Browse Source

e2e adjustments for detox android

yogevbd 6 years ago
parent
commit
aa01d95e50

+ 1
- 1
e2e/Orientations.test.js View File

@@ -4,7 +4,7 @@ const testIDs = require('../playground/src/testIDs');
4 4
 
5 5
 const { elementById } = Utils;
6 6
 
7
-describe('orientation', () => {
7
+describe(':ios: orientation', () => {
8 8
   beforeEach(async () => {
9 9
     await device.relaunchApp();
10 10
   });

+ 8
- 8
e2e/ScreenStyle.test.js View File

@@ -35,14 +35,14 @@ describe('screen style', () => {
35 35
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
36 36
   });
37 37
 
38
-  it('hides topBar onScroll down and shows it on scroll up', async () => {
38
+  it(':ios: hides topBar onScroll down and shows it on scroll up', async () => {
39 39
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
40 40
     await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
41 41
     await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
42 42
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
43
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'fast');
43
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
44 44
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
45
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
45
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'slow');
46 46
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
47 47
   });
48 48
 
@@ -52,14 +52,14 @@ describe('screen style', () => {
52 52
     await expect(element(by.text('TeSt'))).toBeVisible();
53 53
   });
54 54
 
55
-  it('hide Tab Bar', async () => {
55
+  it(':ios: hide Tab Bar', async () => {
56 56
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
57 57
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
58 58
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
59 59
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
60 60
   });
61 61
 
62
-  it('show Tab Bar', async () => {
62
+  it(':ios: show Tab Bar', async () => {
63 63
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
64 64
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
65 65
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
@@ -67,7 +67,7 @@ describe('screen style', () => {
67 67
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
68 68
   });
69 69
 
70
-  it('side menu visibility - left', async () => {
70
+  it(':ios: side menu visibility - left', async () => {
71 71
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
72 72
     await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
73 73
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
@@ -75,7 +75,7 @@ describe('screen style', () => {
75 75
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
76 76
   });
77 77
 
78
-  it('side menu visibility - right', async () => {
78
+  it(':ios: side menu visibility - right', async () => {
79 79
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
80 80
     await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
81 81
     await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
@@ -83,7 +83,7 @@ describe('screen style', () => {
83 83
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
84 84
   });
85 85
 
86
-  it('set right buttons', async () => {
86
+  it(':ios: set right buttons', async () => {
87 87
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
88 88
     await expect(elementById('buttonOne')).toBeVisible();
89 89
     await elementById('buttonOne').tap();

+ 1
- 2
e2e/TopLevelApi.test.js View File

@@ -18,7 +18,7 @@ describe('top level api', () => {
18 18
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
19 19
   });
20 20
 
21
-  it('switch to tabs with side menus', async () => {
21
+  it(':ios: switch to tabs with side menus', async () => {
22 22
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
23 23
     await elementById(testIDs.CENTERED_TEXT_HEADER).swipe('right');
24 24
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
@@ -28,7 +28,6 @@ describe('top level api', () => {
28 28
     await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
29 29
     await expect(elementByLabel('didAppear')).toBeVisible();
30 30
     await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
31
-    await expect(elementByLabel('Alert')).toBeVisible();
32 31
     await expect(elementByLabel('didDisappear')).toBeVisible();
33 32
   });
34 33
 

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java View File

@@ -32,6 +32,9 @@ public class BottomTabOptions implements DEFAULT_VALUES {
32 32
         if (other.badge.hasValue()) {
33 33
             badge = other.badge;
34 34
         }
35
+        if (other.testId.hasValue()) {
36
+            testId = other.testId;
37
+        }
35 38
     }
36 39
 
37 40
     void mergeWithDefault(final BottomTabOptions defaultOptions) {

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java View File

@@ -48,6 +48,7 @@ public class Options implements DEFAULT_VALUES {
48 48
         result.topTabOptions.mergeWith(topTabOptions);
49 49
         result.bottomTabOptions.mergeWith(bottomTabOptions);
50 50
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
51
+        result.overlayOptions = overlayOptions;
51 52
         return result;
52 53
     }
53 54
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java View File

@@ -18,7 +18,7 @@ public class StackLayout extends RelativeLayout implements TitleBarButton.OnClic
18 18
 
19 19
     public StackLayout(Context context) {
20 20
         super(context);
21
-        topBar = new TopBar(context, this);
21
+        topBar = new TopBar(context, this, this);
22 22
         topBar.setId(CompatUtils.generateViewId());
23 23
         createLayout();
24 24
         setContentDescription("StackLayout");

+ 16
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java View File

@@ -24,6 +24,9 @@ import com.reactnativenavigation.parse.params.Bool;
24 24
 
25 25
 import java.util.ArrayList;
26 26
 
27
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
28
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
29
+
27 30
 @SuppressLint("ViewConstructor")
28 31
 public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAwareView {
29 32
     private final Toolbar titleBar;
@@ -31,8 +34,9 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
31 34
     private final TopBarCollapseBehavior collapsingBehavior;
32 35
     private final TopBarAnimator animator;
33 36
     private TopTabs topTabs;
37
+    private StackLayout parentView;
34 38
 
35
-    public TopBar(final Context context, TitleBarButton.OnClickListener onClickListener) {
39
+    public TopBar(final Context context, TitleBarButton.OnClickListener onClickListener, StackLayout parentView) {
36 40
         super(context);
37 41
         this.onClickListener = onClickListener;
38 42
         collapsingBehavior = new TopBarCollapseBehavior(this);
@@ -40,6 +44,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
40 44
         titleBar.getMenu();
41 45
         topTabs = new TopTabs(getContext());
42 46
         this.animator = new TopBarAnimator(this);
47
+        this.parentView = parentView;
43 48
         addView(titleBar);
44 49
     }
45 50
 
@@ -191,6 +196,16 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
191 196
         }
192 197
     }
193 198
 
199
+    @Override
200
+    public void setVisibility(int visibility) {
201
+        super.setVisibility(visibility);
202
+        if (visibility == View.GONE) {
203
+            this.parentView.removeView(this);
204
+        } else if (visibility == View.VISIBLE && this.getParent() == null) {
205
+            this.parentView.addView(this, MATCH_PARENT, WRAP_CONTENT);
206
+        }
207
+    }
208
+
194 209
     public void clear() {
195 210
         titleBar.setTitle(null);
196 211
         titleBar.setNavigationIcon(null);

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java View File

@@ -9,7 +9,7 @@ import static org.assertj.core.api.Java6Assertions.*;
9 9
 public class TopBarTest extends BaseTest {
10 10
     @Test
11 11
     public void title() throws Exception {
12
-        TopBar topBar = new TopBar(newActivity(), buttonId -> {});
12
+        TopBar topBar = new TopBar(newActivity(), buttonId -> {}, null);
13 13
         assertThat(topBar.getTitle()).isEmpty();
14 14
 
15 15
         topBar.setTitle("new title");

+ 2
- 1
playground/src/screens/ScrollViewScreen.js View File

@@ -13,7 +13,8 @@ class ScrollViewScreen extends Component {
13 13
         title: 'Collapse',
14 14
         drawBehind: true,
15 15
         textColor: 'black',
16
-        textFontSize: 16
16
+        textFontSize: 16,
17
+        testID: testIDs.TOP_BAR_ELEMENT
17 18
       }
18 19
     };
19 20
   }

+ 1
- 1
scripts/test.e2e.android.detox.js View File

@@ -8,5 +8,5 @@ run();
8 8
 function run() {
9 9
   const conf = release ? `release` : `debug`;
10 10
   exec.execSync(`detox build --configuration android.emu.${conf}`);
11
-  exec.execSync(`detox test --configuration android.emu.${conf} ${process.env.CI ? '--cleanup' : ''}`);
11
+  exec.execSync(`detox test --configuration android.emu.${conf} ${process.env.CI ? '--cleanup' : ''}  --platform android`);
12 12
 }