@@ -34,233 +34,179 @@ const expectBackButtonMenuToNotExistOnLabel = async (text: string) => {
34
34
await expect ( element ( by . type ( '_UIContextMenuView' ) ) ) . not . toExist ( ) ;
35
35
} ;
36
36
37
+ const expectInitialPageToExist = async ( testName : string , expectToExist : Detox . NativeMatcher , expectToNotExist ?: Detox . NativeMatcher ) => {
38
+ await element ( by . text ( testName ) ) . tap ( ) ;
39
+ await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
40
+ await expect ( element ( expectToExist ) ) . toBeVisible ( ) ;
41
+ if ( expectToNotExist ) {
42
+ await expect ( element ( expectToNotExist ) ) . not . toBeVisible ( ) ;
43
+ }
44
+ } ;
37
45
38
46
describeIfiOS ( 'Test2809' , ( ) => {
39
- beforeAll ( async ( ) => {
40
- await device . reloadReactNative ( ) ;
41
- } ) ;
47
+ beforeAll ( async ( ) => {
48
+ await device . reloadReactNative ( ) ;
49
+ } ) ;
42
50
43
51
it ( 'Test2809 should exist' , async ( ) => {
44
- await waitFor ( element ( by . id ( 'root-screen-tests-Test2809' ) ) )
45
- . toBeVisible ( )
46
- . whileElement ( by . id ( 'root-screen-examples-scrollview' ) )
47
- . scroll ( 600 , 'down' , NaN , 0.85 ) ;
52
+ await waitFor ( element ( by . id ( 'root-screen-tests-Test2809' ) ) )
53
+ . toBeVisible ( )
54
+ . whileElement ( by . id ( 'root-screen-examples-scrollview' ) )
55
+ . scroll ( 600 , 'down' , NaN , 0.85 ) ;
48
56
49
- await expect ( element ( by . id ( 'root-screen-tests-Test2809' ) ) ) . toBeVisible ( ) ;
50
- await element ( by . id ( 'root-screen-tests-Test2809' ) ) . tap ( ) ;
51
- } ) ;
57
+ await expect ( element ( by . id ( 'root-screen-tests-Test2809' ) ) ) . toBeVisible ( ) ;
58
+ await element ( by . id ( 'root-screen-tests-Test2809' ) ) . tap ( ) ;
59
+ } ) ;
52
60
53
61
describe ( 'backButtonMenuEnabled: true' , ( ) => {
62
+ afterEach ( async ( ) => {
63
+ await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
64
+ } ) ;
65
+
54
66
describe ( 'backButtonDisplayMode: default' , ( ) => {
55
- it ( 'with default text' , async ( ) => {
56
- await element ( by . text ( 'EnabledDefaultDefaultText' ) ) . tap ( ) ;
57
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
58
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
67
+ it ( 'default text stays visible and matches label in back button menu' , async ( ) => {
68
+ await expectInitialPageToExist ( 'EnabledDefaultDefaultText' , by . text ( 'First' ) ) ;
59
69
await expectBackButtonMenuWithTheSameLabel ( 'First' ) ; // Check if backButtonMenu works
60
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
61
70
} ) ;
62
71
63
- it ( 'with custom text' , async ( ) => {
64
- await element ( by . text ( 'EnabledDefaultCustomText' ) ) . tap ( ) ;
65
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
66
- await expect ( element ( by . text ( 'Custom' ) ) ) . toBeVisible ( ) ;
72
+ it ( 'custom text stays visible and matches label in back button menu' , async ( ) => {
73
+ await expectInitialPageToExist ( 'EnabledDefaultCustomText' , by . text ( 'Custom' ) ) ;
67
74
await expectBackButtonMenuWithTheSameLabel ( 'Custom' ) ; // Check if backButtonMenu works
68
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
69
75
} ) ;
70
76
71
77
// We don't check if the styles are applied, I think that it could be flaky, but it can be done
72
78
// using element(by.type('UIButtonLabel')).getAttributes() and looking at bounds. The values there
73
79
// doesn't match the ones in the code exactly (I think some padding is added), so I don't think we should do that.
74
- it ( 'with styled text' , async ( ) => {
75
- await element ( by . text ( 'EnabledDefaultStyledText' ) ) . tap ( ) ;
76
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
77
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
80
+ it ( 'styled text stays visible and matches label in back button menu' , async ( ) => {
81
+ await expectInitialPageToExist ( 'EnabledDefaultStyledText' , by . text ( 'First' ) ) ;
78
82
await expectBackButtonMenuWithTheSameLabel ( 'First' ) ; // Check if backButtonMenu works
79
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
80
83
} ) ;
81
84
} ) ;
82
85
83
86
describe ( 'backButtonDisplayMode: generic' , ( ) => {
84
- it ( 'with default text' , async ( ) => {
85
- await element ( by . text ( 'EnabledGenericDefaultText' ) ) . tap ( ) ;
86
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
87
- await expect ( element ( by . text ( 'Back' ) ) ) . toBeVisible ( ) ;
87
+ it ( 'default text is truncated by backButtonDisplayMode and is used in back button menu' , async ( ) => {
88
+ await expectInitialPageToExist ( 'EnabledGenericDefaultText' , by . text ( 'Back' ) ) ;
88
89
await expectBackButtonMenuWithDifferentLabels ( 'Back' , 'First' ) ; // Check if backButtonMenu works
89
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
90
90
} ) ;
91
91
92
92
// TODO: We should be able to fix that
93
93
// Custom text overrides backButtonDisplayMode
94
- it ( 'has custom text' , async ( ) => {
95
- await element ( by . text ( 'EnabledGenericCustomText' ) ) . tap ( ) ;
96
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
97
- await expect ( element ( by . text ( 'Custom' ) ) ) . toBeVisible ( ) ; // TODO: We should be able to fix that
94
+ it ( 'custom text is NOT truncated by backButtonDisplayMode and is used in back button menu' , async ( ) => {
95
+ await expectInitialPageToExist ( 'EnabledGenericCustomText' , by . text ( 'Custom' ) ) ;
98
96
await expectBackButtonMenuWithTheSameLabel ( 'Custom' ) ; // Check if backButtonMenu works
99
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
100
97
} ) ;
101
98
102
99
// Custom styles override backButtonDisplayMode
103
- it ( 'with custom text' , async ( ) => {
104
- await element ( by . text ( 'EnabledGenericStyledText' ) ) . tap ( ) ;
105
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
106
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
100
+ it ( 'styled text is NOT truncated by backButtonDisplayMode and is used in back button menu' , async ( ) => {
101
+ await expectInitialPageToExist ( 'EnabledGenericStyledText' , by . text ( 'First' ) ) ;
107
102
await expectBackButtonMenuWithTheSameLabel ( 'First' ) ; // Check if backButtonMenu works
108
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
109
103
} ) ;
110
104
} ) ;
111
105
112
106
describe ( 'backButtonDisplayMode: minimal' , ( ) => {
113
- it ( 'with default text' , async ( ) => {
114
- await element ( by . text ( 'EnabledMinimalDefaultText' ) ) . tap ( ) ;
115
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
116
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
117
- await expect ( element ( by . text ( 'First' ) ) ) . not . toBeVisible ( ) ;
107
+ it ( 'chevron is used as back button and default text is used in back button menu' , async ( ) => {
108
+ await expectInitialPageToExist ( 'EnabledMinimalDefaultText' , by . id ( 'chevron.backward' ) , by . text ( 'First' ) ) ;
118
109
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'First' ) ; // Check if backButtonMenu works
119
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
120
110
} ) ;
121
111
122
- it ( 'with custom text' , async ( ) => {
123
- await element ( by . text ( 'EnabledMinimalCustomText' ) ) . tap ( ) ;
124
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
125
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
126
- await expect ( element ( by . text ( 'Custom' ) ) ) . not . toBeVisible ( ) ;
112
+ it ( 'chevron is used as back button and custom text is used in back button menu' , async ( ) => {
113
+ await expectInitialPageToExist ( 'EnabledMinimalCustomText' , by . id ( 'chevron.backward' ) , by . text ( 'Custom' ) ) ;
127
114
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'Custom' ) ; // Check if backButtonMenu works
128
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
129
115
} ) ;
130
116
131
- it ( 'with styled text' , async ( ) => {
132
- await element ( by . text ( 'EnabledMinimalStyledText' ) ) . tap ( ) ;
133
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
134
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
135
- await expect ( element ( by . text ( 'First' ) ) ) . not . toBeVisible ( ) ;
117
+ it ( 'styles are omitted, chevron is used as back button and default text is used in back button menu' , async ( ) => {
118
+ await expectInitialPageToExist ( 'EnabledMinimalStyledText' , by . id ( 'chevron.backward' ) , by . text ( 'First' ) ) ;
136
119
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'First' ) ; // Check if backButtonMenu works
137
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
138
120
} ) ;
139
121
} ) ;
140
122
} ) ;
141
123
142
124
describe ( 'backButtonMenuEnabled: false' , ( ) => {
125
+ afterEach ( async ( ) => {
126
+ await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
127
+ } ) ;
128
+
143
129
describe ( 'backButtonDisplayMode: default' , ( ) => {
144
- it ( 'with default text' , async ( ) => {
145
- await element ( by . text ( 'DisabledDefaultDefaultText' ) ) . tap ( ) ;
146
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
147
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
130
+ it ( 'default text stays visible and back button menu is disabled' , async ( ) => {
131
+ await expectInitialPageToExist ( 'DisabledDefaultDefaultText' , by . text ( 'First' ) ) ;
148
132
await expectBackButtonMenuToNotExistOnLabel ( 'First' ) ; // Check if backButtonMenu is disabled
149
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
150
133
} ) ;
151
134
152
- it ( 'with custom text' , async ( ) => {
153
- await element ( by . text ( 'DisabledDefaultCustomText' ) ) . tap ( ) ;
154
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
155
- await expect ( element ( by . text ( 'Custom' ) ) ) . toBeVisible ( ) ;
135
+ it ( 'custom text stays visible and back button menu is disabled' , async ( ) => {
136
+ await expectInitialPageToExist ( 'DisabledDefaultCustomText' , by . text ( 'Custom' ) ) ;
156
137
await expectBackButtonMenuToNotExistOnLabel ( 'Custom' ) ; // Check if backButtonMenu is disabled
157
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
158
138
} ) ;
159
139
160
- it ( 'with styled text' , async ( ) => {
161
- await element ( by . text ( 'DisabledDefaultStyledText' ) ) . tap ( ) ;
162
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
163
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
140
+ it ( 'styled text stays visible and back button menu is disabled' , async ( ) => {
141
+ await expectInitialPageToExist ( 'DisabledDefaultStyledText' , by . text ( 'First' ) ) ;
164
142
await expectBackButtonMenuToNotExistOnLabel ( 'First' ) ; // Check if backButtonMenu is disabled
165
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
166
143
} ) ;
167
144
} ) ;
168
145
169
146
// [backButtonMenuEnabled: false and backButtonDisplayMode: generic]
170
147
// generic is not working as currently backButtonDisplayMode is causing backButtonItem to be set
171
- describe ( 'backButtonDisplayMode: generic not working' , ( ) => {
172
- it ( 'with default text' , async ( ) => {
173
- await element ( by . text ( 'DisabledGenericDefaultText' ) ) . tap ( ) ;
174
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
175
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
148
+ describe ( 'backButtonDisplayMode: generic' , ( ) => {
149
+ it ( 'default text is visible, because backButtonDisplayMode is overwritten by backButtonDisplayMode' , async ( ) => {
150
+ await expectInitialPageToExist ( 'DisabledGenericDefaultText' , by . text ( 'First' ) ) ;
176
151
await expectBackButtonMenuToNotExistOnLabel ( 'First' ) ; // Check if backButtonMenu is disabled
177
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
178
152
} ) ;
179
153
180
- it ( 'with custom text' , async ( ) => {
181
- await element ( by . text ( 'DisabledGenericCustomText' ) ) . tap ( ) ;
182
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
183
- await expect ( element ( by . text ( 'Custom' ) ) ) . toBeVisible ( ) ;
154
+ it ( 'custom text is visible, because backButtonDisplayMode is overwritten by backButtonDisplayMode' , async ( ) => {
155
+ await expectInitialPageToExist ( 'DisabledGenericCustomText' , by . text ( 'Custom' ) ) ;
184
156
await expectBackButtonMenuToNotExistOnLabel ( 'Custom' ) ; // Check if backButtonMenu is disabled
185
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
186
157
} ) ;
187
158
188
- it ( 'with styled text' , async ( ) => {
189
- await element ( by . text ( 'DisabledGenericStyledText' ) ) . tap ( ) ;
190
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
191
- await expect ( element ( by . text ( 'First' ) ) ) . toBeVisible ( ) ;
159
+ it ( 'styled text is visible, because backButtonDisplayMode is overwritten by backButtonDisplayMode' , async ( ) => {
160
+ await expectInitialPageToExist ( 'DisabledGenericStyledText' , by . text ( 'First' ) ) ;
192
161
await expectBackButtonMenuToNotExistOnLabel ( 'First' ) ; // Check if backButtonMenu is disabled
193
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
194
162
} ) ;
195
163
} ) ;
196
164
197
165
// [backButtonMenuEnabled: false and backButtonDisplayMode: minimal]
198
166
// backButtonDisplayMode: minimal works as a kill switch so backButtonMenu value is omitted
199
167
describe ( 'backButtonDisplayMode: minimal' , ( ) => {
200
- it ( 'with default text' , async ( ) => {
201
- await element ( by . text ( 'DisabledMinimalDefaultText' ) ) . tap ( ) ;
202
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
203
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
204
- await expect ( element ( by . text ( 'First' ) ) ) . not . toBeVisible ( ) ;
168
+ it ( 'chevron is used as back button and default text is used in back button menu, backButtonMenuEnabled is omitted' , async ( ) => {
169
+ await expectInitialPageToExist ( 'DisabledMinimalDefaultText' , by . id ( 'chevron.backward' ) , by . text ( 'First' ) ) ;
205
170
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'First' ) ; // Check if backButtonMenu works
206
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
207
171
} ) ;
208
172
209
- it ( 'with custom text' , async ( ) => {
210
- await element ( by . text ( 'DisabledMinimalCustomText' ) ) . tap ( ) ;
211
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
212
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
213
- await expect ( element ( by . text ( 'Custom' ) ) ) . not . toBeVisible ( ) ;
173
+ it ( 'chevron is used as back button and custom text is used in back button menu, backButtonMenuEnabled is omitted' , async ( ) => {
174
+ await expectInitialPageToExist ( 'DisabledMinimalCustomText' , by . id ( 'chevron.backward' ) , by . text ( 'Custom' ) ) ;
214
175
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'Custom' ) ; // Check if backButtonMenu works
215
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
216
176
} ) ;
217
177
218
- it ( 'with styled text' , async ( ) => {
219
- await element ( by . text ( 'DisabledMinimalStyledText' ) ) . tap ( ) ;
220
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
221
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
222
- await expect ( element ( by . text ( 'First' ) ) ) . not . toBeVisible ( ) ;
178
+ it ( 'backButtonMenuEnabled is omitted, chevron is used as back button and default text is used in back button menu' , async ( ) => {
179
+ await expectInitialPageToExist ( 'DisabledMinimalStyledText' , by . id ( 'chevron.backward' ) , by . text ( 'First' ) ) ;
223
180
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'First' ) ; // Check if backButtonMenu works
224
- await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
225
181
} ) ;
226
182
} ) ;
227
183
} ) ;
228
184
229
185
// Custom
230
- it ( 'Default long back label should be truncated to generic by buckButtonDisplayMode' , async ( ) => {
231
- await element ( by . text ( 'CustomLongDefaultText' ) ) . tap ( ) ;
232
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
233
- await expect ( element ( by . text ( 'Back' ) ) ) . toBeVisible ( ) ;
186
+ it ( 'Default long back label should be truncated to generic by backButtonDisplayMode' , async ( ) => {
187
+ await expectInitialPageToExist ( 'CustomLongDefaultText' , by . text ( 'Back' ) ) ;
234
188
await expectBackButtonMenuWithDifferentLabels ( 'Back' , 'LongLongLongLongLong' ) ; // Check if backButtonMenu works
235
189
await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
236
190
} ) ;
237
191
238
- it ( 'Default label should be truncated to minimal by buckButtonDisplayMode when title is long' , async ( ) => {
239
- await element ( by . text ( 'CustomDefaultTextWithLongTitle' ) ) . tap ( ) ;
240
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
241
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
242
- await expect ( element ( by . text ( 'First' ) ) ) . not . toBeVisible ( ) ;
192
+ it ( 'Default label should be truncated to minimal by backButtonDisplayMode when title is long' , async ( ) => {
193
+ await expectInitialPageToExist ( 'CustomDefaultTextWithLongTitle' , by . id ( 'chevron.backward' ) , by . text ( 'First' ) ) ;
243
194
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'First' ) ; // Check if backButtonMenu works
244
195
await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
245
196
} ) ;
246
197
247
198
// TODO: We should be able to fix that
248
199
// Custom text overrides backButtonDisplayMode because of using backButtonItem
249
- it . failing ( 'Custom long back label should be truncated to generic by buckButtonDisplayMode' , async ( ) => {
250
- await element ( by . text ( 'CustomLongCustomText' ) ) . tap ( ) ;
251
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
252
- await expect ( element ( by . text ( 'Back' ) ) ) . toBeVisible ( ) ;
200
+ it . failing ( 'Custom long back label should be truncated to generic by backButtonDisplayMode' , async ( ) => {
201
+ await expectInitialPageToExist ( 'CustomLongCustomText' , by . text ( 'Back' ) ) ;
253
202
await expectBackButtonMenuWithDifferentLabels ( 'Back' , 'LongLongLongLongLong' ) ; // Check if backButtonMenu works
254
203
await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
255
204
} ) ;
256
205
257
206
// TODO: We should be able to fix that
258
207
// Custom text overrides backButtonDisplayMode because of using backButtonItem
259
- it . failing ( 'Custom back label should be truncated to minimal by buckButtonDisplayMode when title is long' , async ( ) => {
260
- await element ( by . text ( 'CustomCustomTextWithLongTitle' ) ) . tap ( ) ;
261
- await element ( by . text ( 'Open screen' ) ) . tap ( ) ;
262
- await expect ( element ( by . id ( 'chevron.backward' ) ) ) . toBeVisible ( ) ;
263
- await expect ( element ( by . text ( 'CustomBack' ) ) ) . not . toBeVisible ( ) ;
208
+ it . failing ( 'Custom back label should be truncated to minimal by backButtonDisplayMode when title is long' , async ( ) => {
209
+ await expectInitialPageToExist ( 'CustomCustomTextWithLongTitle' , by . id ( 'chevron.backward' ) , by . text ( 'CustomBack' ) ) ;
264
210
await expectBackButtonMenuIconAndLabel ( 'chevron.backward' , 'CustomBack' ) ; // Check if backButtonMenu works
265
211
await element ( by . text ( 'Pop to top' ) ) . tap ( ) ; // Go back
266
212
} ) ;
0 commit comments