Browse Source

Add SideMenu inside BottomTabs e2e

This test checks if mergeOptions are applied correctly on SideMenu child contained inside BottomTabs layout
Guy Carmeli 6 years ago
parent
commit
d73caad8bd

+ 11
- 0
e2e/ComplexLayout.test.js View File

19
     await elementById(testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK).tap();
19
     await elementById(testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK).tap();
20
     await expect(elementByLabel('External component in deep stack')).toBeVisible();
20
     await expect(elementByLabel('External component in deep stack')).toBeVisible();
21
   });
21
   });
22
+
23
+  test(':android: merge options correctly in SideMenu inside BottomTabs layout', async () => {
24
+    await elementById(testIDs.COMPLEX_LAYOUT_BUTTON).tap();
25
+    await elementById(testIDs.SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB).tap();
26
+    await elementById(testIDs.SECOND_TAB_BAR_BUTTON).tap();
27
+    await elementById(testIDs.OPEN_SIDE_MENU).tap();
28
+    await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
29
+
30
+    await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
31
+    await expect(elementByLabel('This is a left side menu screen')).toBeNotVisible();
32
+  });
22
 });
33
 });

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

100
                 options: {
100
                 options: {
101
                   bottomTab: {
101
                   bottomTab: {
102
                     text: 'SideMenu',
102
                     text: 'SideMenu',
103
-                    icon: require('../images/two.png')
103
+                    icon: require('../images/two.png'),
104
+                    testID: testIDs.SECOND_TAB_BAR_BUTTON
104
                   }
105
                   }
105
                 }
106
                 }
106
               }
107
               }

+ 7
- 6
playground/src/screens/complexlayouts/BottomTabSideMenuScreen.js View File

2
 const { Component } = require('react');
2
 const { Component } = require('react');
3
 const { View, Button } = require('react-native');
3
 const { View, Button } = require('react-native');
4
 const { Navigation } = require('react-native-navigation');
4
 const { Navigation } = require('react-native-navigation');
5
+const testIDs = require('../../testIDs');
5
 
6
 
6
 class BottomTabSideMenuScreen extends Component {
7
 class BottomTabSideMenuScreen extends Component {
7
-   onOpenSideMenuPress = () => {
8
-   Navigation.mergeOptions(this.props.componentId, {
8
+  onOpenSideMenuPress = () => {
9
+    Navigation.mergeOptions(this.props.componentId, {
9
       sideMenu: {
10
       sideMenu: {
10
         left: {
11
         left: {
11
           visible: true
12
           visible: true
13
       }
14
       }
14
     });
15
     });
15
   }
16
   }
16
-   render() {
17
+  render() {
17
     return (
18
     return (
18
       <View style={styles.root}>
19
       <View style={styles.root}>
19
         <Button
20
         <Button
20
           title="Open SideMenu"
21
           title="Open SideMenu"
21
           color="blue"
22
           color="blue"
22
           onPress={this.onOpenSideMenuPress}
23
           onPress={this.onOpenSideMenuPress}
23
-          //TODO: testID for detox 
24
+          testID={testIDs.OPEN_SIDE_MENU}
24
         />
25
         />
25
       </View>
26
       </View>
26
     );
27
     );
27
   }
28
   }
28
 }
29
 }
29
- module.exports = BottomTabSideMenuScreen;
30
- const styles = {
30
+module.exports = BottomTabSideMenuScreen;
31
+const styles = {
31
   root: {
32
   root: {
32
     flexGrow: 1,
33
     flexGrow: 1,
33
     justifyContent: 'center',
34
     justifyContent: 'center',

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

71
   SHOW_TOPBAR_SEARCHBAR: `SHOW_TOPBAR_SEARCHBAR`,
71
   SHOW_TOPBAR_SEARCHBAR: `SHOW_TOPBAR_SEARCHBAR`,
72
   SEARCH_RESULT_ITEM: `SEARCH_RESULT_ITEM`,
72
   SEARCH_RESULT_ITEM: `SEARCH_RESULT_ITEM`,
73
   HIDE_BOTTOM_TABS_ON_PUSH_BUTTON: `HIDE_BOTTOM_TABS_ON_PUSH_BUTTON`,
73
   HIDE_BOTTOM_TABS_ON_PUSH_BUTTON: `HIDE_BOTTOM_TABS_ON_PUSH_BUTTON`,
74
+  SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB: `SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB`,
75
+  OPEN_SIDE_MENU: `OPEN_SIDE_MENU`,
74
   
76
   
75
   // Elements
77
   // Elements
76
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
78
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,