Skip to content

Commit

Permalink
closes #1053 - add test for complex callback graph with preventDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Mar 6, 2020
1 parent 7e57ed1 commit d39e3ad
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/integration/callbacks/test_multiple_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from multiprocessing import Value

import dash_html_components as html
import dash_core_components as dcc
import dash
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate


def test_cbmt001_called_multiple_times_and_out_of_order(dash_duo):
Expand Down Expand Up @@ -36,3 +38,37 @@ def update_output(n_clicks):
dash_duo.percy_snapshot(
name="test_callbacks_called_multiple_times_and_out_of_order"
)


def test_cbmt002_canceled_intermediate_callback(dash_duo):
# see https://github.com/plotly/dash/issues/1053
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.Input(id='a', value="x"),
html.Div('b', id='b'),
html.Div('c', id='c'),
html.Div(id='out')
])

@app.callback(
Output("out", "children"),
[Input("a", "value"), Input("b", "children"), Input("c", "children")]
)
def set_out(a, b, c):
return "{}/{}/{}".format(a, b, c)

@app.callback(Output("b", "children"), [Input("a", "value")])
def set_b(a):
raise PreventUpdate

@app.callback(Output("c", "children"), [Input("a", "value")])
def set_c(a):
return a

dash_duo.start_server(app)
dash_duo.wait_for_text_to_equal("#out", "x/b/x")
chars = "x"
for i in list(range(10)) * 2:
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))

0 comments on commit d39e3ad

Please sign in to comment.