22
33from  shiny .playwright  import  controller 
44from  shiny .run  import  ShinyAppProc 
5+ import  datetime 
56
67
78def  test_dynamic_navs (page : Page , local_app : ShinyAppProc ) ->  None :
@@ -10,3 +11,40 @@ def test_dynamic_navs(page: Page, local_app: ShinyAppProc) -> None:
1011    # Check the initial state of the date picker where value = max 
1112    date1  =  controller .InputDate (page , "start_date_picker" )
1213    date1 .expect_value ("14.11.2011" )
14+ 
15+     # Can't find a way to inspect the actual display date in the datepicker, 
16+     # as even in the broken example, the correct attribute was still set. 
17+     # To work around this, we will check the displayed value to ensure the 
18+     # correct value is being passed to the server. 
19+     date_output  =  controller .OutputText (page , "start" )
20+     date_output .expect_value ("Date Picker Value: 2011-11-14" )
21+ 
22+     # Test the date picker with the min date = initial value (unchanged case) 
23+     date2  =  controller .InputDate (page , "min_date_picker" )
24+     date2 .expect_value ("04.11.2011" )
25+ 
26+     date_output2  =  controller .OutputText (page , "min" )
27+     date_output2 .expect_value ("Date Picker Value: 2011-11-04" )
28+ 
29+     # Test the date picker with the date set as a string instead of as a date object 
30+     date3  =  controller .InputDate (page , "str_date_picker" )
31+     date3 .expect_value ("01-10-2023" )
32+ 
33+     date_output3  =  controller .OutputText (page , "str_format" )
34+     date_output3 .expect_value ("Date Picker Value: 2023-10-01" )
35+ 
36+     # Test the date picker with a None value inputted 
37+     # None defaults to today's date 
38+     input  =  datetime .date .today ().strftime ("%Y-%m-%d" )
39+     date4  =  controller .InputDate (page , "none_date_picker" )
40+     date4 .expect_value (input )
41+ 
42+     date_output4  =  controller .OutputText (page , "none_format" )
43+     date_output4 .expect_value ("Date Picker Value: "  +  input )
44+ 
45+     # Test the default value when an empty string is passed is correctly blank 
46+     date5  =  controller .InputDate (page , "empty_date_picker" )
47+     date5 .expect_value ("" )
48+ 
49+     date_output5  =  controller .OutputText (page , "empty_format" )
50+     date_output5 .expect_value ("Date Picker Value: None" )
0 commit comments