@@ -13,9 +13,26 @@ def test_cdpr001_date_clearable_true_works(dash_dcc):
1313 [
1414 dcc .DatePickerRange (id = "dpr" , clearable = True ),
1515 dcc .DatePickerSingle (id = "dps" , clearable = True ),
16+ html .Div (id = "dpr-output" ),
17+ html .Div (id = "dps-output" ),
1618 ]
1719 )
1820
21+ @app .callback (
22+ Output ("dpr-output" , "children" ),
23+ Input ("dpr" , "start_date" ),
24+ Input ("dpr" , "end_date" ),
25+ )
26+ def display_range_dates (start_date , end_date ):
27+ return f"Range: { start_date } - { end_date } "
28+
29+ @app .callback (
30+ Output ("dps-output" , "children" ),
31+ Input ("dps" , "date" ),
32+ )
33+ def display_single_date (date ):
34+ return f"Single: { date } "
35+
1936 dash_dcc .start_server (app )
2037
2138 # DPR
@@ -26,21 +43,34 @@ def test_cdpr001_date_clearable_true_works(dash_dcc):
2643 "1" in start_date and "28" in end_date
2744 ), "both start date and end date should match the selected day"
2845
46+ # Verify callback received the dates
47+ dash_dcc .wait_for_text_to_equal ("#dpr-output" , f"Range: { start_date } - { end_date } " )
48+
2949 close_btn .click ()
3050 sleep (0.25 )
3151 start_date , end_date = dash_dcc .get_date_range ("dpr" )
3252 assert not start_date and not end_date , "both start and end dates should be cleared"
3353
54+ # Verify callback received the cleared dates (None)
55+ dash_dcc .wait_for_text_to_equal ("#dpr-output" , "Range: None - None" )
56+
3457 # DPS
3558 selected = dash_dcc .select_date_single ("dps" , day = "1" )
3659
3760 assert selected , "single date should get a value"
61+
62+ # Verify callback received the date
63+ dash_dcc .wait_for_text_to_equal ("#dps-output" , f"Single: { selected } " )
64+
3865 close_btn = dash_dcc .wait_for_element ("#dps-wrapper .dash-datepicker-clear" )
3966 close_btn .click ()
4067 sleep (0.25 )
4168 (single_date ,) = dash_dcc .get_date_range ("dps" )
4269 assert not single_date , "date should be cleared"
4370
71+ # Verify callback received the cleared date (None)
72+ dash_dcc .wait_for_text_to_equal ("#dps-output" , "Single: None" )
73+
4474 assert dash_dcc .get_logs () == []
4575
4676
0 commit comments