From ba989cb2a5174922525d7b8f4d8de9a1d41afc2a Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 10:59:42 +0000 Subject: [PATCH] Journeys: delete-a-project's 'deleted' shot waits for the organization's table to list its projects without the deleted one and for the page's height to hold, so it never catches the relayout at the viewport's height --- scripts/screenshots/journeys.mjs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/screenshots/journeys.mjs b/scripts/screenshots/journeys.mjs index 774df37a..174e1ba9 100644 --- a/scripts/screenshots/journeys.mjs +++ b/scripts/screenshots/journeys.mjs @@ -70,6 +70,27 @@ async function journey(name, steps) { } } +/** Waits until the page's height has held for five frames in a row (a list re-rendering after a refetch). */ +async function steadyHeight(page) { + await page.waitForFunction( + () => + new Promise((resolve) => { + let last = -1 + let same = 0 + const tick = () => { + const h = document.documentElement.scrollHeight + same = h === last ? same + 1 : 0 + last = h + if (same >= 5) resolve(true) + else requestAnimationFrame(tick) + } + requestAnimationFrame(tick) + }), + null, + { timeout: 10000 }, + ) +} + function expect(condition, message) { if (!condition) throw new Error(message) } @@ -667,6 +688,13 @@ await journey('delete-a-project', async ({ page, shot }) => { await confirm.click() await page.waitForURL((url) => url.pathname === `/${org}`, { timeout: 15000 }) await page.getByRole('status').getByText(`Deleted ${victim.name}`).waitFor() + // The organization's page re-renders once its projects come back without the deleted one: wait for the table to list + // them and the page's height to hold, or the full-page shot catches it mid-relayout at the viewport's height (4 Dec + // 2026, build 619). + const table = page.locator('table.tbl') + await table.locator(`a[href="/${org}/${projects.find((p) => p.slug !== victim.slug).slug}"]`).first().waitFor() + await table.locator(`a[href="/${org}/${victim.slug}"]`).first().waitFor({ state: 'detached' }) + await steadyHeight(page) await shot('deleted') const after = (await api(page, `/api/ui/orgs/${org}`)).projects expect(!after.some((p) => p.slug === victim.slug), `the organization still lists ${victim.slug}`)