From 37e6e051b362dfef03bf52560fb01d2c3e9d60c1 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 13:43:41 +1300 Subject: [PATCH] journeys: no motion from the first paint, and the "Added 2 projects" shot waits for the finished, settled state --- scripts/screenshots/journeys.mjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/screenshots/journeys.mjs b/scripts/screenshots/journeys.mjs index 1b7b6471..dc50ea32 100644 --- a/scripts/screenshots/journeys.mjs +++ b/scripts/screenshots/journeys.mjs @@ -27,7 +27,13 @@ const failures = [] /** One journey in a fresh browser (no cookies), its steps' screenshots named `/-`. */ async function journey(name, steps) { if ((only ?? 'all') !== (name === 'waitlist-keeps-new-people-out' ? 'waitlist' : 'all')) return - const context = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1280, height: 800 } }) + const context = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1280, height: 800 }, reducedMotion: 'reduce' }) + // No motion from the first paint, not only from the shot: a transition started before the shot can be caught midway + await context.addInitScript((css) => { + const add = () => document.head.appendChild(Object.assign(document.createElement('style'), { textContent: css })) + if (document.head) add() + else document.addEventListener('DOMContentLoaded', add) + }, NO_MOTION) // Nothing reaches production: the site's figures come from VisualCI's own gallery on app.visualci.com, which // changes when its screenshots are approved (and loaded in some runs, not others). Refused, each shows its // description, the same every run. @@ -38,6 +44,8 @@ async function journey(name, steps) { await page.waitForLoadState('networkidle').catch(() => {}) await page.addStyleTag({ content: NO_MOTION }).catch(() => {}) await page.evaluate(() => document.fonts.ready).catch(() => {}) + // Two frames, so a re-render the last request caused (a refetch after a finished import) has painted + await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)))).catch(() => {}) n++ await mkdir(`${out}/${name}`, { recursive: true }) await page.screenshot({ path: `${out}/${name}/${String(n).padStart(2, '0')}-${step}.png`, fullPage: true }) @@ -374,6 +382,12 @@ await journey('setup-picks-from-300-repositories', async ({ page, shot }) => { await shot('picked') await page.getByRole('button', { name: 'Add 2 repositories' }).click() await page.getByRole('heading', { name: 'Added 2 projects' }).waitFor({ timeout: 30000 }) + // The finished state, settled: the bar full, the next step offered, and the refetches that follow it done + await page.getByRole('button', { name: 'Next: add VisualCI to CI' }).waitFor() + await page.waitForFunction(() => { + const bar = document.querySelector('.picker-progress progress') + return bar instanceof HTMLProgressElement && bar.value === bar.max + }) await shot('added') const after = await api(page, `/api/ui/orgs/${org}`) expect(after.projects.length === 2, `picking two made ${after.projects.length} projects`)