Browse Source

Add e2e for pushing screens from side menu

Guy Carmeli 6 years ago
parent
commit
164729ae01

+ 9
- 0
e2e/ScreenStack.test.js View File

98
     await elementById(testIDs.POP_BUTTON).tap();
98
     await elementById(testIDs.POP_BUTTON).tap();
99
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
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 View File

15
         <Text testID={testIDs.SIDE_BAR}>Side Bar</Text>
15
         <Text testID={testIDs.SIDE_BAR}>Side Bar</Text>
16
         <Text style={styles.h1}>{`This is a ${this.props.side} side menu screen`}</Text>
16
         <Text style={styles.h1}>{`This is a ${this.props.side} side menu screen`}</Text>
17
         <Button title='Hide Side Menu' testID={testID} onPress={() => this.hideSideMenu()} />
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
       </View>
19
       </View>
19
     );
20
     );
20
   }
21
   }
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
 module.exports = SideMenuScreen;
42
 module.exports = SideMenuScreen;
33
 
43
 

+ 1
- 0
playground/src/screens/WelcomeScreen.js View File

153
               children: [
153
               children: [
154
                 {
154
                 {
155
                   stack: {
155
                   stack: {
156
+                    id: 'tab1Stack',
156
                     children: [
157
                     children: [
157
                       {
158
                       {
158
                         component: {
159
                         component: {

+ 3
- 0
playground/src/testIDs.js View File

7
   PUSH_LIFECYCLE_BUTTON: `PUSH_LIFECYCLE_BUTTON`,
7
   PUSH_LIFECYCLE_BUTTON: `PUSH_LIFECYCLE_BUTTON`,
8
   PUSH_STATIC_LIFECYCLE_BUTTON: `PUSH_STATIC_LIFECYCLE_BUTTON`,
8
   PUSH_STATIC_LIFECYCLE_BUTTON: `PUSH_STATIC_LIFECYCLE_BUTTON`,
9
   PUSH_BUTTON: `PUSH_BUTTON`,
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
   PUSH_OPTIONS_BUTTON: `PUSH_OPTIONS_BUTTON`,
13
   PUSH_OPTIONS_BUTTON: `PUSH_OPTIONS_BUTTON`,
11
   PUSH_DEFAULT_OPTIONS_BUTTON: `PUSH_DEFAULT_OPTIONS_BUTTON`,
14
   PUSH_DEFAULT_OPTIONS_BUTTON: `PUSH_DEFAULT_OPTIONS_BUTTON`,
12
   SHOW_TOPBAR_REACT_VIEW: `SHOW_TOPBAR_REACT_VIEW`,
15
   SHOW_TOPBAR_REACT_VIEW: `SHOW_TOPBAR_REACT_VIEW`,