@@ -255,8 +255,15 @@ public void InputDateInteractsWithEditContext_NullableDateTimeOffset()
255
255
public void InputDateInteractsWithEditContext_TimeInput ( )
256
256
{
257
257
var appElement = MountTypicalValidationComponent ( ) ;
258
- var departureTimeInput = appElement . FindElement ( By . ClassName ( "departure-time" ) ) . FindElement ( By . TagName ( "input" ) ) ;
259
258
var messagesAccessor = CreateValidationMessagesAccessor ( appElement ) ;
259
+ var departureTimeInput = appElement . FindElement ( By . ClassName ( "departure-time" ) ) . FindElement ( By . Id ( "time-input" ) ) ;
260
+ var includeSecondsCheckbox = appElement . FindElement ( By . ClassName ( "departure-time" ) ) . FindElement ( By . Id ( "time-seconds-checkbox" ) ) ;
261
+
262
+ // Ensure we're not using a custom step
263
+ if ( includeSecondsCheckbox . Selected )
264
+ {
265
+ includeSecondsCheckbox . Click ( ) ;
266
+ }
260
267
261
268
// Validates on edit
262
269
Browser . Equal ( "valid" , ( ) => departureTimeInput . GetAttribute ( "class" ) ) ;
@@ -271,7 +278,39 @@ public void InputDateInteractsWithEditContext_TimeInput()
271
278
Browser . Equal ( new [ ] { "The DepartureTime field must be a time." } , messagesAccessor ) ;
272
279
}
273
280
274
- [ Fact ( Skip = "https://github.com/dotnet/aspnetcore/issues/35498" ) ]
281
+ [ Fact ]
282
+ public void InputDateInteractsWithEditContext_TimeInput_Step ( )
283
+ {
284
+ var appElement = MountTypicalValidationComponent ( ) ;
285
+ var messagesAccessor = CreateValidationMessagesAccessor ( appElement ) ;
286
+ var departureTimeInput = appElement . FindElement ( By . ClassName ( "departure-time" ) ) . FindElement ( By . Id ( "time-input" ) ) ;
287
+ var includeSecondsCheckbox = appElement . FindElement ( By . ClassName ( "departure-time" ) ) . FindElement ( By . Id ( "time-seconds-checkbox" ) ) ;
288
+
289
+ // Ensure we're using a custom step
290
+ if ( ! includeSecondsCheckbox . Selected )
291
+ {
292
+ includeSecondsCheckbox . Click ( ) ;
293
+ }
294
+
295
+ // Input works with seconds value of zero and has the expected final value
296
+ Browser . Equal ( "valid" , ( ) => departureTimeInput . GetAttribute ( "class" ) ) ;
297
+ departureTimeInput . SendKeys ( "111111" ) ;
298
+ Browser . Equal ( "modified valid" , ( ) => departureTimeInput . GetAttribute ( "class" ) ) ;
299
+ Browser . Equal ( "11:11:11" , ( ) => departureTimeInput . GetAttribute ( "value" ) ) ;
300
+
301
+ // Input works with non-zero seconds value
302
+ // Move to the beginning of the input and put the new time
303
+ departureTimeInput . SendKeys ( string . Concat ( Enumerable . Repeat ( Keys . ArrowLeft , 3 ) ) + "101010" ) ;
304
+ Browser . Equal ( "modified valid" , ( ) => departureTimeInput . GetAttribute ( "class" ) ) ;
305
+ Browser . Equal ( "10:10:10" , ( ) => departureTimeInput . GetAttribute ( "value" ) ) ;
306
+
307
+ // Can become invalid
308
+ departureTimeInput . SendKeys ( Keys . Backspace ) ;
309
+ Browser . Equal ( "modified invalid" , ( ) => departureTimeInput . GetAttribute ( "class" ) ) ;
310
+ Browser . Equal ( new [ ] { "The DepartureTime field must be a time." } , messagesAccessor ) ;
311
+ }
312
+
313
+ [ Fact ]
275
314
public void InputDateInteractsWithEditContext_MonthInput ( )
276
315
{
277
316
var appElement = MountTypicalValidationComponent ( ) ;
@@ -283,50 +322,92 @@ public void InputDateInteractsWithEditContext_MonthInput()
283
322
visitMonthInput . SendKeys ( $ "03{ Keys . ArrowRight } 2005\t ") ;
284
323
Browser . Equal ( "modified valid" , ( ) => visitMonthInput . GetAttribute ( "class" ) ) ;
285
324
286
- // Can become invalid
287
- visitMonthInput . SendKeys ( $ "11 { Keys . ArrowRight } 11111 \t " ) ;
325
+ // Empty is invalid because it's not nullable
326
+ visitMonthInput . Clear ( ) ;
288
327
Browser . Equal ( "modified invalid" , ( ) => visitMonthInput . GetAttribute ( "class" ) ) ;
289
328
Browser . Equal ( new [ ] { "The VisitMonth field must be a year and month." } , messagesAccessor ) ;
290
329
291
- // Empty is invalid, because it's not nullable
292
- visitMonthInput . SendKeys ( $ "{ Keys . Backspace } \t { Keys . Backspace } \t ") ;
330
+ // Invalid year (11111)
331
+ visitMonthInput . SendKeys ( $ "11 { Keys . ArrowRight } 11111 \t ") ;
293
332
Browser . Equal ( "modified invalid" , ( ) => visitMonthInput . GetAttribute ( "class" ) ) ;
294
333
Browser . Equal ( new [ ] { "The VisitMonth field must be a year and month." } , messagesAccessor ) ;
295
334
335
+ // Can become valid again
296
336
visitMonthInput . Clear ( ) ;
297
- visitMonthInput . SendKeys ( $ "05 { Keys . ArrowRight } 2007 \t ") ;
337
+ visitMonthInput . SendKeys ( $ "11 { Keys . ArrowRight } 1111 \t ") ;
298
338
Browser . Equal ( "modified valid" , ( ) => visitMonthInput . GetAttribute ( "class" ) ) ;
299
339
Browser . Empty ( messagesAccessor ) ;
300
340
}
301
341
302
- [ Fact ( Skip = "https://github.com/dotnet/aspnetcore/issues/35498" ) ]
342
+ [ Fact ]
303
343
[ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/34884" ) ]
304
344
public void InputDateInteractsWithEditContext_DateTimeLocalInput ( )
305
345
{
306
346
var appElement = MountTypicalValidationComponent ( ) ;
307
- var appointmentInput = appElement . FindElement ( By . ClassName ( "appointment-date-time" ) ) . FindElement ( By . TagName ( "input" ) ) ;
308
347
var messagesAccessor = CreateValidationMessagesAccessor ( appElement ) ;
348
+ var appointmentInput = appElement . FindElement ( By . ClassName ( "appointment-date-time" ) ) . FindElement ( By . Id ( "datetime-local-input" ) ) ;
349
+ var includeSecondsCheckbox = appElement . FindElement ( By . ClassName ( "appointment-date-time" ) ) . FindElement ( By . Id ( "datetime-local-seconds-checkbox" ) ) ;
309
350
310
- // Validates on edit
351
+ // Ensure we're not using a custom step
352
+ if ( includeSecondsCheckbox . Selected )
353
+ {
354
+ includeSecondsCheckbox . Click ( ) ;
355
+ }
356
+
357
+ // Validates on edit and has the expected value
311
358
Browser . Equal ( "valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
312
- appointmentInput . SendKeys ( "01 \t 02 \t 1988 \t 0523 \t 1 ") ;
359
+ appointmentInput . SendKeys ( $ "01011970 { Keys . ArrowRight } 05421 ") ;
313
360
Browser . Equal ( "modified valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
314
361
315
- // Can become invalid
316
- appointmentInput . SendKeys ( $ "11 { Keys . ArrowRight } 11 { Keys . ArrowRight } 11111 { Keys . ArrowRight } \t " ) ;
362
+ // Empty is invalid because it's not nullable
363
+ appointmentInput . Clear ( ) ;
317
364
Browser . Equal ( "modified invalid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
318
365
Browser . Equal ( new [ ] { "The AppointmentDateAndTime field must be a date and time." } , messagesAccessor ) ;
319
366
320
- // Empty is invalid, because it's not nullable
321
- appointmentInput . SendKeys ( $ "{ Keys . Backspace } \t { Keys . Backspace } \t { Keys . Backspace } \t { Keys . Backspace } \t { Keys . Backspace } \t { Keys . Backspace } \t ") ;
367
+ // Invalid year (11111)
368
+ appointmentInput . SendKeys ( $ "111111111 { Keys . ArrowRight } 11111 ") ;
322
369
Browser . Equal ( "modified invalid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
323
370
Browser . Equal ( new [ ] { "The AppointmentDateAndTime field must be a date and time." } , messagesAccessor ) ;
324
371
325
- appointmentInput . SendKeys ( "01234567\t 11551\t " ) ;
372
+ // Can become valid again
373
+ appointmentInput . Clear ( ) ;
374
+ appointmentInput . SendKeys ( $ "11111111{ Keys . ArrowRight } 11111") ;
326
375
Browser . Equal ( "modified valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
327
376
Browser . Empty ( messagesAccessor ) ;
328
377
}
329
378
379
+ [ Fact ]
380
+ public void InputDateInteractsWithEditContext_DateTimeLocalInput_Step ( )
381
+ {
382
+ var appElement = MountTypicalValidationComponent ( ) ;
383
+ var messagesAccessor = CreateValidationMessagesAccessor ( appElement ) ;
384
+ var appointmentInput = appElement . FindElement ( By . ClassName ( "appointment-date-time" ) ) . FindElement ( By . Id ( "datetime-local-input" ) ) ;
385
+ var includeSecondsCheckbox = appElement . FindElement ( By . ClassName ( "appointment-date-time" ) ) . FindElement ( By . Id ( "datetime-local-seconds-checkbox" ) ) ;
386
+
387
+ // Ensure we're using a custom step
388
+ if ( ! includeSecondsCheckbox . Selected )
389
+ {
390
+ includeSecondsCheckbox . Click ( ) ;
391
+ }
392
+
393
+ // Input works with seconds value of zero and has the expected final value
394
+ Browser . Equal ( "valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
395
+ appointmentInput . SendKeys ( $ "11111970{ Keys . ArrowRight } 114216") ;
396
+ Browser . Equal ( "modified valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
397
+ Browser . Equal ( "1970-11-11T11:42:16" , ( ) => appointmentInput . GetAttribute ( "value" ) ) ;
398
+
399
+ // Input works with non-zero seconds value
400
+ // Move to the beginning of the input and put the new value
401
+ appointmentInput . SendKeys ( string . Concat ( Enumerable . Repeat ( Keys . ArrowLeft , 6 ) ) + $ "10101970{ Keys . ArrowRight } 105321") ;
402
+ Browser . Equal ( "modified valid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
403
+ Browser . Equal ( "1970-10-10T10:53:21" , ( ) => appointmentInput . GetAttribute ( "value" ) ) ;
404
+
405
+ // Can become invalid
406
+ appointmentInput . SendKeys ( Keys . Backspace ) ;
407
+ Browser . Equal ( "modified invalid" , ( ) => appointmentInput . GetAttribute ( "class" ) ) ;
408
+ Browser . Equal ( new [ ] { "The AppointmentDateAndTime field must be a date and time." } , messagesAccessor ) ;
409
+ }
410
+
330
411
[ Fact ]
331
412
public void InputSelectInteractsWithEditContext ( )
332
413
{
0 commit comments