From cd6fad6c6086ff270f20d6e8eba8417b5b581909 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Sat, 24 Oct 2026 17:14:19 -0700 Subject: [PATCH] test(tagging): wait for in-flight pages before reading the loaded range The scroll-position test read the loaded count right after scrolling the continuation out of view, while a listing page the continuation had already requested could still be in flight. When it landed the count grew (80 -> 120 in CI) and the stability poll failed. The test now waits a frame for any scheduled load to start and then for every listing request to finish before it reads the count. --- tests/browser/workspace-tagging.spec.mjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/browser/workspace-tagging.spec.mjs b/tests/browser/workspace-tagging.spec.mjs index 15de079..525e2ef 100644 --- a/tests/browser/workspace-tagging.spec.mjs +++ b/tests/browser/workspace-tagging.spec.mjs @@ -602,6 +602,10 @@ test('a save under a Tags filter re-reads the listing: the selection stays while test('a save under a search keeps the scroll position and the loaded range', async ({ page, request }) => { await expect(await request.post('/__test__/tagging/reset', { data: { extra_images: 140 } })).toBeOK(); + // Listing pages still in flight: one that lands after the scroll below would grow the loaded range. + const inFlight = new Set(); + page.on('request', item => { if (item.url().includes('/images/output?')) inFlight.add(item); }); + for (const done of ['requestfinished', 'requestfailed']) page.on(done, item => inFlight.delete(item)); await page.goto(images); const searched = listingOf(page, query => query.get('q') === 'bulk'); await page.getByRole('searchbox', { name: 'Search workspace', exact: true }).fill('bulk'); @@ -615,6 +619,9 @@ test('a save under a search keeps the scroll position and the loaded range', asy await expect.poll(async () => { await continuation.scrollIntoViewIfNeeded(); return loadedCount(); }).toBeGreaterThanOrEqual(80); await page.evaluate(() => window.scrollTo(0, Math.round(document.documentElement.scrollHeight / 3))); await expect(continuation).not.toBeInViewport(); + // A load the continuation scheduled for the next frame has started by now; wait for every page to land. + await page.evaluate(() => new Promise(done => requestAnimationFrame(() => requestAnimationFrame(done)))); + await expect.poll(() => inFlight.size).toBe(0); const loaded = await continuation.textContent(); await expect.poll(() => continuation.textContent()).toBe(loaded); const y = await page.evaluate(() => window.scrollY);