瀏覽代碼

Add e2e for pushing screens from side menu

Guy Carmeli 6 年之前
父節點
當前提交
164729ae01

+ 9
- 0
e2e/ScreenStack.test.js 查看文件

@@ -98,4 +98,13 @@ describe('screen stack', () => {
98 98
     await elementById(testIDs.POP_BUTTON).tap();
99 99
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
100 100
   });
101
+
102
+  it(':android: push to stack with static id from SideMenu', async () => {
103
+    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
104
+    await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
105
+    await elementById(testIDs.LEFT_SIDE_MENU_PUSH_BUTTON).tap();
106
+    await expect(elementByLabel('Text Screen')).toBeVisible();
107
+    await elementById(testIDs.POP_BUTTON).tap();
108
+    await expect(elementByLabel('This is a side menu center screen tab 1')).toBeVisible();
109
+  });
101 110
 });

+ 10
- 0
playground/src/screens/SideMenuScreen.js 查看文件

@@ -15,6 +15,7 @@ class SideMenuScreen extends Component {
15 15
         <Text testID={testIDs.SIDE_BAR}>Side Bar</Text>
16 16
         <Text style={styles.h1}>{`This is a ${this.props.side} side menu screen`}</Text>
17 17
         <Button title='Hide Side Menu' testID={testID} onPress={() => this.hideSideMenu()} />
18
+        <Button title='Push' testID={this.props.side + testIDs.SIDE_MENU_PUSH_BUTTON} onPress={() => this.pushAndCloseSideMenu()} />
18 19
       </View>
19 20
     );
20 21
   }
@@ -28,6 +29,15 @@ class SideMenuScreen extends Component {
28 29
       }
29 30
     });
30 31
   }
32
+
33
+  pushAndCloseSideMenu() {
34
+    this.hideSideMenu();
35
+    Navigation.push('tab1Stack', {
36
+      component: {
37
+        name: 'navigation.playground.TextScreen'
38
+      }
39
+    });
40
+  }
31 41
 }
32 42
 module.exports = SideMenuScreen;
33 43
 

+ 1
- 0
playground/src/screens/WelcomeScreen.js 查看文件

@@ -153,6 +153,7 @@ class WelcomeScreen extends Component {
153 153
               children: [
154 154
                 {
155 155
                   stack: {
156
+                    id: 'tab1Stack',
156 157
                     children: [
157 158
                       {
158 159
                         component: {

+ 3
- 0
playground/src/testIDs.js 查看文件

@@ -7,6 +7,9 @@ module.exports = {
7 7
   PUSH_LIFECYCLE_BUTTON: `PUSH_LIFECYCLE_BUTTON`,
8 8
   PUSH_STATIC_LIFECYCLE_BUTTON: `PUSH_STATIC_LIFECYCLE_BUTTON`,
9 9
   PUSH_BUTTON: `PUSH_BUTTON`,
10
+  SIDE_MENU_PUSH_BUTTON: `SIDE_MENU_PUSH_BUTTON`,
11
+  LEFT_SIDE_MENU_PUSH_BUTTON: `leftSIDE_MENU_PUSH_BUTTON`,
12
+  RIGHT_SIDE_MENU_PUSH_BUTTON: `rightSIDE_MENU_PUSH_BUTTON`,
10 13
   PUSH_OPTIONS_BUTTON: `PUSH_OPTIONS_BUTTON`,
11 14
   PUSH_DEFAULT_OPTIONS_BUTTON: `PUSH_DEFAULT_OPTIONS_BUTTON`,
12 15
   SHOW_TOPBAR_REACT_VIEW: `SHOW_TOPBAR_REACT_VIEW`,