瀏覽代碼

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

* Use Overlay alert on iOS to address flakiness in CI
Guy Carmeli 4 年之前
父節點
當前提交
5ac9fb64da
No account linked to committer's email address
共有 2 個文件被更改,包括 16 次插入14 次删除
  1. 9
    10
      playground/src/app.js
  2. 7
    4
      playground/src/screens/LifecycleScreen.js

+ 9
- 10
playground/src/app.js 查看文件

@@ -6,17 +6,16 @@ const { setDefaultOptions } = require('./commons/Options')
6 6
 const testIDs = require('./testIDs');
7 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 20
 function start() {
22 21
   registerScreens();

+ 7
- 4
playground/src/screens/LifecycleScreen.js 查看文件

@@ -65,11 +65,14 @@ class LifecycleScreen extends React.Component {
65 65
   push = () => Navigation.push(this, Screens.Pushed);
66 66
   screenPoppedEvent = async () => {
67 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 77
   pop = () => Navigation.pop(this);
75 78
   dismiss = () => Navigation.dismissModal(this);