瀏覽代碼

refactor e2e tests

Ran Greenberg 8 年之前
父節點
當前提交
ffe86e383f
共有 1 個檔案被更改,包括 31 行新增19 行删除
  1. 31
    19
      playground/e2e/app.test.js

+ 31
- 19
playground/e2e/app.test.js 查看文件

13
     expect(elementByLabel('Hello from a function!')).toBeVisible();
13
     expect(elementByLabel('Hello from a function!')).toBeVisible();
14
   });
14
   });
15
 
15
 
16
-  it('push screen', () => {
17
-    elementByLabel('Push').tap();
18
-    expect(elementByLabel('Pushed Screen')).toBeVisible();
19
-  });
20
-
21
   it('switch to tabs with side menus', () => {
16
   it('switch to tabs with side menus', () => {
22
     elementByLabel('Switch to app with side menus').tap();
17
     elementByLabel('Switch to app with side menus').tap();
23
     elementByLabel('This is a side menu center screen tab 1').swipe('right');
18
     elementByLabel('This is a side menu center screen tab 1').swipe('right');
31
     expect(elementByLabel('Alert')).toBeVisible();
26
     expect(elementByLabel('Alert')).toBeVisible();
32
     expect(elementByLabel('onStop!')).toBeVisible();
27
     expect(elementByLabel('onStop!')).toBeVisible();
33
   });
28
   });
29
+});
30
+
31
+describe('screen stack', () => {
32
+  beforeEach((done) => {
33
+    global.simulator.relaunchApp(done);
34
+  });
35
+
36
+  it('push screen', () => {
37
+    elementByLabel('Push').tap();
38
+    expect(elementByLabel('Pushed Screen')).toBeVisible();
39
+  });
34
 
40
 
35
   it('pop screen', () => {
41
   it('pop screen', () => {
36
     elementByLabel('Push').tap();
42
     elementByLabel('Push').tap();
39
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
45
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
40
   });
46
   });
41
   
47
   
42
-  it.only('pop screen deep in the stack', () => {
48
+  it('pop screen deep in the stack', () => {
43
     elementByLabel('Push').tap();
49
     elementByLabel('Push').tap();
44
     expect(elementByLabel('Stack Position: 1')).toBeVisible();
50
     expect(elementByLabel('Stack Position: 1')).toBeVisible();
45
     elementByLabel('Push').tap();
51
     elementByLabel('Push').tap();
48
     expect(elementByLabel('Stack Position: 2')).toBeVisible();
54
     expect(elementByLabel('Stack Position: 2')).toBeVisible();
49
     elementByLabel('Pop').tap();
55
     elementByLabel('Pop').tap();
50
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
56
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
51
-  
52
   });
57
   });
58
+});
59
+
53
 
60
 
61
+describe('modal', () => {
62
+  beforeEach((done) => {
63
+    global.simulator.relaunchApp(done);
64
+  });
65
+  
54
   it('show modal', () => {
66
   it('show modal', () => {
55
     elementByLabel('Show Modal').tap();
67
     elementByLabel('Show Modal').tap();
56
     expect(elementByLabel('Modal Screen')).toBeVisible();
68
     expect(elementByLabel('Modal Screen')).toBeVisible();
57
   });
69
   });
58
-
70
+  
59
   it('dismiss modal', () => {
71
   it('dismiss modal', () => {
60
     elementByLabel('Show Modal').tap();
72
     elementByLabel('Show Modal').tap();
61
     expect(elementByLabel('Modal Screen')).toBeVisible();
73
     expect(elementByLabel('Modal Screen')).toBeVisible();
62
     elementByLabel('Dismiss Modal').tap();
74
     elementByLabel('Dismiss Modal').tap();
63
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
75
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
64
   });
76
   });
65
-
77
+  
66
   it('show multiple modals', () => {
78
   it('show multiple modals', () => {
67
     elementByLabel('Show Modal').tap();
79
     elementByLabel('Show Modal').tap();
68
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
80
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
73
     elementByLabel('Dismiss Modal').tap();
85
     elementByLabel('Dismiss Modal').tap();
74
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
86
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
75
   });
87
   });
76
-
88
+  
77
   it('dismiss unknown screen id', () => {
89
   it('dismiss unknown screen id', () => {
78
     elementByLabel('Show Modal').tap();
90
     elementByLabel('Show Modal').tap();
79
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
91
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
82
     elementByLabel('Dismiss Modal').tap();
94
     elementByLabel('Dismiss Modal').tap();
83
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
95
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
84
   });
96
   });
85
-
97
+  
86
   it('dismiss modal by id which is not the top most', () => {
98
   it('dismiss modal by id which is not the top most', () => {
87
     elementByLabel('Show Modal').tap();
99
     elementByLabel('Show Modal').tap();
88
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
100
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
93
     elementByLabel('Dismiss Modal').tap();
105
     elementByLabel('Dismiss Modal').tap();
94
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
106
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
95
   });
107
   });
96
-
108
+  
97
   it('dismiss all previous modals by id when they are below top presented modal', () => {
109
   it('dismiss all previous modals by id when they are below top presented modal', () => {
98
     elementByLabel('Show Modal').tap();
110
     elementByLabel('Show Modal').tap();
99
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
111
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
101
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
113
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
102
     elementByLabel('Show Modal').tap();
114
     elementByLabel('Show Modal').tap();
103
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
115
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
104
-
116
+    
105
     elementByLabel('Dismiss ALL Previous Modals').tap();
117
     elementByLabel('Dismiss ALL Previous Modals').tap();
106
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
118
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
107
-
119
+    
108
     elementByLabel('Dismiss Modal').tap();
120
     elementByLabel('Dismiss Modal').tap();
109
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
121
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
110
   });
122
   });
111
-
123
+  
112
   it('dismiss some modal by id deep in the stack', () => {
124
   it('dismiss some modal by id deep in the stack', () => {
113
     elementByLabel('Show Modal').tap();
125
     elementByLabel('Show Modal').tap();
114
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
126
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
116
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
128
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
117
     elementByLabel('Show Modal').tap();
129
     elementByLabel('Show Modal').tap();
118
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
130
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
119
-
131
+    
120
     elementByLabel('Dismiss First In Stack').tap();
132
     elementByLabel('Dismiss First In Stack').tap();
121
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
133
     expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
122
-
134
+    
123
     elementByLabel('Dismiss Modal').tap();
135
     elementByLabel('Dismiss Modal').tap();
124
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
136
     expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
125
-
137
+    
126
     elementByLabel('Dismiss Modal').tap();
138
     elementByLabel('Dismiss Modal').tap();
127
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
139
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
128
   });
140
   });
129
-
141
+  
130
   it('dismissAllModals', () => {
142
   it('dismissAllModals', () => {
131
     elementByLabel('Show Modal').tap();
143
     elementByLabel('Show Modal').tap();
132
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
144
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();