Skip to content

Commit 4e40f20

Browse files
committed
modernize basic callback test
1 parent 5dfa6b0 commit 4e40f20

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

tests/integration/callbacks/test_basic_callback.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
callback_context,
2424
)
2525
from dash.exceptions import PreventUpdate
26-
from dash.testing import wait
2726
from tests.integration.utils import json_engine
2827

2928

@@ -47,7 +46,7 @@ def update_output(value):
4746

4847
dash_duo.start_server(app)
4948

50-
assert dash_duo.find_element("#output-1").text == "initial value"
49+
dash_duo.wait_for_text_to_equal("#output-1", "initial value")
5150
dash_duo.percy_snapshot(name="simple-callback-initial")
5251

5352
input_ = dash_duo.find_element("#input")
@@ -57,7 +56,7 @@ def update_output(value):
5756
with lock:
5857
input_.send_keys(key)
5958

60-
wait.until(lambda: dash_duo.find_element("#output-1").text == "hello world", 2)
59+
dash_duo.wait_for_text_to_equal("#output-1", "hello world")
6160
dash_duo.percy_snapshot(name="simple-callback-hello-world")
6261

6362
assert call_count.value == 2 + len("hello world"), "initial count + each key stroke"
@@ -144,11 +143,6 @@ def update_input(value):
144143
# editing the input should modify the sub output
145144
dash_duo.find_element("#sub-input-1").send_keys("deadbeef")
146145

147-
assert (
148-
dash_duo.find_element("#sub-output-1").text
149-
== pad_input.attrs["value"] + "deadbeef"
150-
), "deadbeef is added"
151-
152146
# the total updates is initial one + the text input changes
153147
dash_duo.wait_for_text_to_equal(
154148
"#sub-output-1", pad_input.attrs["value"] + "deadbeef"
@@ -452,25 +446,16 @@ def content(n, d, v):
452446

453447
dash_duo.start_server(app)
454448

455-
wait.until(lambda: dash_duo.find_element("#output").text == '[null, null, "A"]', 3)
449+
dash_duo.wait_for_text_to_equal("#output", '[null, null, "A"]')
456450
dash_duo.wait_for_element("#d").click()
457451

458-
wait.until(
459-
lambda: dash_duo.find_element("#output").text == '[null, 1, "A"]',
460-
3,
461-
)
452+
dash_duo.wait_for_text_to_equal("#output", '[null, 1, "A"]')
462453

463454
dash_duo.wait_for_element("#n").click()
464-
wait.until(
465-
lambda: dash_duo.find_element("#output").text == '[1, 1, "A"]',
466-
3,
467-
)
455+
dash_duo.wait_for_text_to_equal("#output", '[1, 1, "A"]')
468456

469457
dash_duo.wait_for_element("#d").click()
470-
wait.until(
471-
lambda: dash_duo.find_element("#output").text == '[1, 2, "A"]',
472-
3,
473-
)
458+
dash_duo.wait_for_text_to_equal("#output", '[1, 2, "A"]')
474459

475460

476461
def test_cbsc010_event_properties(dash_duo):
@@ -712,7 +697,7 @@ def follower_output(v):
712697
with lock:
713698
input_.send_keys(key)
714699

715-
wait.until(lambda: dash_duo.find_element("#input-text").text == "3", 2)
700+
dash_duo.wait_for_text_to_equal("#input-text", "3")
716701

717702
assert call_count.value == 2, "initial + changed once"
718703

@@ -746,13 +731,13 @@ def update_output(value, data):
746731

747732
dash_duo.start_server(app)
748733

749-
assert dash_duo.find_element("#output-1").text == "initial value"
734+
dash_duo.wait_for_text_to_equal("#output-1", "initial value")
750735

751736
input_ = dash_duo.find_element("#input")
752737
dash_duo.clear_input(input_)
753738
input_.send_keys("A")
754739

755-
wait.until(lambda: dash_duo.find_element("#output-1").text == "A", 2)
740+
dash_duo.wait_for_text_to_equal("#output-1", "A")
756741

757742
assert store_data.value == 123
758743
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)