Browse Source

fixed e2e

Daniel Zlotin 6 years ago
parent
commit
362accf16e
2 changed files with 9 additions and 5 deletions
  1. 2
    5
      e2e/TopLevelApi.test.js
  2. 7
    0
      e2e/Utils.js

+ 2
- 5
e2e/TopLevelApi.test.js View File

34
   it('unmount is called on pop', async () => {
34
   it('unmount is called on pop', async () => {
35
     await elementByLabel('Push Lifecycle Screen').tap();
35
     await elementByLabel('Push Lifecycle Screen').tap();
36
     await expect(elementByLabel('didAppear')).toBeVisible();
36
     await expect(elementByLabel('didAppear')).toBeVisible();
37
-    try {
38
-      await element(by.trait(['button']).and(by.label('Back'))).tap();
39
-    } catch (err) {
40
-      await element(by.type('_UIModernBarButton').and(by.label('Back'))).tap();
41
-    }
37
+    await Utils.tapBackIos();
42
     await expect(elementByLabel('didDisappear')).toBeVisible();
38
     await expect(elementByLabel('didDisappear')).toBeVisible();
39
+    await element(by.traits(['button']).and(by.label('OK'))).atIndex(0).tap();
43
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
40
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
44
   });
41
   });
45
 });
42
 });

+ 7
- 0
e2e/Utils.js View File

4
   },
4
   },
5
   elementById: (id) => {
5
   elementById: (id) => {
6
     return element(by.id(id));
6
     return element(by.id(id));
7
+  },
8
+  tapBackIos: () => {
9
+    try {
10
+      return element(by.traits(['button']).and(by.label('Back'))).atIndex(0).tap();
11
+    } catch (err) {
12
+      return element(by.type('_UIModernBarButton').and(by.label('Back'))).tap();
13
+    }
7
   }
14
   }
8
 };
15
 };