Skip to content

Commit

Permalink
close #1071 - add test for chained callbacks with table coming in late
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Mar 6, 2020
1 parent d39e3ad commit ebe2241
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/integration/callbacks/test_multiple_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import dash_html_components as html
import dash_core_components as dcc
import dash_table
import dash
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate
Expand Down Expand Up @@ -72,3 +73,54 @@ def set_c(a):
dash_duo.find_element("#a").send_keys(str(i))
chars += str(i)
dash_duo.wait_for_text_to_equal("#out", "{0}/b/{0}".format(chars))


def test_cbmt003_chain_with_table(dash_duo):
# see https://github.com/plotly/dash/issues/1071
app = dash.Dash(__name__)
app.layout = html.Div([
html.Div(id="a1"),
html.Div(id="a2"),
html.Div(id="b1"),
html.H1(id="b2"),
html.Button("Update", id="button"),
dash_table.DataTable(id="table"),
])

@app.callback(
# Changing the order of outputs here fixes the issue
[Output("a2", "children"), Output("a1", "children")],
[Input("button", "n_clicks")],
)
def a12(n):
return "a2: {!s}".format(n), "a1: {!s}".format(n)

@app.callback(Output("b1", "children"), [Input("a1", "children")])
def b1(a1):
return "b1: {!r}".format(a1)

@app.callback(
Output("b2", "children"),
[Input("a2", "children"), Input("table", "selected_cells")],
)
def b2(a2, selected_cells):
return "b2: {!r}, {!r}".format(a2, selected_cells)

dash_duo.start_server(app)

dash_duo.wait_for_text_to_equal("#a1", "a1: None")
dash_duo.wait_for_text_to_equal("#a2", "a2: None")
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: None'")
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: None', None")

dash_duo.find_element("#button").click()
dash_duo.wait_for_text_to_equal("#a1", "a1: 1")
dash_duo.wait_for_text_to_equal("#a2", "a2: 1")
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 1'")
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 1', None")

dash_duo.find_element("#button").click()
dash_duo.wait_for_text_to_equal("#a1", "a1: 2")
dash_duo.wait_for_text_to_equal("#a2", "a2: 2")
dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 2'")
dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 2', None")

0 comments on commit ebe2241

Please sign in to comment.