Skip to content

Commit 92eb690

Browse files
committed
Replace wait_for calls for wait_for_text_to_equal
1 parent a45fc3d commit 92eb690

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

tests/test_integration.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import dash
1212
import time
1313

14-
from dash.dependencies import Input, Output
14+
from dash.dependencies import Input, Output, State
1515
from dash.exceptions import PreventUpdate
1616
from .IntegrationTests import IntegrationTests
1717
from .utils import assert_clean_console, invincible, wait_for
@@ -61,8 +61,7 @@ def update_output(value):
6161

6262
input1.send_keys('hello world')
6363

64-
output1 = lambda: self.wait_for_element_by_id('output-1')
65-
wait_for(lambda: output1().text == 'hello world')
64+
output1 = self.wait_for_text_to_equal('#output-1', 'hello world')
6665
self.percy_snapshot(name='simple-callback-2')
6766

6867
self.assertEqual(
@@ -106,17 +105,15 @@ def update_text(data):
106105
return data
107106

108107
self.startServer(app)
109-
output1 = self.wait_for_element_by_id('output-1')
110-
wait_for(lambda: output1.text == 'initial value')
108+
output1 = self.wait_for_text_to_equal('#output-1', 'initial value')
111109
self.percy_snapshot(name='wildcard-callback-1')
112110

113111
input1 = self.wait_for_element_by_id('input')
114112
input1.clear()
115113

116114
input1.send_keys('hello world')
117115

118-
output1 = lambda: self.wait_for_element_by_id('output-1')
119-
wait_for(lambda: output1().text == 'hello world')
116+
output1 = self.wait_for_text_to_equal('#output-1', 'hello world')
120117
self.percy_snapshot(name='wildcard-callback-2')
121118

122119
self.assertEqual(
@@ -534,3 +531,42 @@ def create_layout():
534531

535532
self.startServer(app)
536533
time.sleep(0.5)
534+
535+
def test_multi_output(self):
536+
app = dash.Dash(__name__)
537+
app.scripts.config.serve_locally = True
538+
539+
app.layout = html.Div([
540+
html.Button('OUTPUT', id='output-btn'),
541+
542+
html.Table([
543+
html.Thead([
544+
html.Tr([
545+
html.Th('Output 1'),
546+
html.Th('Output 2')
547+
])
548+
]),
549+
html.Tbody([
550+
html.Tr([html.Td(id='output1'), html.Td(id='output2')]),
551+
])
552+
]),
553+
])
554+
555+
@app.callback([Output('output1', 'children'), Output('output2', 'children')],
556+
[Input('output-btn', 'n_clicks')],
557+
[State('output-btn', 'n_clicks_timestamp')])
558+
def on_click(n_clicks, n_clicks_timestamp):
559+
if n_clicks is None:
560+
raise PreventUpdate
561+
562+
return n_clicks, n_clicks_timestamp
563+
564+
565+
t = time.time()
566+
567+
btn = self.wait_for_element_by_id('output-btn')
568+
btn.click()
569+
time.sleep(1)
570+
571+
self.wait_for_text_to_equals()
572+

0 commit comments

Comments
 (0)