@@ -22,6 +22,9 @@ describe('Example', () => {
22
22
} ) ;
23
23
24
24
it ( 'should have title and hermes indicator on android' , async ( ) => {
25
+ await waitFor ( element ( by . id ( 'appRootView' ) ) )
26
+ . toBeVisible ( )
27
+ . withTimeout ( 5000 ) ;
25
28
await expect ( element ( by . id ( 'appRootView' ) ) ) . toBeVisible ( ) ;
26
29
await expect ( element ( by . text ( 'Example DateTime Picker' ) ) ) . toBeVisible ( ) ;
27
30
if ( device . getPlatform ( ) === 'android' ) {
@@ -30,7 +33,7 @@ describe('Example', () => {
30
33
} ) ;
31
34
32
35
it ( 'should show date picker after tapping datePicker button' , async ( ) => {
33
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
36
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
34
37
35
38
if ( global . device . getPlatform ( ) === 'ios' ) {
36
39
await expect (
@@ -42,7 +45,7 @@ describe('Example', () => {
42
45
} ) ;
43
46
44
47
it ( 'Nothing should happen if date doesn`t change' , async ( ) => {
45
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
48
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
46
49
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
47
50
48
51
if ( global . device . getPlatform ( ) === 'ios' ) {
@@ -57,23 +60,23 @@ describe('Example', () => {
57
60
) ;
58
61
testElement . swipe ( 'left' , 'fast' , '100' ) ;
59
62
testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
60
- element ( by . text ( 'CANCEL' ) ) . tap ( ) ;
63
+ await element ( by . text ( 'CANCEL' ) ) . tap ( ) ;
61
64
}
62
65
63
66
await expect ( dateTimeText ) . toHaveText ( '08/21/2020' ) ;
64
67
} ) ;
65
68
66
69
it ( 'should update dateTimeText when date changes' , async ( ) => {
67
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
70
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
68
71
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
69
72
70
73
if ( global . device . getPlatform ( ) === 'ios' ) {
71
74
const testElement = element (
72
75
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
73
76
) ;
74
- testElement . setColumnToValue ( 0 , 'November' ) ;
75
- testElement . setColumnToValue ( 1 , '3' ) ;
76
- testElement . setColumnToValue ( 2 , '1800' ) ;
77
+ await testElement . setColumnToValue ( 0 , 'November' ) ;
78
+ await testElement . setColumnToValue ( 1 , '3' ) ;
79
+ await testElement . setColumnToValue ( 2 , '1800' ) ;
77
80
78
81
await expect ( dateTimeText ) . toHaveText ( '11/03/1800' ) ;
79
82
} else {
@@ -82,16 +85,16 @@ describe('Example', () => {
82
85
. type ( 'android.widget.ScrollView' )
83
86
. withAncestor ( by . type ( 'android.widget.DatePicker' ) ) ,
84
87
) ;
85
- testElement . swipe ( 'left' , 'fast' , '100' ) ;
86
- testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
87
- element ( by . text ( 'OK' ) ) . tap ( ) ;
88
+ await testElement . swipe ( 'left' , 'fast' , '100' ) ;
89
+ await testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
90
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
88
91
89
92
await expect ( dateTimeText ) . toHaveText ( '09/13/2020' ) ;
90
93
}
91
94
} ) ;
92
95
93
96
it ( 'should show time picker after tapping timePicker button' , async ( ) => {
94
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
97
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
95
98
96
99
if ( global . device . getPlatform ( ) === 'ios' ) {
97
100
await expect (
@@ -103,7 +106,7 @@ describe('Example', () => {
103
106
} ) ;
104
107
105
108
it ( 'Nothing should happen if time doesn`t change' , async ( ) => {
106
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
109
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
107
110
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
108
111
109
112
if ( global . device . getPlatform ( ) === 'ios' ) {
@@ -119,16 +122,16 @@ describe('Example', () => {
119
122
} ) ;
120
123
121
124
it ( 'should change time text when time changes' , async ( ) => {
122
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
125
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
123
126
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
124
127
125
128
if ( global . device . getPlatform ( ) === 'ios' ) {
126
129
const testElement = element (
127
130
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
128
131
) ;
129
- testElement . setColumnToValue ( 0 , '2' ) ;
130
- testElement . setColumnToValue ( 1 , '44' ) ;
131
- testElement . setColumnToValue ( 2 , 'PM' ) ;
132
+ await testElement . setColumnToValue ( 0 , '2' ) ;
133
+ await testElement . setColumnToValue ( 1 , '44' ) ;
134
+ await testElement . setColumnToValue ( 2 , 'PM' ) ;
132
135
133
136
await expect ( dateTimeText ) . toHaveText ( '14:44' ) ;
134
137
} else {
@@ -139,105 +142,82 @@ describe('Example', () => {
139
142
}
140
143
} ) ;
141
144
142
- it ( "shouldn't change time text when time changes to less than half of minuteInterval" , async ( ) => {
143
- element ( by . id ( 'timePickerIntervalButton ' ) ) . tap ( ) ;
145
+ it ( 'should correct time text when using minuteInterval' , async ( ) => {
146
+ await element ( by . id ( 'timePickerDefaultIntervalButton ' ) ) . tap ( ) ;
144
147
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
145
148
146
149
if ( global . device . getPlatform ( ) === 'ios' ) {
147
150
const testElement = element (
148
151
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
149
152
) ;
150
- testElement . setColumnToValue ( 0 , '2' ) ;
151
- testElement . setColumnToValue ( 1 , '42' ) ;
152
- testElement . setColumnToValue ( 2 , 'PM' ) ;
153
-
154
- await expect ( dateTimeText ) . toHaveText ( '14:40' ) ;
155
- } else {
156
- const keyboardButton = element (
157
- by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
158
- ) ;
159
- keyboardButton . tap ( ) ;
160
- const testElement = element (
161
- by
162
- . type ( 'androidx.appcompat.widget.AppCompatEditText' )
163
- . and ( by . text ( '15' ) ) ,
164
- ) ;
165
- testElement . tap ( ) ;
166
- testElement . replaceText ( '17' ) ;
167
- element ( by . text ( 'OK' ) ) . tap ( ) ;
168
-
169
- await expect ( dateTimeText ) . toHaveText ( '23:15' ) ;
170
- }
171
- } ) ;
172
-
173
- it ( 'should change time text when time changes to more than half of minuteInterval' , async ( ) => {
174
- element ( by . id ( 'timePickerIntervalButton' ) ) . tap ( ) ;
175
- const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
176
-
177
- if ( global . device . getPlatform ( ) === 'ios' ) {
178
- const testElement = element (
179
- by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
180
- ) ;
181
- testElement . setColumnToValue ( 0 , '2' ) ;
182
- testElement . setColumnToValue ( 1 , '44' ) ;
183
- testElement . setColumnToValue ( 2 , 'PM' ) ;
153
+ await testElement . setColumnToValue ( 0 , '2' ) ;
154
+ await testElement . setColumnToValue ( 1 , '45' ) ;
155
+ await testElement . setColumnToValue ( 2 , 'PM' ) ;
184
156
185
157
await expect ( dateTimeText ) . toHaveText ( '14:45' ) ;
186
158
} else {
187
159
const keyboardButton = element (
188
160
by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
189
161
) ;
190
- keyboardButton . tap ( ) ;
162
+ await keyboardButton . tap ( ) ;
191
163
const testElement = element (
192
164
by
193
165
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
194
166
. and ( by . text ( '15' ) ) ,
195
167
) ;
196
- testElement . tap ( ) ;
197
- testElement . replaceText ( '18' ) ;
198
- element ( by . text ( 'OK' ) ) . tap ( ) ;
168
+ await testElement . tap ( ) ;
169
+ await testElement . replaceText ( '18' ) ;
170
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
199
171
200
172
await expect ( dateTimeText ) . toHaveText ( '23:20' ) ;
201
173
}
202
174
} ) ;
203
175
204
- it ( 'should correct input on the fly on android ' , async ( ) => {
205
- element ( by . id ( 'timePickerIntervalButton ' ) ) . tap ( ) ;
176
+ it ( 'should change minutes when pressing in default interval button ' , async ( ) => {
177
+ await element ( by . id ( 'timePickerDefaultIntervalButton ' ) ) . tap ( ) ;
206
178
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
207
179
208
- if ( global . device . getPlatform ( ) !== 'ios ') {
180
+ if ( global . device . getPlatform ( ) === 'android ') {
209
181
const keyboardButton = element (
210
182
by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
211
183
) ;
212
- keyboardButton . tap ( ) ;
184
+ await keyboardButton . tap ( ) ;
213
185
214
- element (
186
+ await element (
215
187
by
216
188
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
217
189
. and ( by . text ( '15' ) ) ,
218
190
) . tap ( ) ;
219
- element (
191
+
192
+ await element (
220
193
by
221
194
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
222
195
. and ( by . text ( '15' ) ) ,
223
196
) . tapBackspaceKey ( ) ;
197
+
224
198
element (
225
199
by
226
200
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
227
201
. and ( by . text ( '1' ) ) ,
228
- ) . typeText ( '8' ) ;
202
+ ) ;
203
+
204
+ const minuteTextinput = element (
205
+ by . type ( 'androidx.appcompat.widget.AppCompatEditText' ) ,
206
+ ) . atIndex ( 1 ) ;
207
+
208
+ await minuteTextinput . replaceText ( '55' ) ;
229
209
230
210
await expect (
231
211
element (
232
212
by
233
213
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
234
- . and ( by . text ( '18 ' ) ) ,
214
+ . and ( by . text ( '55 ' ) ) ,
235
215
) ,
236
- ) . toExist ( ) ;
216
+ ) . toBeVisible ( ) ;
237
217
238
- element ( by . text ( 'OK' ) ) . tap ( ) ;
218
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
239
219
240
- await expect ( dateTimeText ) . toHaveText ( '23:20 ' ) ;
220
+ await expect ( dateTimeText ) . toHaveText ( '23:55 ' ) ;
241
221
}
242
222
} ) ;
243
223
} ) ;
0 commit comments