From 13b21c92f762cd20c4fad01e247a71c39ff3bf99 Mon Sep 17 00:00:00 2001 From: tunjayoff Date: Fri, 20 Nov 2026 21:14:28 +0300 Subject: [PATCH] test(explorer): wait for every API answer before ending the image-flood step goto's settle is a quiet window (no API slot or response for 2 s), not 'all page requests answered'. Under the image flood the interceptor can stay quiet that long, so goto may return before all 12 API answers reach the page (v3.2.0 release run: title '0'). Wait for document.title to reach N_API while the step is still active, then end it; every other assertion is unchanged. --- tests/test_research_explorer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_research_explorer.py b/tests/test_research_explorer.py index 4abbd850..3bd27d4c 100644 --- a/tests/test_research_explorer.py +++ b/tests/test_research_explorer.py @@ -970,9 +970,14 @@ def recorded_slot(): t0 = time.monotonic() res = await ex.goto({"url": "http://www.fakescore.test/page", "sport": "football", "page_type": "event", "settle": 2, "dwell": 90}) - ex.active = False assert res["error"] is None, res - assert await page.title() == str(N_API) + # `settle` is a quiet window (no API slot/response for 2 s), not "all page requests answered": under + # the flood the interceptor can stay quiet that long (e.g. before the first slot) and goto returns + # early. Wait for what the test means, every API answer reached the page, while the step is still + # active; only then end it (an inactive step would drop the requests still queued). + await page.wait_for_function(f"document.title === '{N_API}'", + timeout=(N_API * gap + 60) * 1000) + ex.active = False elapsed = time.monotonic() - t0 for _ in range(120): # selin sonu (görseller kesiciden geçmeye devam ediyor olabilir) if ex.blocked >= FLOOD: