Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit a83ff48

Browse files
committed
integration test
1 parent 3547924 commit a83ff48

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/test_integration.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,54 @@ def update_output(n_clicks):
8484
'#container', 'You have clicked the button 1 times')
8585
self.assertEqual(call_count.value, 2)
8686
self.snapshot('button click')
87+
88+
89+
def test_click_prev(self):
90+
call_count = Value('i', 0)
91+
92+
app = dash.Dash()
93+
app.layout = html.Div([
94+
html.Div(id='container'),
95+
html.Button('Click', id='button-1', n_clicks=0, n_clicks_previous=0),
96+
html.Button('Click', id='button-2', n_clicks=0, n_clicks_previous=0)
97+
])
98+
99+
@app.callback(
100+
Output('container', 'children'),
101+
[Input('button-1', 'n_clicks'),
102+
Input('button-1', 'n_clicks_previous'),
103+
Input('button-2', 'n_clicks'),
104+
Input('button-2', 'n_clicks_previous')])
105+
def update_output(*args):
106+
call_count.value += 1
107+
return '{}, {}, {}, {}'.format(*args)
108+
109+
self.startServer(app)
110+
111+
self.wait_for_element_by_css_selector('#container')
112+
time.sleep(2)
113+
self.wait_for_text_to_equal(
114+
'#container', '0, 0, 0, 0')
115+
self.assertEqual(call_count.value, 1)
116+
self.snapshot('button initialization 1')
117+
118+
self.driver.find_element_by_css_selector('#button-1').click()
119+
time.sleep(2)
120+
self.wait_for_text_to_equal(
121+
'#container', '0, 1, 0, 0')
122+
self.assertEqual(call_count.value, 2)
123+
self.snapshot('button-1 click')
124+
125+
self.driver.find_element_by_css_selector('#button-2').click()
126+
time.sleep(2)
127+
self.wait_for_text_to_equal(
128+
'#container', '1, 1, 0, 1')
129+
self.assertEqual(call_count.value, 3)
130+
self.snapshot('button-2 click')
131+
132+
self.driver.find_element_by_css_selector('#button-2').click()
133+
time.sleep(2)
134+
self.wait_for_text_to_equal(
135+
'#container', '1, 1, 1, 2')
136+
self.assertEqual(call_count.value, 4)
137+
self.snapshot('button-2 click again')

0 commit comments

Comments
 (0)