Browse Source

navigation bars e2e with testIDs (#2365)

yogevbd 7 years ago
parent
commit
0d0b7dbef6
No account linked to committer's email address

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

10
 
10
 
11
   it('declare a navigationOptions on container component', async () => {
11
   it('declare a navigationOptions on container component', async () => {
12
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
12
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
13
-    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
13
+    await expect(element(by.label('Static Title'))).toBeVisible();
14
   });
14
   });
15
 
15
 
16
   it('change title on container component', async () => {
16
   it('change title on container component', async () => {
17
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
17
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
18
-    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
18
+    await expect(element(by.label('Static Title'))).toBeVisible();
19
     await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
19
     await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
20
-    await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
20
+    await expect(element(by.label('Dynamic Title'))).toBeVisible();
21
   });
21
   });
22
 
22
 
23
   it('set dynamic options with valid options will do something and not crash', async () => {
23
   it('set dynamic options with valid options will do something and not crash', async () => {
30
   it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
30
   it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
31
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
31
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
32
     await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
32
     await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
33
-    await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
33
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
34
     await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
34
     await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
35
-    await expect(element(by.type('UINavigationBar'))).toBeVisible();
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('hides topBar onScroll down and shows it on scroll up', async () => {
39
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
39
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
40
     await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
40
     await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
41
     await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
41
     await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
42
-    await expect(element(by.type('UINavigationBar'))).toBeVisible();
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', 'fast');
44
-    await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
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', 'fast');
46
-    await expect(element(by.type('UINavigationBar'))).toBeVisible();
46
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
47
   });
47
   });
48
 
48
 
49
   it('makes topBar transparent and opaque', async () => {
49
   it('makes topBar transparent and opaque', async () => {
61
   });
61
   });
62
 
62
 
63
   it('hide Tab Bar', async () => {
63
   it('hide Tab Bar', async () => {
64
-    await elementByLabel('Switch to tab based app').tap();
65
-    await expect(element(by.type('UITabBar'))).toBeVisible();
66
-    await elementByLabel('Hide Tab Bar').tap();
67
-    await expect(element(by.type('UITabBar'))).toBeNotVisible();
64
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
65
+    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
66
+    await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
67
+    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
68
   });
68
   });
69
 
69
 
70
   it('show Tab Bar', async () => {
70
   it('show Tab Bar', async () => {
71
-    await elementByLabel('Switch to tab based app').tap();
72
-    await elementByLabel('Hide Tab Bar').tap();
73
-    await expect(element(by.type('UITabBar'))).toBeNotVisible();
74
-    await elementByLabel('Show Tab Bar').tap();
75
-    await expect(element(by.type('UITabBar'))).toBeVisible();
71
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
72
+    await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
73
+    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
74
+    await elementById(testIDs.SHOW_BOTTOM_TABS_BUTTON).tap();
75
+    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
76
   });
76
   });
77
 
77
 
78
   it('side menu visibility - left', async () => {
78
   it('side menu visibility - left', async () => {

+ 2
- 1
playground/src/containers/OptionsScreen.js View File

19
         largeTitle: false,
19
         largeTitle: false,
20
         hidden: false,
20
         hidden: false,
21
         textFontSize: 16,
21
         textFontSize: 16,
22
-        textFontFamily: 'HelveticaNeue-Italic'
22
+        textFontFamily: 'HelveticaNeue-Italic',
23
+        testID: testIDs.TOP_BAR_ELEMENT
23
       },
24
       },
24
       rightButtons: [{
25
       rightButtons: [{
25
         id: BUTTON_ONE,
26
         id: BUTTON_ONE,

+ 9
- 2
playground/src/containers/TextScreen.js View File

7
 const testIDs = require('../testIDs');
7
 const testIDs = require('../testIDs');
8
 
8
 
9
 class TextScreen extends Component {
9
 class TextScreen extends Component {
10
+  static get navigationOptions() {
11
+    return {
12
+      bottomTabs: {
13
+        testID: testIDs.BOTTOM_TABS_ELEMENT
14
+      }
15
+    };
16
+  }
10
 
17
 
11
   render() {
18
   render() {
12
     return (
19
     return (
16
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
23
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
17
         <Button title={'Set Tab Badge'} testID={testIDs.SET_TAB_BADGE_BUTTON} onPress={() => this.onButtonPress()} />
24
         <Button title={'Set Tab Badge'} testID={testIDs.SET_TAB_BADGE_BUTTON} onPress={() => this.onButtonPress()} />
18
         <Button title={'Switch To Tab 2'} testID={testIDs.SWITCH_SECOND_TAB_BUTTON} onPress={() => this.onClickSwitchToTab()} />
25
         <Button title={'Switch To Tab 2'} testID={testIDs.SWITCH_SECOND_TAB_BUTTON} onPress={() => this.onClickSwitchToTab()} />
19
-        <Button title="Hide Tab Bar" onPress={() => this.hideTabBar(true)} />
20
-        <Button title="Show Tab Bar" onPress={() => this.hideTabBar(false)} />
26
+        <Button title="Hide Tab Bar" testID={testIDs.HIDE_BOTTOM_TABS_BUTTON} onPress={() => this.hideTabBar(true)} />
27
+        <Button title="Show Tab Bar" testID={testIDs.SHOW_BOTTOM_TABS_BUTTON} onPress={() => this.hideTabBar(false)} />
21
         <Button title="Show Left Side Menu" testID={testIDs.SHOW_LEFT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('left')} />
28
         <Button title="Show Left Side Menu" testID={testIDs.SHOW_LEFT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('left')} />
22
         <Button title="Show Right Side Menu" testID={testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('right')} />
29
         <Button title="Show Right Side Menu" testID={testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('right')} />
23
       </View>
30
       </View>

+ 6
- 2
playground/src/testIDs.js View File

40
   SHOW_RIGHT_SIDE_MENU_BUTTON: `SHOW_RIGHT_SIDE_MENU_BUTTON`,
40
   SHOW_RIGHT_SIDE_MENU_BUTTON: `SHOW_RIGHT_SIDE_MENU_BUTTON`,
41
   HIDE_LEFT_SIDE_MENU_BUTTON: `HIDE_LEFT_SIDE_MENU_BUTTON`,
41
   HIDE_LEFT_SIDE_MENU_BUTTON: `HIDE_LEFT_SIDE_MENU_BUTTON`,
42
   HIDE_RIGHT_SIDE_MENU_BUTTON: `HIDE_RIGHT_SIDE_MENU_BUTTON`,
42
   HIDE_RIGHT_SIDE_MENU_BUTTON: `HIDE_RIGHT_SIDE_MENU_BUTTON`,
43
+  HIDE_BOTTOM_TABS_BUTTON: `HIDE_BOTTOM_TABS_BUTTON`,
44
+  SHOW_BOTTOM_TABS_BUTTON: `SHOW_BOTTOM_TABS_BUTTON`,
43
 
45
 
44
   // Elements
46
   // Elements
45
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
47
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
46
-  CENTERED_TEXT_HEADER: `CENTERED_TEXT_HEADER`,
48
+  BOTTOM_TABS_ELEMENT: `BOTTOM_TABS_ELEMENT`,
49
+  TOP_BAR_ELEMENT: `TOP_BAR_ELEMENT`,
47
 
50
 
48
   // Headers
51
   // Headers
49
   WELCOME_SCREEN_HEADER: `WELCOME_SCREEN_HEADER`,
52
   WELCOME_SCREEN_HEADER: `WELCOME_SCREEN_HEADER`,
50
   PUSHED_SCREEN_HEADER: `PUSHED_SCREEN_HEADER`,
53
   PUSHED_SCREEN_HEADER: `PUSHED_SCREEN_HEADER`,
51
   OPTIONS_SCREEN_HEADER: `OPTIONS_SCREEN_HEADER`,
54
   OPTIONS_SCREEN_HEADER: `OPTIONS_SCREEN_HEADER`,
52
-  MODAL_SCREEN: `MODAL_SCREEN`
55
+  MODAL_SCREEN: `MODAL_SCREEN`,
56
+  CENTERED_TEXT_HEADER: `CENTERED_TEXT_HEADER`
53
 };
57
 };