Browse Source

Prevent setRoot from removing existing overlays, added e2e test

yogevbd 6 years ago
parent
commit
7c9e0f83a8

+ 8
- 0
e2e/OverlayTest.test.js View File

40
     await device.setOrientation('landscape');
40
     await device.setOrientation('landscape');
41
     await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
41
     await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
42
   });
42
   });
43
+
44
+  test('setRoot should not remove overlay', async () => {
45
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
46
+    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
47
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
48
+    await elementById(testIDs.SET_ROOT_BUTTON).tap();
49
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
50
+  });
43
 });
51
 });

+ 1
- 2
lib/ios/RNNCommandsHandler.m View File

55
 	[self assertReady];
55
 	[self assertReady];
56
 	
56
 	
57
 	[_modalManager dismissAllModalsAnimated:NO];
57
 	[_modalManager dismissAllModalsAnimated:NO];
58
-	[_store removeAllComponents];
59
 	
58
 	
60
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
59
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
61
 	
60
 	
62
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
61
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
63
-	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
62
+	[UIApplication.sharedApplication.delegate.window makeKeyWindow];
64
 	[_eventEmitter sendOnNavigationCommandCompletion:setRoot params:@{@"layout": layout}];
63
 	[_eventEmitter sendOnNavigationCommandCompletion:setRoot params:@{@"layout": layout}];
65
 	completion();
64
 	completion();
66
 }
65
 }

+ 12
- 0
playground/src/screens/CustomDialog.js View File

18
       <View style={styles.root}>
18
       <View style={styles.root}>
19
         <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>Test view</Text>
19
         <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>Test view</Text>
20
         <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
20
         <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
21
+        <Button title='Set Root' testID={testIDs.SET_ROOT_BUTTON} onPress={() => this.onCLickSetRoot()} />
21
       </View>
22
       </View>
22
     );
23
     );
23
   }
24
   }
27
       Alert.alert('Overlay disappeared');
28
       Alert.alert('Overlay disappeared');
28
     }
29
     }
29
   }
30
   }
31
+  
30
   onCLickOk() {
32
   onCLickOk() {
31
     Navigation.dismissOverlay(this.props.componentId);
33
     Navigation.dismissOverlay(this.props.componentId);
32
   }
34
   }
35
+  
36
+  onCLickSetRoot() {
37
+    Navigation.setRoot({
38
+      root: {
39
+        component: {
40
+          name: 'navigation.playground.TextScreen'
41
+        }
42
+      }
43
+    });
44
+  }
33
 }
45
 }
34
 
46
 
35
 const styles = {
47
 const styles = {

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

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`,
74
   SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB: `SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB`,
75
   OPEN_SIDE_MENU: `OPEN_SIDE_MENU`,
75
   OPEN_SIDE_MENU: `OPEN_SIDE_MENU`,
76
+  SET_ROOT_BUTTON: `SET_ROOT_BUTTON`,
76
   
77
   
77
   // Elements
78
   // Elements
78
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
79
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,