Skip to content

Commit ebe2241

Browse files
committed
close #1071 - add test for chained callbacks with table coming in late
1 parent d39e3ad commit ebe2241

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Diff for: tests/integration/callbacks/test_multiple_callbacks.py

+52
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import dash_html_components as html
55
import dash_core_components as dcc
6+
import dash_table
67
import dash
78
from dash.dependencies import Input, Output
89
from dash.exceptions import PreventUpdate
@@ -72,3 +73,54 @@ def set_c(a):
7273
dash_duo.find_element("#a").send_keys(str(i))
7374
chars += str(i)
7475
dash_duo.wait_for_text_to_equal("#out", "{0}/b/{0}".format(chars))
76+
77+
78+
def test_cbmt003_chain_with_table(dash_duo):
79+
# see https://github.com/plotly/dash/issues/1071
80+
app = dash.Dash(__name__)
81+
app.layout = html.Div([
82+
html.Div(id="a1"),
83+
html.Div(id="a2"),
84+
html.Div(id="b1"),
85+
html.H1(id="b2"),
86+
html.Button("Update", id="button"),
87+
dash_table.DataTable(id="table"),
88+
])
89+
90+
@app.callback(
91+
# Changing the order of outputs here fixes the issue
92+
[Output("a2", "children"), Output("a1", "children")],
93+
[Input("button", "n_clicks")],
94+
)
95+
def a12(n):
96+
return "a2: {!s}".format(n), "a1: {!s}".format(n)
97+
98+
@app.callback(Output("b1", "children"), [Input("a1", "children")])
99+
def b1(a1):
100+
return "b1: {!r}".format(a1)
101+
102+
@app.callback(
103+
Output("b2", "children"),
104+
[Input("a2", "children"), Input("table", "selected_cells")],
105+
)
106+
def b2(a2, selected_cells):
107+
return "b2: {!r}, {!r}".format(a2, selected_cells)
108+
109+
dash_duo.start_server(app)
110+
111+
dash_duo.wait_for_text_to_equal("#a1", "a1: None")
112+
dash_duo.wait_for_text_to_equal("#a2", "a2: None")
113+
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: None'")
114+
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: None', None")
115+
116+
dash_duo.find_element("#button").click()
117+
dash_duo.wait_for_text_to_equal("#a1", "a1: 1")
118+
dash_duo.wait_for_text_to_equal("#a2", "a2: 1")
119+
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 1'")
120+
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 1', None")
121+
122+
dash_duo.find_element("#button").click()
123+
dash_duo.wait_for_text_to_equal("#a1", "a1: 2")
124+
dash_duo.wait_for_text_to_equal("#a2", "a2: 2")
125+
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 2'")
126+
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 2', None")

0 commit comments

Comments
 (0)