Skip to content

Commit bd84d08

Browse files
committed
Add test running match
1 parent 5c5f867 commit bd84d08

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/integration/callbacks/test_wildcards.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
from selenium.webdriver.common.keys import Keys
44
import json
5+
import time
56

67
from dash.testing import wait
78
import dash
@@ -552,3 +553,65 @@ def update_selected_values(values):
552553
dash_duo.wait_for_text_to_equal(
553554
"#selected-values", "['option0-2', 'option1-2', 'option2-2']"
554555
)
556+
557+
558+
def test_cbwc008_running_match(dash_duo):
559+
app = dash.Dash()
560+
561+
app.layout = [
562+
html.Div(
563+
[
564+
html.Button(
565+
"Test1",
566+
id={"component": "button", "index": "1"},
567+
),
568+
html.Button(
569+
"Test2",
570+
id={"component": "button", "index": "2"},
571+
),
572+
],
573+
id="buttons",
574+
),
575+
html.Div(html.Div(id={"component": "output", "index": "1"}), id="output1"),
576+
html.Div(html.Div(id={"component": "output", "index": "2"}), id="output2"),
577+
]
578+
579+
@app.callback(
580+
Output({"component": "output", "index": MATCH}, "children"),
581+
Input({"component": "button", "index": MATCH}, "n_clicks"),
582+
running=[
583+
(
584+
Output({"component": "button", "index": MATCH}, "children"),
585+
"running",
586+
"finished",
587+
),
588+
(Output({"component": "button", "index": ALL}, "disabled"), True, False),
589+
],
590+
prevent_initial_call=True,
591+
)
592+
def on_click(_) -> str:
593+
time.sleep(1)
594+
return "done"
595+
596+
dash_duo.start_server(app)
597+
598+
for i in range(1, 3):
599+
dash_duo.find_element(f"#buttons button:nth-child({i})").click()
600+
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "running")
601+
# verify all the buttons were disabled.
602+
assert dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
603+
"disabled"
604+
)
605+
assert dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
606+
"disabled"
607+
)
608+
609+
dash_duo.wait_for_text_to_equal(f"#output{i}", "done")
610+
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "finished")
611+
612+
assert not dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
613+
"disabled"
614+
)
615+
assert not dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
616+
"disabled"
617+
)

0 commit comments

Comments
 (0)