Browse Source

Use Overlay alert on iOS to address flakiness in CI (#6186)

* Use Overlay alert on iOS to address flakiness in CI
Guy Carmeli 4 years ago
parent
commit
5ac9fb64da
No account linked to committer's email address
2 changed files with 16 additions and 14 deletions
  1. 9
    10
      playground/src/app.js
  2. 7
    4
      playground/src/screens/LifecycleScreen.js

+ 9
- 10
playground/src/app.js View File

6
 const testIDs = require('./testIDs');
6
 const testIDs = require('./testIDs');
7
 const Screens = require('./screens/Screens');
7
 const Screens = require('./screens/Screens');
8
 
8
 
9
-if (Platform.OS === 'android') {
10
-  alert = (title, message) => Navigation.showOverlay({
11
-    component: {
12
-      name: Screens.Alert,
13
-      passProps: {
14
-        title,
15
-        message
16
-      }
9
+// @ts-ignore
10
+alert = (title, message) => Navigation.showOverlay({
11
+  component: {
12
+    name: Screens.Alert,
13
+    passProps: {
14
+      title,
15
+      message
17
     }
16
     }
18
-  });
19
-};
17
+  }
18
+});
20
 
19
 
21
 function start() {
20
 function start() {
22
   registerScreens();
21
   registerScreens();

+ 7
- 4
playground/src/screens/LifecycleScreen.js View File

65
   push = () => Navigation.push(this, Screens.Pushed);
65
   push = () => Navigation.push(this, Screens.Pushed);
66
   screenPoppedEvent = async () => {
66
   screenPoppedEvent = async () => {
67
     this.showUnmountAndDisappearAlerts = false;
67
     this.showUnmountAndDisappearAlerts = false;
68
-    const unregister = Navigation.events().registerScreenPoppedListener((event) => {
69
-      alert('Screen popped event')
70
-      unregister.remove();
68
+    const promise = new Promise((resolve) => {
69
+      const unregister = Navigation.events().registerScreenPoppedListener((event) => {
70
+        alert('Screen popped event');
71
+        unregister.remove();
72
+        resolve();
73
+      });
71
     });
74
     });
72
-    await Navigation.pop(this);
75
+    await Promise.all([Navigation.pop(this), promise]);
73
   }
76
   }
74
   pop = () => Navigation.pop(this);
77
   pop = () => Navigation.pop(this);
75
   dismiss = () => Navigation.dismissModal(this);
78
   dismiss = () => Navigation.dismissModal(this);