ソースを参照

navigation bars e2e with testIDs (#2365)

yogevbd 7 年 前
コミット
0d0b7dbef6
No account linked to committer's email address
共有4 個のファイルを変更した34 個の追加22 個の削除を含む
  1. 17
    17
      e2e/ScreenStyle.test.js
  2. 2
    1
      playground/src/containers/OptionsScreen.js
  3. 9
    2
      playground/src/containers/TextScreen.js
  4. 6
    2
      playground/src/testIDs.js

+ 17
- 17
e2e/ScreenStyle.test.js ファイルの表示

@@ -10,14 +10,14 @@ describe('screen style', () => {
10 10
 
11 11
   it('declare a navigationOptions on container component', async () => {
12 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 16
   it('change title on container component', async () => {
17 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 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 23
   it('set dynamic options with valid options will do something and not crash', async () => {
@@ -30,20 +30,20 @@ describe('screen style', () => {
30 30
   it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
31 31
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
32 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 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 38
   it('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
-    await expect(element(by.type('UINavigationBar'))).toBeVisible();
42
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
43 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 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 49
   it('makes topBar transparent and opaque', async () => {
@@ -61,18 +61,18 @@ describe('screen style', () => {
61 61
   });
62 62
 
63 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 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 78
   it('side menu visibility - left', async () => {

+ 2
- 1
playground/src/containers/OptionsScreen.js ファイルの表示

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

+ 9
- 2
playground/src/containers/TextScreen.js ファイルの表示

@@ -7,6 +7,13 @@ const Navigation = require('react-native-navigation');
7 7
 const testIDs = require('../testIDs');
8 8
 
9 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 18
   render() {
12 19
     return (
@@ -16,8 +23,8 @@ class TextScreen extends Component {
16 23
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
17 24
         <Button title={'Set Tab Badge'} testID={testIDs.SET_TAB_BADGE_BUTTON} onPress={() => this.onButtonPress()} />
18 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 28
         <Button title="Show Left Side Menu" testID={testIDs.SHOW_LEFT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('left')} />
22 29
         <Button title="Show Right Side Menu" testID={testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON} onPress={() => this.showSideMenu('right')} />
23 30
       </View>

+ 6
- 2
playground/src/testIDs.js ファイルの表示

@@ -40,14 +40,18 @@ module.exports = {
40 40
   SHOW_RIGHT_SIDE_MENU_BUTTON: `SHOW_RIGHT_SIDE_MENU_BUTTON`,
41 41
   HIDE_LEFT_SIDE_MENU_BUTTON: `HIDE_LEFT_SIDE_MENU_BUTTON`,
42 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 46
   // Elements
45 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 51
   // Headers
49 52
   WELCOME_SCREEN_HEADER: `WELCOME_SCREEN_HEADER`,
50 53
   PUSHED_SCREEN_HEADER: `PUSHED_SCREEN_HEADER`,
51 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
 };