Skip to content

Commit 3dbf7fb

Browse files
committed
Fix rdcap003 race: poll for option re-render after click
test_rdcap003_side_effect_regression clicked #a and then counted the checklist options synchronously, racing the opts callback that re-renders them - so it read the previous count (assert 2 == 3). @flaky did not help because a slow runner loses the race on every rerun. Poll for the expected option count instead.
1 parent 7090bd8 commit 3dbf7fb

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎tests/integration/renderer/test_component_as_prop.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from dash.dcc import Checklist, Dropdown
88
from dash.html import Button, Div, Span
99

10+
import dash.testing.wait as wait
1011
from flaky import flaky
1112

1213

@@ -393,13 +394,24 @@ def opts(n):
393394

394395
dash_duo.wait_for_text_to_equal("#counter", "0")
395396
dash_duo.find_element("#a").click()
396-
assert (
397-
len(dash_duo.find_elements('#b label:not([data-option-index="-1"]) input')) == 2
397+
# The options re-render is driven by the `opts` callback; poll for the new
398+
# count instead of reading it synchronously right after the click, which
399+
# races the callback and reads the previous count.
400+
wait.until(
401+
lambda: len(
402+
dash_duo.find_elements('#b label:not([data-option-index="-1"]) input')
403+
)
404+
== 2,
405+
timeout=4,
398406
)
399407
dash_duo.wait_for_text_to_equal("#counter", "0")
400408
dash_duo.find_element("#a").click()
401-
assert (
402-
len(dash_duo.find_elements('#b label:not([data-option-index="-1"]) input')) == 3
409+
wait.until(
410+
lambda: len(
411+
dash_duo.find_elements('#b label:not([data-option-index="-1"]) input')
412+
)
413+
== 3,
414+
timeout=4,
403415
)
404416
dash_duo.wait_for_text_to_equal("#counter", "0")
405417

0 commit comments

Comments
 (0)