@@ -19,6 +19,8 @@ def test_click_simple(dash_duo):
19
19
@app .callback (
20
20
Output ("container" , "children" ),
21
21
Input ("button" , "n_clicks" ),
22
+ # The new percy runner loads the page, so to get consistent behavior for
23
+ # call_count we need to skip the initial call
22
24
prevent_initial_call = True ,
23
25
)
24
26
def update_output (n_clicks ):
@@ -52,7 +54,7 @@ def test_click_prev(dash_duo):
52
54
app = Dash (__name__ )
53
55
app .layout = html .Div (
54
56
[
55
- html .Div (id = "container" ),
57
+ html .Div ("Initial" , id = "container" ),
56
58
html .Button ("Click" , id = "button-1" , n_clicks = 0 , n_clicks_timestamp = - 1 ),
57
59
html .Button ("Click" , id = "button-2" , n_clicks = 0 , n_clicks_timestamp = - 1 ),
58
60
]
@@ -66,7 +68,7 @@ def test_click_prev(dash_duo):
66
68
Input ("button-2" , "n_clicks" ),
67
69
Input ("button-2" , "n_clicks_timestamp" ),
68
70
],
69
- prevent_inital_call = True ,
71
+ prevent_initial_call = True ,
70
72
)
71
73
def update_output (* args ):
72
74
print (args )
@@ -77,25 +79,25 @@ def update_output(*args):
77
79
78
80
dash_duo .start_server (app )
79
81
80
- dash_duo .wait_for_text_to_equal ("#container" , "0, 0 " )
81
- assert timestamp_1 .value == - 1
82
- assert timestamp_2 .value == - 1
83
- assert call_count .value == 1
82
+ dash_duo .wait_for_text_to_equal ("#container" , "Initial " )
83
+ assert timestamp_1 .value == - 5
84
+ assert timestamp_2 .value == - 5
85
+ assert call_count .value == 0
84
86
dash_duo .percy_snapshot ("html button initialization 1" )
85
87
86
88
dash_duo .find_element ("#button-1" ).click ()
87
89
dash_duo .wait_for_text_to_equal ("#container" , "1, 0" )
88
90
assert timestamp_1 .value > ((time .time () - (24 * 60 * 60 )) * 1000 )
89
91
assert timestamp_2 .value == - 1
90
- assert call_count .value == 2
92
+ assert call_count .value == 1
91
93
dash_duo .percy_snapshot ("html button-1 click" )
92
94
prev_timestamp_1 = timestamp_1 .value
93
95
94
96
dash_duo .find_element ("#button-2" ).click ()
95
97
dash_duo .wait_for_text_to_equal ("#container" , "1, 1" )
96
98
assert timestamp_1 .value == prev_timestamp_1
97
99
assert timestamp_2 .value > ((time .time () - 24 * 60 * 60 ) * 1000 )
98
- assert call_count .value == 3
100
+ assert call_count .value == 2
99
101
dash_duo .percy_snapshot ("html button-2 click" )
100
102
prev_timestamp_2 = timestamp_2 .value
101
103
@@ -104,7 +106,7 @@ def update_output(*args):
104
106
assert timestamp_1 .value == prev_timestamp_1
105
107
assert timestamp_2 .value > prev_timestamp_2
106
108
assert timestamp_2 .value > timestamp_1 .value
107
- assert call_count .value == 4
109
+ assert call_count .value == 3
108
110
dash_duo .percy_snapshot ("html button-2 click again" )
109
111
110
112
assert not dash_duo .get_logs ()
0 commit comments