Browse Source

Prevent setRoot from removing existing overlays, added e2e test

yogevbd 5 years ago
parent
commit
7c9e0f83a8

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

@@ -40,4 +40,12 @@ describe('Overlay', () => {
40 40
     await device.setOrientation('landscape');
41 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,12 +55,11 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
55 55
 	[self assertReady];
56 56
 	
57 57
 	[_modalManager dismissAllModalsAnimated:NO];
58
-	[_store removeAllComponents];
59 58
 	
60 59
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
61 60
 	
62 61
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
63
-	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
62
+	[UIApplication.sharedApplication.delegate.window makeKeyWindow];
64 63
 	[_eventEmitter sendOnNavigationCommandCompletion:setRoot params:@{@"layout": layout}];
65 64
 	completion();
66 65
 }

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

@@ -18,6 +18,7 @@ class CustomDialog extends PureComponent {
18 18
       <View style={styles.root}>
19 19
         <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>Test view</Text>
20 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 22
       </View>
22 23
     );
23 24
   }
@@ -27,9 +28,20 @@ class CustomDialog extends PureComponent {
27 28
       Alert.alert('Overlay disappeared');
28 29
     }
29 30
   }
31
+  
30 32
   onCLickOk() {
31 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 47
 const styles = {

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

@@ -73,6 +73,7 @@ module.exports = {
73 73
   HIDE_BOTTOM_TABS_ON_PUSH_BUTTON: `HIDE_BOTTOM_TABS_ON_PUSH_BUTTON`,
74 74
   SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB: `SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB`,
75 75
   OPEN_SIDE_MENU: `OPEN_SIDE_MENU`,
76
+  SET_ROOT_BUTTON: `SET_ROOT_BUTTON`,
76 77
   
77 78
   // Elements
78 79
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,