Przeglądaj źródła

Add SideMenu inside BottomTabs e2e

This test checks if mergeOptions are applied correctly on SideMenu child contained inside BottomTabs layout
Guy Carmeli 6 lat temu
rodzic
commit
d73caad8bd

+ 11
- 0
e2e/ComplexLayout.test.js Wyświetl plik

@@ -19,4 +19,15 @@ describe('complex layout', () => {
19 19
     await elementById(testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK).tap();
20 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 Wyświetl plik

@@ -100,7 +100,8 @@ class ComplexLayout extends Component {
100 100
                 options: {
101 101
                   bottomTab: {
102 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 Wyświetl plik

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

+ 2
- 0
playground/src/testIDs.js Wyświetl plik

@@ -71,6 +71,8 @@ module.exports = {
71 71
   SHOW_TOPBAR_SEARCHBAR: `SHOW_TOPBAR_SEARCHBAR`,
72 72
   SEARCH_RESULT_ITEM: `SEARCH_RESULT_ITEM`,
73 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 77
   // Elements
76 78
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,