Skip to content

Commit 98ac776

Browse files
committed
Add click delay (attempt to fix flakey tests)
1 parent 70a7ea0 commit 98ac776

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_core.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import os
12
from typing import Any
23

34
from reactpy import Ref, component, html, use_location
45
from reactpy.testing import DisplayFixture
56

67
from reactpy_router import browser_router, link, route, use_params, use_search_params
78

9+
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "").lower() == "true"
10+
CLICK_DELAY = 250 if GITHUB_ACTIONS else 25 # Delay in miliseconds.
11+
812

913
async def test_simple_router(display: DisplayFixture):
1014
def make_location_check(path, *routes):
@@ -92,7 +96,7 @@ def sample():
9296

9397
for link_selector in ["#root", "#a", "#b", "#c"]:
9498
lnk = await display.page.wait_for_selector(link_selector)
95-
await lnk.click()
99+
await lnk.click(delay=CLICK_DELAY)
96100

97101
await display.page.wait_for_selector("#default")
98102

@@ -171,7 +175,7 @@ def sample():
171175

172176
for link_selector in ["#root", "#a", "#b", "#c"]:
173177
lnk = await display.page.wait_for_selector(link_selector)
174-
await lnk.click()
178+
await lnk.click(delay=CLICK_DELAY)
175179

176180
await display.page.wait_for_selector("#default")
177181

@@ -206,7 +210,7 @@ def sample():
206210

207211
for link_selector in ["#root", "#a", "#b", "#c", "#d", "#e", "#f"]:
208212
lnk = await display.page.wait_for_selector(link_selector)
209-
await lnk.click()
213+
await lnk.click(delay=CLICK_DELAY)
210214

211215
await display.page.wait_for_selector("#default")
212216

@@ -249,7 +253,7 @@ def sample():
249253
await display.show(sample)
250254
await display.page.wait_for_selector("#root")
251255
lnk = await display.page.wait_for_selector("#root")
252-
await lnk.click()
256+
await lnk.click(delay=CLICK_DELAY)
253257
await display.page.wait_for_selector("#success")
254258

255259

0 commit comments

Comments
 (0)