@@ -2021,6 +2021,78 @@ public void CanBindTimeStepTextboxNullableTimeOnly()
20212021 Assert . Equal ( string . Empty , mirrorValue . GetAttribute ( "value" ) ) ;
20222022 }
20232023
2024+ [ Fact ]
2025+ public void CanBindDateTimeLocalDefaultStepTextboxDateTime ( )
2026+ {
2027+ // This test differs from the other "step"-related test in that the DOM element has no "step" attribute
2028+ // and hence defaults to step=60, and for this the framework has explicit logic to strip off the "seconds"
2029+ // part of the bound value (otherwise the browser reports it as invalid - issue #41731)
2030+
2031+ var target = Browser . Exists ( By . Id ( "datetime-local-default-step-textbox-datetime" ) ) ;
2032+ var boundValue = Browser . Exists ( By . Id ( "datetime-local-default-step-textbox-datetime-value" ) ) ;
2033+ var expected = DateTime . Now . Date . Add ( new TimeSpan ( 8 , 5 , 0 ) ) ; // Notice the "seconds" part is zero here, even though the original data has seconds=30
2034+ Assert . Equal ( expected , DateTime . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2035+
2036+ // Clear textbox; value updates to 00:00 because that's the default
2037+ target . Clear ( ) ;
2038+ expected = default ;
2039+ Browser . Equal ( default , ( ) => DateTime . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2040+ Assert . Equal ( default , DateTime . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2041+
2042+ // We have to do it this way because the browser gets in the way when sending keys to the input element directly.
2043+ ApplyInputValue ( "#datetime-local-default-step-textbox-datetime" , "2000-01-02T04:05" ) ;
2044+ expected = new DateTime ( 2000 , 1 , 2 , 04 , 05 , 0 ) ;
2045+ Browser . Equal ( expected , ( ) => DateTime . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2046+ }
2047+
2048+ [ Fact ]
2049+ public void CanBindTimeDefaultStepTextboxDateTime ( )
2050+ {
2051+ // This test differs from the other "step"-related test in that the DOM element has no "step" attribute
2052+ // and hence defaults to step=60, and for this the framework has explicit logic to strip off the "seconds"
2053+ // part of the bound value (otherwise the browser reports it as invalid - issue #41731)
2054+
2055+ var target = Browser . Exists ( By . Id ( "time-default-step-textbox-datetime" ) ) ;
2056+ var boundValue = Browser . Exists ( By . Id ( "time-default-step-textbox-datetime-value" ) ) ;
2057+ var expected = DateTime . Now . Date . Add ( new TimeSpan ( 8 , 5 , 0 ) ) ; // Notice the "seconds" part is zero here, even though the original data has seconds=30
2058+ Assert . Equal ( expected , DateTime . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2059+
2060+ // Clear textbox; value updates to 00:00 because that's the default
2061+ target . Clear ( ) ;
2062+ expected = default ;
2063+ Browser . Equal ( DateTime . Now . Date , ( ) => DateTime . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2064+ Assert . Equal ( default , DateTime . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2065+
2066+ // We have to do it this way because the browser gets in the way when sending keys to the input element directly.
2067+ ApplyInputValue ( "#time-default-step-textbox-datetime" , "04:05" ) ;
2068+ expected = DateTime . Now . Date . Add ( new TimeSpan ( 4 , 5 , 0 ) ) ;
2069+ Browser . Equal ( expected , ( ) => DateTime . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2070+ }
2071+
2072+ [ Fact ]
2073+ public void CanBindTimeDefaultStepTextboxTimeOnly ( )
2074+ {
2075+ // This test differs from the other "step"-related test in that the DOM element has no "step" attribute
2076+ // and hence defaults to step=60, and for this the framework has explicit logic to strip off the "seconds"
2077+ // part of the bound value (otherwise the browser reports it as invalid - issue #41731)
2078+
2079+ var target = Browser . Exists ( By . Id ( "time-default-step-textbox-timeonly" ) ) ;
2080+ var boundValue = Browser . Exists ( By . Id ( "time-default-step-textbox-timeonly-value" ) ) ;
2081+ var expected = new TimeOnly ( 8 , 5 , 0 ) ; // Notice the "seconds" part is zero here, even though the original data has seconds=30
2082+ Assert . Equal ( expected , TimeOnly . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2083+
2084+ // Clear textbox; value updates to 00:00 because that's the default
2085+ target . Clear ( ) ;
2086+ expected = default ;
2087+ Browser . Equal ( default , ( ) => TimeOnly . Parse ( target . GetAttribute ( "value" ) , CultureInfo . InvariantCulture ) ) ;
2088+ Assert . Equal ( default , TimeOnly . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2089+
2090+ // We have to do it this way because the browser gets in the way when sending keys to the input element directly.
2091+ ApplyInputValue ( "#time-default-step-textbox-timeonly" , "04:05" ) ;
2092+ expected = new TimeOnly ( 4 , 5 , 0 ) ;
2093+ Browser . Equal ( expected , ( ) => TimeOnly . Parse ( boundValue . Text , CultureInfo . InvariantCulture ) ) ;
2094+ }
2095+
20242096 // Applies an input through javascript to datetime-local/month/time controls.
20252097 private void ApplyInputValue ( string cssSelector , string value )
20262098 {
0 commit comments