ソースを参照

refctor ios e2e

Daniel Zlotin 7 年 前
コミット
ebcf770a42
共有4 個のファイルを変更した108 個の追加103 個の削除を含む
  1. 0
    103
      e2e/Modals.test.js
  2. 44
    0
      e2e/ScreenStack.test.js
  3. 10
    0
      e2e/ScreenStyleStatic.test.js
  4. 54
    0
      e2e/TopLevelApi.test.js

e2e/app.test.js → e2e/Modals.test.js ファイルの表示

@@ -1,82 +1,3 @@
1
-describe('top level api', () => {
2
-  beforeEach(async () => {
3
-    await device.relaunchApp();
4
-  });
5
-
6
-  it('shows welcome screen', async () => {
7
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
8
-  });
9
-
10
-  it('switch to tab based app, passProps and functions', async () => {
11
-    await elementByLabel('Switch to tab based app').tap();
12
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
13
-    await expect(elementByLabel('Hello from a function!')).toBeVisible();
14
-  });
15
-
16
-  it('switch to tabs with side menus', async () => {
17
-    await elementByLabel('Switch to app with side menus').tap();
18
-    await elementByLabel('This is a side menu center screen tab 1').swipe('right');
19
-    await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
20
-  });
21
-
22
-  it('screen lifecycle', async () => {
23
-    await elementByLabel('Push lifecycle screen').tap();
24
-    await expect(elementByLabel('onStart')).toBeVisible();
25
-    await elementByLabel('Push to test onStop').tap();
26
-    await expect(elementByLabel('Alert')).toBeVisible();
27
-    await expect(elementByLabel('onStop')).toBeVisible();
28
-  });
29
-
30
-  it('unmount is called on pop', async () => {
31
-    await elementByLabel('Push lifecycle screen').tap();
32
-    await expect(elementByLabel('onStart')).toBeVisible();
33
-    await element(by.traits(['button']).and(by.label('Back'))).tap();
34
-    await expect(elementByLabel('onStop')).toBeVisible();
35
-    await expect(elementByLabel('componentWillUnmount')).toBeVisible();
36
-  });
37
-});
38
-
39
-describe('screen stack', () => {
40
-  beforeEach(async () => {
41
-    await device.relaunchApp();
42
-  });
43
-
44
-  it('push and pop screen', async () => {
45
-    await elementByLabel('Push').tap();
46
-    await expect(elementByLabel('Pushed Screen')).toBeVisible();
47
-    await elementByLabel('Pop').tap();
48
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
49
-  });
50
-
51
-  it('pop screen deep in the stack', async () => {
52
-    await elementByLabel('Push').tap();
53
-    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
54
-    await elementByLabel('Push').tap();
55
-    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
56
-    await elementByLabel('Pop Previous').tap();
57
-    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
58
-    await elementByLabel('Pop').tap();
59
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
60
-  });
61
-
62
-  it('pop to specific id', async () => {
63
-    await elementByLabel('Push').tap();
64
-    await elementByLabel('Push').tap();
65
-    await elementByLabel('Push').tap();
66
-    await expect(elementByLabel('Stack Position: 3')).toBeVisible();
67
-    await elementByLabel('Pop To Stack Position 1').tap();
68
-    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
69
-  });
70
-
71
-  it('pop to root', async () => {
72
-    await elementByLabel('Push').tap();
73
-    await elementByLabel('Push').tap();
74
-    await elementByLabel('Push').tap();
75
-    await elementByLabel('Pop To Root').tap();
76
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
77
-  });
78
-});
79
-
80 1
 describe('modal', () => {
81 2
   beforeEach(async () => {
82 3
     await device.relaunchApp();
@@ -168,30 +89,6 @@ describe('modal', () => {
168 89
   });
169 90
 });
170 91
 
171
-describe('reload app', async () => {
172
-  beforeEach(async () => {
173
-    await device.relaunchApp();
174
-  });
175
-
176
-  it('push a screen to ensure its not there after reload', async () => {
177
-    await elementByLabel('Push').tap();
178
-    await expect(elementByLabel('Pushed Screen')).toBeVisible();
179
-    await device.reloadReactNative();
180
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
181
-  });
182
-});
183
-
184
-describe('screen style - static', () => {
185
-  beforeEach(async () => {
186
-    await device.relaunchApp();
187
-  });
188
-
189
-  it('declare a navigationStyle on container component', async () => {
190
-    await elementByLabel('Push').tap();
191
-    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
192
-  });
193
-});
194
-
195 92
 function elementByLabel(label) {
196 93
   return element(by.label(label));
197 94
 }

+ 44
- 0
e2e/ScreenStack.test.js ファイルの表示

@@ -0,0 +1,44 @@
1
+describe('screen stack', () => {
2
+  beforeEach(async () => {
3
+    await device.relaunchApp();
4
+  });
5
+
6
+  it('push and pop screen', async () => {
7
+    await elementByLabel('Push').tap();
8
+    await expect(elementByLabel('Pushed Screen')).toBeVisible();
9
+    await elementByLabel('Pop').tap();
10
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
11
+  });
12
+
13
+  it('pop screen deep in the stack', async () => {
14
+    await elementByLabel('Push').tap();
15
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
16
+    await elementByLabel('Push').tap();
17
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
18
+    await elementByLabel('Pop Previous').tap();
19
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
20
+    await elementByLabel('Pop').tap();
21
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
22
+  });
23
+
24
+  it('pop to specific id', async () => {
25
+    await elementByLabel('Push').tap();
26
+    await elementByLabel('Push').tap();
27
+    await elementByLabel('Push').tap();
28
+    await expect(elementByLabel('Stack Position: 3')).toBeVisible();
29
+    await elementByLabel('Pop To Stack Position 1').tap();
30
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
31
+  });
32
+
33
+  it('pop to root', async () => {
34
+    await elementByLabel('Push').tap();
35
+    await elementByLabel('Push').tap();
36
+    await elementByLabel('Push').tap();
37
+    await elementByLabel('Pop To Root').tap();
38
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
39
+  });
40
+});
41
+
42
+function elementByLabel(label) {
43
+  return element(by.label(label));
44
+}

+ 10
- 0
e2e/ScreenStyleStatic.test.js ファイルの表示

@@ -0,0 +1,10 @@
1
+describe('screen style - static', () => {
2
+  beforeEach(async () => {
3
+    await device.relaunchApp();
4
+  });
5
+
6
+  it('declare a navigationStyle on container component', async () => {
7
+    await element(by.label('Push')).tap();
8
+    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
9
+  });
10
+});

+ 54
- 0
e2e/TopLevelApi.test.js ファイルの表示

@@ -0,0 +1,54 @@
1
+describe('top level api', () => {
2
+  beforeEach(async () => {
3
+    await device.relaunchApp();
4
+  });
5
+
6
+  it('shows welcome screen', async () => {
7
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
8
+  });
9
+
10
+  it('switch to tab based app, passProps and functions', async () => {
11
+    await elementByLabel('Switch to tab based app').tap();
12
+    await expect(elementByLabel('This is tab 1')).toBeVisible();
13
+    await expect(elementByLabel('Hello from a function!')).toBeVisible();
14
+  });
15
+
16
+  it('switch to tabs with side menus', async () => {
17
+    await elementByLabel('Switch to app with side menus').tap();
18
+    await elementByLabel('This is a side menu center screen tab 1').swipe('right');
19
+    await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
20
+  });
21
+
22
+  it('screen lifecycle', async () => {
23
+    await elementByLabel('Push lifecycle screen').tap();
24
+    await expect(elementByLabel('onStart')).toBeVisible();
25
+    await elementByLabel('Push to test onStop').tap();
26
+    await expect(elementByLabel('Alert')).toBeVisible();
27
+    await expect(elementByLabel('onStop')).toBeVisible();
28
+  });
29
+
30
+  it('unmount is called on pop', async () => {
31
+    await elementByLabel('Push lifecycle screen').tap();
32
+    await expect(elementByLabel('onStart')).toBeVisible();
33
+    await element(by.traits(['button']).and(by.label('Back'))).tap();
34
+    await expect(elementByLabel('onStop')).toBeVisible();
35
+    await expect(elementByLabel('componentWillUnmount')).toBeVisible();
36
+  });
37
+});
38
+
39
+describe('reload app', async () => {
40
+  beforeEach(async () => {
41
+    await device.relaunchApp();
42
+  });
43
+
44
+  it('push a screen to ensure its not there after reload', async () => {
45
+    await elementByLabel('Push').tap();
46
+    await expect(elementByLabel('Pushed Screen')).toBeVisible();
47
+    await device.reloadReactNative();
48
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
49
+  });
50
+});
51
+
52
+function elementByLabel(label) {
53
+  return element(by.label(label));
54
+}