|
11 | 11 | import dash
|
12 | 12 | import time
|
13 | 13 |
|
14 |
| -from dash.dependencies import Input, Output |
| 14 | +from dash.dependencies import Input, Output, State |
15 | 15 | from dash.exceptions import PreventUpdate
|
16 | 16 | from .IntegrationTests import IntegrationTests
|
17 | 17 | from .utils import assert_clean_console, invincible, wait_for
|
@@ -61,8 +61,7 @@ def update_output(value):
|
61 | 61 |
|
62 | 62 | input1.send_keys('hello world')
|
63 | 63 |
|
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') |
66 | 65 | self.percy_snapshot(name='simple-callback-2')
|
67 | 66 |
|
68 | 67 | self.assertEqual(
|
@@ -106,17 +105,15 @@ def update_text(data):
|
106 | 105 | return data
|
107 | 106 |
|
108 | 107 | 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') |
111 | 109 | self.percy_snapshot(name='wildcard-callback-1')
|
112 | 110 |
|
113 | 111 | input1 = self.wait_for_element_by_id('input')
|
114 | 112 | input1.clear()
|
115 | 113 |
|
116 | 114 | input1.send_keys('hello world')
|
117 | 115 |
|
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') |
120 | 117 | self.percy_snapshot(name='wildcard-callback-2')
|
121 | 118 |
|
122 | 119 | self.assertEqual(
|
@@ -534,3 +531,42 @@ def create_layout():
|
534 | 531 |
|
535 | 532 | self.startServer(app)
|
536 | 533 | 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