From 0f3a48dd412286c3e20a3b84caf91cf5083635e0 Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:11:16 -0800 Subject: [PATCH 1/7] Browser tests wait for the page to be still, not a fixed time The browser layout tests draw a screen, add the app's stylesheet after it has drawn, and measure or photograph it. The late styles start the transitions they declare (a dialog sliding into place, a fade, rows easing in), and about forty files then waited a fixed 150 to 1000ms before measuring. Under a full CI run, eight files at once in Chromium and WebKit, that guess was sometimes short and the test read a screen mid-move. They now call one shared helper, still(page) in app/tests/page-still.ts, which waits until, for three frames in a row, no animation that ends is running and nothing in the document changed. Endless and scroll-driven animations do not count, since they never end on their own (waiting on a scroll-driven one's finished never returns). A page that never stops fails with what kept moving. no-fixed-settle-waits.test.ts keeps it that way: a file under app/tests that calls waitForTimeout fails unless it is listed with the most waits it may hold and why (a wait that proves something does not happen, a timer under test, a poll). --- app/tests/admin-people-remove-layout.test.tsx | 3 +- app/tests/admin-providers-connection.test.tsx | 3 +- app/tests/ai-connection-dialog.test.tsx | 3 +- .../audit-computer-limit-layout.test.tsx | 3 +- .../bot-long-instructions-layout.test.tsx | 23 +-- app/tests/bot-screen-record-layout.test.tsx | 3 +- .../bots-panel-start-conversation.test.tsx | 3 +- app/tests/checkbox-contrast.test.tsx | 3 +- app/tests/chunk-recovery.test.tsx | 3 +- .../composer-keeps-draft-browser.test.tsx | 5 +- .../computer-panel-phone-layout.test.tsx | 3 +- app/tests/connect-your-ai.test.tsx | 5 +- .../connected-bot-mistakes-layout.test.tsx | 3 +- .../conversation-refusal-layout.test.tsx | 5 +- app/tests/delete-account-layout.test.tsx | 3 +- app/tests/home-no-answer.test.tsx | 3 +- app/tests/large-picture-tile.test.tsx | 3 +- app/tests/member-rows-long-names.test.tsx | 3 +- app/tests/model-picker-phone-layout.test.tsx | 3 +- app/tests/move-to-cloud-settings.test.tsx | 3 +- app/tests/moved-elsewhere.test.tsx | 3 +- app/tests/needs-you-board-layout.test.tsx | 5 +- app/tests/no-fixed-settle-waits.test.ts | 140 ++++++++++++++++++ .../offline-conversation-layout.test.tsx | 3 +- .../organization-members-remove.test.tsx | 3 +- app/tests/organization-notices-browser.ts | 3 +- app/tests/page-still.ts | 96 ++++++++++++ app/tests/people-lists.test.tsx | 3 +- app/tests/plan-notices-layout.test.tsx | 9 +- app/tests/routine-run-now-layout.test.tsx | 3 +- app/tests/run-ended-unheard-layout.test.tsx | 3 +- app/tests/section-strip-routines.test.tsx | 3 +- app/tests/service-terms.test.tsx | 5 +- .../settings-tool-cards-admin-layout.test.tsx | 3 +- .../settings-tool-cards-personal.test.tsx | 3 +- app/tests/sidebar-current-row.test.tsx | 3 +- app/tests/sidebar-window-buttons.test.tsx | 3 +- app/tests/task-report-chip.test.tsx | 3 +- app/tests/team-grants-screens-layout.test.tsx | 3 +- app/tests/team-models-screens-layout.test.tsx | 7 +- app/tests/teams-screens-layout.test.tsx | 7 +- app/tests/web-push-browser.test.tsx | 3 +- app/tests/workspace-snapshots-layout.test.tsx | 8 +- 43 files changed, 329 insertions(+), 79 deletions(-) create mode 100644 app/tests/no-fixed-settle-waits.test.ts create mode 100644 app/tests/page-still.ts diff --git a/app/tests/admin-people-remove-layout.test.tsx b/app/tests/admin-people-remove-layout.test.tsx index b654c70bd5..7df9441af9 100644 --- a/app/tests/admin-people-remove-layout.test.tsx +++ b/app/tests/admin-people-remove-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Removing somebody on a self-hosted OpenBot that keeps one shared organization and lets people @@ -176,7 +177,7 @@ async function open( ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/admin-providers-connection.test.tsx b/app/tests/admin-providers-connection.test.tsx index 8db9637a77..616b6d327d 100644 --- a/app/tests/admin-providers-connection.test.tsx +++ b/app/tests/admin-providers-connection.test.tsx @@ -27,6 +27,7 @@ import { MODEL_USAGE_PATH, overviewResponse, } from "./admin-settings-api"; +import { still } from "./page-still"; /** * Admin → AI providers: an admin changes the organization's AI, disconnects it and connects another, @@ -593,7 +594,7 @@ async function style(page: Page) { await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); // A dialog scales in: looked at once it is still. - await page.waitForTimeout(250); + await still(page); } async function shoot( diff --git a/app/tests/ai-connection-dialog.test.tsx b/app/tests/ai-connection-dialog.test.tsx index 10ae5ce599..0ea17e6007 100644 --- a/app/tests/ai-connection-dialog.test.tsx +++ b/app/tests/ai-connection-dialog.test.tsx @@ -10,6 +10,7 @@ import { ReplaceAiConnectionBody, } from "@/lib/api/generated/models/models.zod"; import { personBody } from "./accounts-api"; +import { still } from "./page-still"; /** * Settings → General → AI model changes the AI connection in the app, with OpenBot running. @@ -340,7 +341,7 @@ async function style(page: Page) { await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); // A dialog scales in: looked at once it is still. - await page.waitForTimeout(250); + await still(page); } async function shoot( diff --git a/app/tests/audit-computer-limit-layout.test.tsx b/app/tests/audit-computer-limit-layout.test.tsx index 7c653f1f3b..a4c8fd8b4c 100644 --- a/app/tests/audit-computer-limit-layout.test.tsx +++ b/app/tests/audit-computer-limit-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Admin's Activity with a computer refused at a limit, in a real browser, in light and dark, wide and on a phone. @@ -165,7 +166,7 @@ async function open( ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/bot-long-instructions-layout.test.tsx b/app/tests/bot-long-instructions-layout.test.tsx index 89cc78e769..e32e1fc4aa 100644 --- a/app/tests/bot-long-instructions-layout.test.tsx +++ b/app/tests/bot-long-instructions-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A Bot's instructions at the most they take, 5000 characters, in a real browser, in light and @@ -129,8 +130,8 @@ afterAll(async () => { * * Styles that arrive after the page has drawn start the transitions they declare: the dialog slides * from where it sat unstyled to the middle of the window over 150ms. A fixed wait measured it partway - * there, off the screen, whenever WebKit ran slow under a full CI run, so this waits for every - * transition and animation that ends to end, then measures what a person would see. + * there, off the screen, whenever WebKit ran slow under a full CI run, so this waits until the page + * is still, then measures what a person would see. */ async function styled(page: Page) { const classes = await page.evaluate(() => @@ -140,23 +141,7 @@ async function styled(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.evaluate(async () => { - for (;;) { - const moving = document - .getAnimations() - .filter( - (animation) => - animation.playState === "running" && - Number.isFinite( - Number(animation.effect?.getComputedTiming().endTime), - ), - ); - if (moving.length === 0) return; - await Promise.all( - moving.map((animation) => animation.finished.catch(() => {})), - ); - } - }); + await still(page); } async function open( diff --git a/app/tests/bot-screen-record-layout.test.tsx b/app/tests/bot-screen-record-layout.test.tsx index 09fd713499..db8155d542 100644 --- a/app/tests/bot-screen-record-layout.test.tsx +++ b/app/tests/bot-screen-record-layout.test.tsx @@ -4,6 +4,7 @@ import { dirname, join } from "node:path"; import type { BotBrowserApiState } from "@openbot/shared/bot-browser"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Record is on screen with the Bot's page, in a window of any width. @@ -199,7 +200,7 @@ async function open(window: { width: number; height: number }): Promise { await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); // The page is sized to the space it is given once that space has been measured (`useFittedWidth`). - await page.waitForTimeout(300); + await still(page); return page; } diff --git a/app/tests/bots-panel-start-conversation.test.tsx b/app/tests/bots-panel-start-conversation.test.tsx index 5e119af892..28fc0c1e66 100644 --- a/app/tests/bots-panel-start-conversation.test.tsx +++ b/app/tests/bots-panel-start-conversation.test.tsx @@ -5,6 +5,7 @@ import type { Browser, BrowserType, Locator, Page } from "playwright-core"; import { compile } from "tailwindcss"; import { personBody } from "./accounts-api"; import { conversationPage } from "./conversations-api"; +import { still } from "./page-still"; /** * A conversation with a Bot starts from the Bots panel, under the Bot. @@ -398,7 +399,7 @@ describe.skipIf(!asked)("starting a conversation from the Bots panel", () => { const page = await open(browser, { theme, width }); try { await page.mouse.move(width - 5, 600); - await page.waitForTimeout(400); + await still(page); await page.screenshot({ path: join( shots, diff --git a/app/tests/checkbox-contrast.test.tsx b/app/tests/checkbox-contrast.test.tsx index 0764d7b406..f0b7909b0d 100644 --- a/app/tests/checkbox-contrast.test.tsx +++ b/app/tests/checkbox-contrast.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * An unticked tickbox can be seen, in light and in dark. @@ -192,7 +193,7 @@ async function open( ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); // The tickbox eases its border colour in; let it land. - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/chunk-recovery.test.tsx b/app/tests/chunk-recovery.test.tsx index d2921e188d..4c4b694835 100644 --- a/app/tests/chunk-recovery.test.tsx +++ b/app/tests/chunk-recovery.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs"; import { basename, dirname, join } from "node:path"; import type { Browser, BrowserType, Page, Route } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A part of the app that couldn't be fetched is fetched again, and a release that replaced the @@ -348,7 +349,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } describe.skipIf(!asked)("A part of the app that couldn't be fetched", () => { diff --git a/app/tests/composer-keeps-draft-browser.test.tsx b/app/tests/composer-keeps-draft-browser.test.tsx index b06ea2f4ea..f08d574029 100644 --- a/app/tests/composer-keeps-draft-browser.test.tsx +++ b/app/tests/composer-keeps-draft-browser.test.tsx @@ -6,6 +6,7 @@ import { compile } from "tailwindcss"; import { getGetBotResponseMock } from "@/lib/api/generated/bots/bots.msw"; import { personBody } from "./accounts-api"; import { botGrantsBody } from "./bot-grants-api"; +import { still } from "./page-still"; /** * An unsent reply, and the files attached to it, stay with their conversation, in a real browser. @@ -423,8 +424,8 @@ async function shoot(page: Page, step: string, name: string) { ]), ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); - // The stylesheet lands after the page drew: give the strip's opening and the fonts a moment. - await page.waitForTimeout(500); + // The stylesheet lands after the page drew: the strip opens and the fonts load, then it is still. + await still(page); await page.screenshot({ path: join(shots, `composer-keeps-draft-${step}-${name}.png`), }); diff --git a/app/tests/computer-panel-phone-layout.test.tsx b/app/tests/computer-panel-phone-layout.test.tsx index eaf8f43a09..fbd96207f7 100644 --- a/app/tests/computer-panel-phone-layout.test.tsx +++ b/app/tests/computer-panel-phone-layout.test.tsx @@ -8,6 +8,7 @@ import { compile } from "tailwindcss"; import { getGetBotResponseMock } from "@/lib/api/generated/bots/bots.msw"; import { personBody } from "./accounts-api"; import { botGrantsBody } from "./bot-grants-api"; +import { still } from "./page-still"; /** * A Bot that browses, and asks the person to take over its browser or for a password, on a phone and @@ -405,7 +406,7 @@ async function style(page: Page) { async function shoot(page: Page, name: string) { await style(page); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); if (!shots) return; mkdirSync(shots, { recursive: true }); await page.screenshot({ path: join(shots, `${name}.png`) }); diff --git a/app/tests/connect-your-ai.test.tsx b/app/tests/connect-your-ai.test.tsx index 542422eaf7..7907ed5e56 100644 --- a/app/tests/connect-your-ai.test.tsx +++ b/app/tests/connect-your-ai.test.tsx @@ -25,6 +25,7 @@ import { } from "@/lib/api/generated/models/models.zod"; import { ListOrganizationsResponse } from "@/lib/api/generated/organizations/organizations.zod"; import { personBody } from "./accounts-api"; +import { still } from "./page-still"; /** * Connect your AI, on an OpenBot that provides no AI of its own (OpenBot Cloud). @@ -991,7 +992,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } async function shoot( @@ -2265,7 +2266,7 @@ describe.skipIf(!asked)("Connect your AI on OpenBot Cloud", () => { await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight), ); - await page.waitForTimeout(100); + await still(page); const room = await page.evaluate(() => { const footer = document.querySelector("footer"); const signOut = [...document.querySelectorAll("button")].find( diff --git a/app/tests/connected-bot-mistakes-layout.test.tsx b/app/tests/connected-bot-mistakes-layout.test.tsx index 7469c45d97..46d640f797 100644 --- a/app/tests/connected-bot-mistakes-layout.test.tsx +++ b/app/tests/connected-bot-mistakes-layout.test.tsx @@ -8,6 +8,7 @@ import { getGetBotResponseMock } from "@/lib/api/generated/bots/bots.msw"; import { UNREADABLE_REPLY } from "@/lib/copilot/stopped-turn"; import { personBody } from "./accounts-api"; import { botGrantsBody } from "./bot-grants-api"; +import { still } from "./page-still"; /** * What a person sees when a connected Bot gets something wrong, in a real browser. @@ -346,7 +347,7 @@ async function sent( async function shoot(page: Page, name: string) { await style(page); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); if (!shots) return; mkdirSync(shots, { recursive: true }); await page.screenshot({ path: join(shots, `${name}.png`) }); diff --git a/app/tests/conversation-refusal-layout.test.tsx b/app/tests/conversation-refusal-layout.test.tsx index d856bb802f..99c80593e9 100644 --- a/app/tests/conversation-refusal-layout.test.tsx +++ b/app/tests/conversation-refusal-layout.test.tsx @@ -4,6 +4,7 @@ import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; import { marksPlugin } from "./marks-plugin"; +import { still } from "./page-still"; /** * A turn the server refused reads as the app's notice, and a short conversation has no stray rail. @@ -164,10 +165,10 @@ async function open( * The turns are measured against the styled window a frame after it is styled, and the rail * (where it is drawn) appears then. Styled again, for its own classes. */ - await page.waitForTimeout(300); + await still(page); await style(page); // Rows ease in: looked at once they are still. - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/delete-account-layout.test.tsx b/app/tests/delete-account-layout.test.tsx index a257b5275a..d3ab0d18ef 100644 --- a/app/tests/delete-account-layout.test.tsx +++ b/app/tests/delete-account-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Deleting your account, in a real browser, in light and dark, wide and on a phone: General's @@ -141,7 +142,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); } async function open( diff --git a/app/tests/home-no-answer.test.tsx b/app/tests/home-no-answer.test.tsx index fc9f771a0f..6dd3dd2476 100644 --- a/app/tests/home-no-answer.test.tsx +++ b/app/tests/home-no-answer.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page, Route } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A message sent from home when OpenBot doesn't answer. @@ -218,7 +219,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } /** Write in home's composer and send, as a person does. */ diff --git a/app/tests/large-picture-tile.test.tsx b/app/tests/large-picture-tile.test.tsx index 2bf401105f..dba2886703 100644 --- a/app/tests/large-picture-tile.test.tsx +++ b/app/tests/large-picture-tile.test.tsx @@ -4,6 +4,7 @@ import { dirname, join } from "node:path"; import { deflateSync } from "node:zlib"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A picture over 8MB is not downloaded to draw its tile; it is fetched when somebody opens it. @@ -210,7 +211,7 @@ async function settled(page: Page) { await page.waitForFunction(() => [...document.images].every((image) => image.complete), ); - await page.waitForTimeout(300); + await still(page); } test.skipIf(!asked)( diff --git a/app/tests/member-rows-long-names.test.tsx b/app/tests/member-rows-long-names.test.tsx index 483f4564d9..bec7906d71 100644 --- a/app/tests/member-rows-long-names.test.tsx +++ b/app/tests/member-rows-long-names.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A long name and a long address in a list of people, in a real browser, in light and dark, wide @@ -179,7 +180,7 @@ async function open( ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/model-picker-phone-layout.test.tsx b/app/tests/model-picker-phone-layout.test.tsx index 6b6fd33c81..a00790c9b7 100644 --- a/app/tests/model-picker-phone-layout.test.tsx +++ b/app/tests/model-picker-phone-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * The composer's model picker names every model whole, on a phone as on a laptop. @@ -130,7 +131,7 @@ async function restyle(page: Page) { ]), ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); - await page.waitForTimeout(400); + await still(page); } const browsers = new Map(); diff --git a/app/tests/move-to-cloud-settings.test.tsx b/app/tests/move-to-cloud-settings.test.tsx index 64e7d9ed57..b63ad5172a 100644 --- a/app/tests/move-to-cloud-settings.test.tsx +++ b/app/tests/move-to-cloud-settings.test.tsx @@ -4,6 +4,7 @@ import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; import { personBody } from "./accounts-api"; +import { still } from "./page-still"; /** * Settings → Computer offers the move to OpenBot Cloud inside OpenBot Desktop, with OpenBot on this @@ -251,7 +252,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } async function shoot(page: Page, step: string, engine: string, theme: Theme) { diff --git a/app/tests/moved-elsewhere.test.tsx b/app/tests/moved-elsewhere.test.tsx index 11c5afa263..eec8bbaa3d 100644 --- a/app/tests/moved-elsewhere.test.tsx +++ b/app/tests/moved-elsewhere.test.tsx @@ -21,6 +21,7 @@ import { } from "@/lib/api/generated/people/people.zod"; import { movedElsewhereNoticeId } from "@/lib/moves/moved-elsewhere"; import { personBody } from "./accounts-api"; +import { still } from "./page-still"; /** * After a move to OpenBot Cloud, the person can tell where their Bots went and as whom they are @@ -604,7 +605,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } async function shoot(page: Page, step: string, engine: string, theme: Theme) { diff --git a/app/tests/needs-you-board-layout.test.tsx b/app/tests/needs-you-board-layout.test.tsx index ea4ff51780..57d260b62d 100644 --- a/app/tests/needs-you-board-layout.test.tsx +++ b/app/tests/needs-you-board-layout.test.tsx @@ -11,6 +11,7 @@ import { conversationPage, taskOf, } from "./conversations-api"; +import { still } from "./page-still"; import { answerScheduleLists, pathOf } from "./schedules-api"; /** @@ -337,9 +338,9 @@ async function open( await style(page); await page.evaluate(() => document.fonts.ready); // Styled, the rows lay out again; a row that folds its actions does so once it is measured. - await page.waitForTimeout(400); + await still(page); await style(page); - await page.waitForTimeout(200); + await still(page); return page; } diff --git a/app/tests/no-fixed-settle-waits.test.ts b/app/tests/no-fixed-settle-waits.test.ts new file mode 100644 index 0000000000..8185397ff0 --- /dev/null +++ b/app/tests/no-fixed-settle-waits.test.ts @@ -0,0 +1,140 @@ +import { describe, expect, test } from "bun:test"; +import { readdirSync, readFileSync } from "node:fs"; +import { join, relative } from "node:path"; + +/* + * Guard: a browser test waits for the page to be still, never for a fixed time. + * + * The browser tests draw a screen, add the app's stylesheet after it has drawn, and measure or + * photograph it. The styles start transitions as they land (a dialog sliding into place, a fade), + * and a row that measures itself lays out again. A fixed `page.waitForTimeout(400)` guessed how long + * that takes; under a full CI run, eight files at once in Chromium and WebKit, it sometimes guessed + * short and the test failed on a screen caught mid-move. About thirty files carried their own copy + * of that guess. They now call `still(page)` from ./page-still, which waits until nothing that ends + * is moving and nothing in the page changes. + * + * Some waits are fixed on purpose: to prove something does NOT happen within a time (no second tab + * opens, a read is not asked again), to let a timer the test is about run, or to poll something the + * page cannot be asked about. Those files are listed below, each with the most waits it may hold + * and why. Any other file that calls `waitForTimeout` fails here. + */ + +const TESTS = import.meta.dir; + +/** File, under app/tests: the most fixed waits it may hold, and why they are fixed. */ +const ALLOWED: Record = { + "chunk-recovery.test.tsx": { + most: 1, + why: "proves a page that failed to load stays put and is not loaded again", + }, + "composer-keeps-draft-browser.test.tsx": { + most: 1, + why: "gives the browser's storage its write before the page reloads", + }, + "composer-touch-return.test.tsx": { + most: 1, + why: "proves Return did not send, after a send it started would have arrived", + }, + "computer-panel-phone-layout.test.tsx": { + most: 2, + why: "proves the Computer does not open itself, and stays open, over a stretch of time", + }, + "connect-your-ai.test.tsx": { + most: 3, + why: "polls the fake provider for the tab the app opened, and proves a left sign-in is not read again", + }, + "consent-handoff.test.tsx": { + most: 14, + why: "the hand-off's countdown is what is tested: nothing opens before it ends, and a tab after", + }, + "conversation-access-ended.test.tsx": { + most: 1, + why: "lets three seconds of the access read's clock go by", + }, + "conversation-reply-toolbar-layout.test.tsx": { + most: 1, + why: "its wait for the Copy button's fade is being replaced on its own", + }, + "moved-apps-reconnect.test.tsx": { + most: 9, + why: "proves nothing is said or asked after a move; its settle waits are being replaced on their own", + }, + "moved-elsewhere.test.tsx": { + most: 8, + why: "proves the moved Bots bar does not come back after a reload, a switch or a dismiss", + }, + "organization-unavailable-admin-pages.test.tsx": { + most: 1, + why: "lets every read a page makes be answered before it is judged", + }, + "organization-unavailable-chat.test.tsx": { + most: 7, + why: "holds the organization out of reach for the time a send takes; being reworked on its own", + }, + "people-lists.test.tsx": { + most: 2, + why: "lets a typeahead's search, which waits for typing to stop, be asked and answered", + }, + "roster-working.test.tsx": { + most: 3, + why: "polls the fake server for a read, and proves a row's Working is not settled back", + }, + "section-strip-routines.test.tsx": { + most: 1, + why: "polls what the strip shows until it is what is wanted, for a few seconds at most", + }, + "sidebar-current-row.test.tsx": { + most: 1, + why: "lets the browser work out what is under a pointer that has not moved, which it does on a timer", + }, +}; + +/** Every .ts and .tsx file under app/tests, as a path from there. */ +function files(dir = TESTS): string[] { + return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const path = join(dir, entry.name); + if (entry.isDirectory()) return files(path); + return /\.tsx?$/.test(entry.name) ? [relative(TESTS, path)] : []; + }); +} + +/** How many fixed waits each file holds. */ +function fixedWaits(): Record { + const self = relative(TESTS, import.meta.path); + return Object.fromEntries( + files() + .filter((file) => file !== self) + .map((file) => [ + file, + ( + readFileSync(join(TESTS, file), "utf8").match( + /\.waitForTimeout\(/g, + ) ?? [] + ).length, + ]) + .filter(([, count]) => Number(count) > 0), + ); +} + +describe("browser tests wait for the page, not the clock", () => { + test("no file waits a fixed time unless it is listed with why", () => { + const over = Object.entries(fixedWaits()) + .filter(([file, count]) => count > (ALLOWED[file]?.most ?? 0)) + .map( + ([file, count]) => + `${file}: ${count} fixed wait${count === 1 ? "" : "s"}, ${ALLOWED[file]?.most ?? 0} allowed`, + ) + .sort(); + expect( + over, + "A fixed wait for the page to settle flakes under load. Wait with `await still(page)` from ./page-still. A wait that proves something does not happen goes in ALLOWED with why.", + ).toEqual([]); + }); + + test("every listed file is still there", () => { + const present = new Set(files()); + expect(Object.keys(ALLOWED).filter((file) => !present.has(file))).toEqual( + [], + ); + }); +}); diff --git a/app/tests/offline-conversation-layout.test.tsx b/app/tests/offline-conversation-layout.test.tsx index 237d09052d..f21c614931 100644 --- a/app/tests/offline-conversation-layout.test.tsx +++ b/app/tests/offline-conversation-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A conversation opened while the OpenBot it is connected to can't be reached, in a real browser. @@ -174,7 +175,7 @@ async function open( await page.getByText(PLACEHOLDER).waitFor({ timeout: 15_000 }); await style(page); // The frame settles after the first styling (the sidebar measures itself), so again for what it drew then. - await page.waitForTimeout(1_000); + await still(page); await style(page); await page.evaluate(() => document.fonts.ready); return page; diff --git a/app/tests/organization-members-remove.test.tsx b/app/tests/organization-members-remove.test.tsx index 28b4bc76e6..a096aadf51 100644 --- a/app/tests/organization-members-remove.test.tsx +++ b/app/tests/organization-members-remove.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Only an owner removes another owner, as the server holds. Organization settings' Members list, in @@ -166,7 +167,7 @@ async function open( ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/organization-notices-browser.ts b/app/tests/organization-notices-browser.ts index 8272ada152..a09cf4c89e 100644 --- a/app/tests/organization-notices-browser.ts +++ b/app/tests/organization-notices-browser.ts @@ -36,6 +36,7 @@ import { } from "@/lib/api/generated/teams/teams.zod"; import { personBody } from "./accounts-api"; import { conversationPage, problemBody } from "./conversations-api"; +import { still } from "./page-still"; export const asked = process.env.OPENBOT_APP_BROWSER === "1"; export const shots = process.env.OPENBOT_APP_SHOTS; @@ -601,7 +602,7 @@ export async function style(page: Page): Promise { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(150); + await still(page); } /** Save the page as `----.png` when screenshots are asked for. */ diff --git a/app/tests/page-still.ts b/app/tests/page-still.ts new file mode 100644 index 0000000000..8bdb851b2b --- /dev/null +++ b/app/tests/page-still.ts @@ -0,0 +1,96 @@ +import type { Page } from "playwright-core"; + +/** + * Until nothing on the page is moving, for the browser tests that measure or photograph a screen. + * + * Those tests draw the page first and add its stylesheet after, so the styles arrive on elements + * already drawn and start the transitions they declare: a dialog slides from where it sat unstyled + * to the middle of the window, a button fades from the browser's own colour to its own, rows ease + * in. Styled, a row that measures itself lays out again, and what it draws then may move too. A + * fixed wait (a `waitForTimeout` of 400ms) guessed how long that takes, and under a full CI run + * (eight files at once, Chromium and WebKit each) it sometimes guessed short, so the test read the + * screen mid-move and failed. This waits for the page itself to say it is done instead. + * + * Still means, for three frames in a row: no animation or transition that ends is running, and + * nothing in the document changed. Endless animations (a spinner, a shimmer) and ones driven by + * scrolling (the transcript's scroll fade) never end on their own, so they do not count; waiting on + * a scroll-driven one's `finished` never returns, because its timeline is the scroller, not time. + * A page that never stops fails here, saying what kept moving, rather than being measured mid-move. + */ +export async function still(page: Page, timeout = 10_000): Promise { + const moving = await page.evaluate(async (timeout) => { + // A font that lands lays the text out again. + await document.fonts.ready; + const frame = () => + new Promise((done) => requestAnimationFrame(() => done())); + const name = (node: Node | null) => { + if (!(node instanceof Element)) return node?.nodeName ?? "nothing"; + const classes = [...node.classList].slice(0, 3).join("."); + return classes ? `${node.localName}.${classes}` : node.localName; + }; + const running = () => + document + .getAnimations() + .filter( + (animation) => + animation.playState === "running" && + animation.timeline === document.timeline && + Number.isFinite( + Number(animation.effect?.getComputedTiming().endTime), + ), + ); + let changed: Node | null = null; + const watcher = new MutationObserver((records) => { + changed = records.at(-1)?.target ?? document; + }); + /** What changed since the last frame, if anything; and forget it. */ + const take = (): Node | null => { + const was = changed; + changed = null; + return was; + }; + watcher.observe(document, { + subtree: true, + childList: true, + attributes: true, + characterData: true, + }); + const deadline = performance.now() + timeout; + try { + for (let quiet = 0; quiet < 3; ) { + await frame(); + const now = running(); + const touched = take(); + if (now.length === 0 && touched === null) { + quiet += 1; + continue; + } + quiet = 0; + if (performance.now() > deadline) + return [ + ...now.map((animation) => { + const target = + animation.effect instanceof KeyframeEffect + ? animation.effect.target + : null; + const what = + animation instanceof CSSTransition + ? `transition of ${animation.transitionProperty}` + : animation instanceof CSSAnimation + ? `animation ${animation.animationName}` + : "animation"; + return `${what} on ${name(target)}`; + }), + ...(touched ? [`a change to ${name(touched)}`] : []), + ].join(", "); + } + return null; + } finally { + watcher.disconnect(); + } + }, timeout); + if (moving) + throw new Error( + `The page was still moving after ${timeout}ms: ${moving}. Something on it never stops, so there is no still screen to measure.`, + ); +} diff --git a/app/tests/people-lists.test.tsx b/app/tests/people-lists.test.tsx index 1c050fb82e..acb1ec92d8 100644 --- a/app/tests/people-lists.test.tsx +++ b/app/tests/people-lists.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Locator, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; import { answer, ORGANIZATION, @@ -655,7 +656,7 @@ describe.skipIf(!asked)("each screen at every width and theme", () => { await look.act?.(page); // What opened after the first styling (a dialog, a list) is styled too. await restyle(page); - await page.waitForTimeout(400); + await still(page); const sideways = await page.evaluate( () => document.documentElement.scrollWidth > innerWidth || diff --git a/app/tests/plan-notices-layout.test.tsx b/app/tests/plan-notices-layout.test.tsx index a83c8d4dbb..416acfc91a 100644 --- a/app/tests/plan-notices-layout.test.tsx +++ b/app/tests/plan-notices-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Where an organization's plan shows, drawn by a real Chromium with the app's stylesheet: the bar @@ -203,13 +204,7 @@ async function restyle(page: Page, key: string) { await page.evaluate(() => document.fonts.ready); // Styled after it was drawn, so a button's colour transition runs from the browser's own link // blue: wait it out, or the picture catches it half way. - // The transitions start on the next frame and last 150ms, so let a few frames pass first. - await page.waitForTimeout(400); - await page.waitForFunction(() => - document - .getAnimations() - .every((running) => !(running instanceof CSSTransition)), - ); + await still(page); } async function shot(page: Page, name: string) { diff --git a/app/tests/routine-run-now-layout.test.tsx b/app/tests/routine-run-now-layout.test.tsx index e0da20e010..b34848598b 100644 --- a/app/tests/routine-run-now-layout.test.tsx +++ b/app/tests/routine-run-now-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * Run now on a routine's page, in a real browser, in light and dark, wide and on a phone. Before @@ -168,7 +169,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(300); + await still(page); } async function shoot(page: Page, file: string) { diff --git a/app/tests/run-ended-unheard-layout.test.tsx b/app/tests/run-ended-unheard-layout.test.tsx index d1ccc5f6f1..4ab802aea0 100644 --- a/app/tests/run-ended-unheard-layout.test.tsx +++ b/app/tests/run-ended-unheard-layout.test.tsx @@ -8,6 +8,7 @@ import { getGetBotResponseMock } from "@/lib/api/generated/bots/bots.msw"; import { RUN_ENDED_UNHEARD } from "@/lib/copilot/quiet-run"; import { personBody } from "./accounts-api"; import { botGrantsBody } from "./bot-grants-api"; +import { still } from "./page-still"; /** * A run whose end never reached this browser is shown as it ended on the server, in a real browser. @@ -608,7 +609,7 @@ async function sent( async function shoot(page: Page, name: string) { await style(page); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); if (!shots) return; mkdirSync(shots, { recursive: true }); await page.screenshot({ path: join(shots, `${name}.png`) }); diff --git a/app/tests/section-strip-routines.test.tsx b/app/tests/section-strip-routines.test.tsx index fde27adfcb..0e4d44ddde 100644 --- a/app/tests/section-strip-routines.test.tsx +++ b/app/tests/section-strip-routines.test.tsx @@ -5,6 +5,7 @@ import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; import { personBody } from "./accounts-api"; import { conversationPage } from "./conversations-api"; +import { still } from "./page-still"; /** * On Routines, a section with no panel, the strip lights Routines, and it can always be chosen @@ -437,7 +438,7 @@ describe.skipIf(!asked)("Routines on the strip", () => { await choose(page, "Chats"); await choose(page, "Bots"); await choose(page, "Routines"); - await page.waitForTimeout(400); + await still(page); await page.screenshot({ path: join( shots, diff --git a/app/tests/service-terms.test.tsx b/app/tests/service-terms.test.tsx index 4e91919c67..378ab0d3e2 100644 --- a/app/tests/service-terms.test.tsx +++ b/app/tests/service-terms.test.tsx @@ -12,6 +12,7 @@ import { } from "@/lib/api/generated/people/people.zod"; import { afterTerms } from "@/lib/service-terms/queries"; import { personBody } from "./accounts-api"; +import { still } from "./page-still"; /** * The terms of service, on OpenBot Cloud and everywhere else. @@ -369,7 +370,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(250); + await still(page); } async function shoot( @@ -402,7 +403,7 @@ async function shootEnd( const root = document.documentElement; root.scrollTop = root.scrollHeight; }); - await page.waitForTimeout(100); + await still(page); mkdirSync(shots, { recursive: true }); await page.screenshot({ path: join( diff --git a/app/tests/settings-tool-cards-admin-layout.test.tsx b/app/tests/settings-tool-cards-admin-layout.test.tsx index ba9483bf30..a9cbdb81be 100644 --- a/app/tests/settings-tool-cards-admin-layout.test.tsx +++ b/app/tests/settings-tool-cards-admin-layout.test.tsx @@ -12,6 +12,7 @@ import { personBody } from "./accounts-api"; import { deploymentBody, overviewResponse } from "./admin-settings-api"; import { approvalInboxResponse } from "./approvals-api"; import { marksPlugin } from "./marks-plugin"; +import { still } from "./page-still"; import { screenLinkLooks } from "./screen-link-style"; import { CALLS, waitingRequests } from "./settings-tool-cards-admin.calls"; @@ -443,7 +444,7 @@ async function open( } await page.addStyleTag({ content: sheet }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/settings-tool-cards-personal.test.tsx b/app/tests/settings-tool-cards-personal.test.tsx index 8671906302..0e381ee430 100644 --- a/app/tests/settings-tool-cards-personal.test.tsx +++ b/app/tests/settings-tool-cards-personal.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; import { screenLinkLooks } from "./screen-link-style"; /** @@ -207,7 +208,7 @@ async function open( }); await page.evaluate(() => document.fonts.ready); // An approval card unfolds its answers as it opens; it is looked at once it has. - await page.waitForTimeout(400); + await still(page); return page; } diff --git a/app/tests/sidebar-current-row.test.tsx b/app/tests/sidebar-current-row.test.tsx index 476b072691..38ce8081c1 100644 --- a/app/tests/sidebar-current-row.test.tsx +++ b/app/tests/sidebar-current-row.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * On the invitations page no row of the sidebar looks like the page that is open. @@ -247,7 +248,7 @@ describe.skipIf(!asked)("the sidebar on the invitations page", () => { (botsNow?.y ?? 0) + (botsNow?.height ?? 0) / 2, { steps: 4 }, ); - await page.waitForTimeout(100); + await still(page); expect((await rows(page)).filled).toEqual(["Bots"]); }, 120_000); } diff --git a/app/tests/sidebar-window-buttons.test.tsx b/app/tests/sidebar-window-buttons.test.tsx index 1639d354af..98f92d5f2a 100644 --- a/app/tests/sidebar-window-buttons.test.tsx +++ b/app/tests/sidebar-window-buttons.test.tsx @@ -9,6 +9,7 @@ import { GetPreferencesResponse } from "@/lib/api/generated/people/people.zod"; import { personBody } from "./accounts-api"; import { type AppsFixture, answerAppsApi } from "./apps-api"; import { conversationPage } from "./conversations-api"; +import { still } from "./page-still"; /** * In OpenBot Desktop on macOS the window's close, minimise and zoom buttons sit over the sidebar's @@ -95,7 +96,7 @@ const CASES: Case[] = [ await page.getByRole("button", { name: "Show sidebar" }).click(); await page.locator('[data-slot="strip"]').waitFor(); // The sheet slides in; measure where it comes to rest. - await page.waitForTimeout(600); + await still(page); }, }, { diff --git a/app/tests/task-report-chip.test.tsx b/app/tests/task-report-chip.test.tsx index f6edebdff9..2f742c201b 100644 --- a/app/tests/task-report-chip.test.tsx +++ b/app/tests/task-report-chip.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; import { apiTask, RESULTS, STATES, TITLES } from "./task-report-chip.data"; /** @@ -180,7 +181,7 @@ async function open(engine: string, theme: Theme, width: number) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(300); + await still(page); return page; } diff --git a/app/tests/team-grants-screens-layout.test.tsx b/app/tests/team-grants-screens-layout.test.tsx index f0e450f414..ddc6be4cbc 100644 --- a/app/tests/team-grants-screens-layout.test.tsx +++ b/app/tests/team-grants-screens-layout.test.tsx @@ -26,6 +26,7 @@ import { sharedConnectionPath, sharedConnectionResponse, } from "./connections-api"; +import { still } from "./page-still"; import { SKILLS_PATH, skillPath, skillsResponse } from "./skills-api"; /** @@ -921,7 +922,7 @@ async function open( await page.evaluate(() => document.fonts.ready); await screen.lookAt?.(page); // Rows ease in and a dialog scales up: looked at once they are still. - await page.waitForTimeout(400); + await still(page); return { page, unanswered }; } diff --git a/app/tests/team-models-screens-layout.test.tsx b/app/tests/team-models-screens-layout.test.tsx index 53b9698761..8b4a39a67d 100644 --- a/app/tests/team-models-screens-layout.test.tsx +++ b/app/tests/team-models-screens-layout.test.tsx @@ -20,6 +20,7 @@ import { settingsBody, } from "./admin-settings-api"; import { marksPlugin } from "./marks-plugin"; +import { still } from "./page-still"; /** * A team's models, set by an admin and read by anybody, in a real browser. @@ -505,7 +506,7 @@ async function restyle(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); // Rows ease in and a dialog scales up: looked at once they are still. - await page.waitForTimeout(400); + await still(page); } /** What a person would see wrong: sideways scroll, a control cut off, words under a button. */ @@ -910,7 +911,7 @@ describe.skipIf(!asked)("a team's models", () => { .locator("[data-slot=item]") .filter({ hasText: "Teams with their own list" }); await line.scrollIntoViewIfNeeded(); - await page.waitForTimeout(200); + await still(page); expect( await line .getByRole("link") @@ -934,7 +935,7 @@ describe.skipIf(!asked)("a team's models", () => { .locator("section") .filter({ has: page.getByRole("heading", { name: "Usage" }) }); await usage.scrollIntoViewIfNeeded(); - await page.waitForTimeout(200); + await still(page); expect( await usage .locator("[data-slot=item-title]") diff --git a/app/tests/teams-screens-layout.test.tsx b/app/tests/teams-screens-layout.test.tsx index 596b037b18..e0d97ae712 100644 --- a/app/tests/teams-screens-layout.test.tsx +++ b/app/tests/teams-screens-layout.test.tsx @@ -14,6 +14,7 @@ import { personBody } from "./accounts-api"; import { teamBotOf } from "./bots-api"; import { personLearningBody, reviewBody } from "./learning-api"; import { marksPlugin } from "./marks-plugin"; +import { still } from "./page-still"; import { SKILLS_PATH, skillBody } from "./skills-api"; /** @@ -483,7 +484,7 @@ const SCREENS: Screen[] = [ await page.addStyleTag({ content: await stylesheet([...new Set(classes)]), }); - await page.waitForTimeout(400); + await still(page); } await account.click(); await page.getByRole("menuitem", { name: "Teams" }).waitFor(); @@ -768,7 +769,7 @@ async function open( } await screen.lookAt?.(page); // Rows ease in and a dialog scales up: looked at once they are still. - await page.waitForTimeout(400); + await still(page); return page; } @@ -951,7 +952,7 @@ async function restyle(page: Page) { ]), ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); - await page.waitForTimeout(400); + await still(page); } /** Saves what the page shows now, when screenshots are asked for. */ diff --git a/app/tests/web-push-browser.test.tsx b/app/tests/web-push-browser.test.tsx index 650f4429a5..9db47bf0bf 100644 --- a/app/tests/web-push-browser.test.tsx +++ b/app/tests/web-push-browser.test.tsx @@ -6,6 +6,7 @@ import { compile } from "tailwindcss"; import { servedHeaders } from "../serve"; import { ME_PATH, meResponse } from "./accounts-api"; import { notificationsResponse } from "./notifications-api"; +import { still } from "./page-still"; import { WEB_PUSH_KEY, WEB_PUSH_SUBSCRIPTIONS_PATH, @@ -148,7 +149,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); + await still(page); } /** Every request the API was sent, as the server saw it. */ diff --git a/app/tests/workspace-snapshots-layout.test.tsx b/app/tests/workspace-snapshots-layout.test.tsx index 415ecb1ee3..5b3491ccf2 100644 --- a/app/tests/workspace-snapshots-layout.test.tsx +++ b/app/tests/workspace-snapshots-layout.test.tsx @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import type { Browser, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * A Bot's saved copies hold their layout, drawn by a real Chromium with the app's stylesheet: the @@ -100,12 +101,7 @@ async function style(page: Page) { ); await page.addStyleTag({ content: await stylesheet(classes) }); await page.evaluate(() => document.fonts.ready); - await page.waitForTimeout(400); - await page.waitForFunction(() => - document - .getAnimations() - .every((running) => !(running instanceof CSSTransition)), - ); + await still(page); } async function open( From e01295d95ef61d4f016b5e3a5dbaa53aeac4cb59 Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:11:36 -0800 Subject: [PATCH 2/7] Temporary: run the still-page browser tests together for several rounds --- .github/workflows/settle-proof.yml | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/settle-proof.yml diff --git a/.github/workflows/settle-proof.yml b/.github/workflows/settle-proof.yml new file mode 100644 index 0000000000..a97b41f15f --- /dev/null +++ b/.github/workflows/settle-proof.yml @@ -0,0 +1,86 @@ +# TEMPORARY: removed before merge. Runs every browser test that now waits for a still page, +# together, eight at a time, in Chromium and WebKit, several rounds side by side. +name: settle proof + +on: + pull_request: + +permissions: + contents: read + +jobs: + round: + name: round ${{ matrix.round }} + runs-on: openbot-ubuntu-16core + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + round: [1, 2, 3, 4, 5, 6] + env: + PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright:v1.62.1-noble@sha256:dcc5531e97840b9b5e794f2814476b21571c5124a3fca2267d73041f56e7580e + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.4.3 + - run: bun install --frozen-lockfile + - run: bun run generate:app-config + - run: | + docker run --rm --ipc=host \ + --volume "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --workdir "$GITHUB_WORKSPACE" \ + --volume "$(command -v bun):/usr/local/bin/bun:ro" \ + --env OPENBOT_APP_BROWSER=1 --env OPENBOT_APP_ENGINES=chromium,webkit \ + "$PLAYWRIGHT_IMAGE" \ + bun test --parallel=8 \ + app/tests/admin-people-remove-layout.test.tsx \ + app/tests/admin-providers-connection.test.tsx \ + app/tests/ai-connection-dialog.test.tsx \ + app/tests/audit-computer-limit-layout.test.tsx \ + app/tests/bot-long-instructions-layout.test.tsx \ + app/tests/bot-screen-record-layout.test.tsx \ + app/tests/bots-panel-start-conversation.test.tsx \ + app/tests/checkbox-contrast.test.tsx \ + app/tests/chunk-recovery.test.tsx \ + app/tests/composer-keeps-draft-browser.test.tsx \ + app/tests/computer-panel-phone-layout.test.tsx \ + app/tests/connect-your-ai.test.tsx \ + app/tests/connected-bot-mistakes-layout.test.tsx \ + app/tests/conversation-refusal-layout.test.tsx \ + app/tests/delete-account-layout.test.tsx \ + app/tests/home-no-answer.test.tsx \ + app/tests/large-picture-tile.test.tsx \ + app/tests/member-rows-long-names.test.tsx \ + app/tests/model-picker-phone-layout.test.tsx \ + app/tests/move-to-cloud-settings.test.tsx \ + app/tests/moved-elsewhere.test.tsx \ + app/tests/needs-you-board-layout.test.tsx \ + app/tests/offline-conversation-layout.test.tsx \ + app/tests/organization-members-remove.test.tsx \ + app/tests/people-lists.test.tsx \ + app/tests/plan-notices-layout.test.tsx \ + app/tests/routine-run-now-layout.test.tsx \ + app/tests/run-ended-unheard-layout.test.tsx \ + app/tests/section-strip-routines.test.tsx \ + app/tests/service-terms.test.tsx \ + app/tests/settings-tool-cards-admin-layout.test.tsx \ + app/tests/settings-tool-cards-personal.test.tsx \ + app/tests/sidebar-current-row.test.tsx \ + app/tests/sidebar-window-buttons.test.tsx \ + app/tests/task-report-chip.test.tsx \ + app/tests/team-grants-screens-layout.test.tsx \ + app/tests/team-models-screens-layout.test.tsx \ + app/tests/teams-screens-layout.test.tsx \ + app/tests/web-push-browser.test.tsx \ + app/tests/workspace-snapshots-layout.test.tsx \ + app/tests/organization-held-actions.test.tsx \ + app/tests/organization-held-recovery.test.tsx \ + app/tests/organization-held-reload.test.tsx \ + app/tests/organization-moving.test.tsx \ + app/tests/organization-removed.test.tsx \ + app/tests/organization-unavailable-admin-pages.test.tsx \ + app/tests/organization-unavailable-chat.test.tsx \ + app/tests/organization-unavailable-pages.test.tsx \ + app/tests/strip-version-layout.test.tsx From b09b67aaf92ed78c1e7cdeeb14e413688c1a471c Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:27:22 -0800 Subject: [PATCH 3/7] Still means no box moved, not no change to the document The sidebar's orb breathes by writing its own scale every frame, so a page with it never stopped changing and the narrow sheet test could not go still. Read every element's laid-out box instead (offsets, before transforms): a transform that never ends no longer counts, and anything that lays out again still does. The failure now names the element that moved and where. --- .github/workflows/settle-proof.yml | 25 +++++++ app/tests/page-still.ts | 115 ++++++++++++++++------------- 2 files changed, 88 insertions(+), 52 deletions(-) diff --git a/.github/workflows/settle-proof.yml b/.github/workflows/settle-proof.yml index a97b41f15f..f47c8a387b 100644 --- a/.github/workflows/settle-proof.yml +++ b/.github/workflows/settle-proof.yml @@ -9,6 +9,31 @@ permissions: contents: read jobs: + # The two sidebar files no CI job runs, as they are on main, to tell their own failures from ours. + main-baseline: + name: main baseline + runs-on: openbot-ubuntu-16core + timeout-minutes: 30 + env: + PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright:v1.62.1-noble@sha256:dcc5531e97840b9b5e794f2814476b21571c5124a3fca2267d73041f56e7580e + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: main + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.4.3 + - run: bun install --frozen-lockfile + - run: bun run generate:app-config + - run: | + docker run --rm --ipc=host \ + --volume "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --workdir "$GITHUB_WORKSPACE" \ + --volume "$(command -v bun):/usr/local/bin/bun:ro" \ + --env OPENBOT_APP_BROWSER=1 --env OPENBOT_APP_ENGINES=chromium,webkit \ + "$PLAYWRIGHT_IMAGE" \ + bun test app/tests/sidebar-current-row.test.tsx app/tests/sidebar-window-buttons.test.tsx + round: name: round ${{ matrix.round }} runs-on: openbot-ubuntu-16core diff --git a/app/tests/page-still.ts b/app/tests/page-still.ts index 8bdb851b2b..1dcb0026cf 100644 --- a/app/tests/page-still.ts +++ b/app/tests/page-still.ts @@ -11,11 +11,13 @@ import type { Page } from "playwright-core"; * (eight files at once, Chromium and WebKit each) it sometimes guessed short, so the test read the * screen mid-move and failed. This waits for the page itself to say it is done instead. * - * Still means, for three frames in a row: no animation or transition that ends is running, and - * nothing in the document changed. Endless animations (a spinner, a shimmer) and ones driven by - * scrolling (the transcript's scroll fade) never end on their own, so they do not count; waiting on - * a scroll-driven one's `finished` never returns, because its timeline is the scroller, not time. - * A page that never stops fails here, saying what kept moving, rather than being measured mid-move. + * Still means, for three frames in a row: no animation or transition that ends is running, and no + * element's box (where it is laid out, and its size) has changed. Endless animations (a spinner, a + * shimmer) and ones driven by scrolling (the transcript's scroll fade) never end on their own, so + * they do not count; waiting on a scroll-driven one's `finished` never returns, because its + * timeline is the scroller, not time. Boxes are read as laid out, before transforms, so an orb that + * breathes by scaling itself every frame does not keep the page from being still. A page that never + * stops fails here, saying what kept moving, rather than being measured mid-move. */ export async function still(page: Page, timeout = 10_000): Promise { const moving = await page.evaluate(async (timeout) => { @@ -23,8 +25,8 @@ export async function still(page: Page, timeout = 10_000): Promise { await document.fonts.ready; const frame = () => new Promise((done) => requestAnimationFrame(() => done())); - const name = (node: Node | null) => { - if (!(node instanceof Element)) return node?.nodeName ?? "nothing"; + const name = (node: Element | null) => { + if (!node) return "nothing"; const classes = [...node.classList].slice(0, 3).join("."); return classes ? `${node.localName}.${classes}` : node.localName; }; @@ -39,55 +41,64 @@ export async function still(page: Page, timeout = 10_000): Promise { Number(animation.effect?.getComputedTiming().endTime), ), ); - let changed: Node | null = null; - const watcher = new MutationObserver((records) => { - changed = records.at(-1)?.target ?? document; - }); - /** What changed since the last frame, if anything; and forget it. */ - const take = (): Node | null => { - const was = changed; - changed = null; - return was; + /** Every element's laid-out box, in document order. */ + const boxes = () => + [...document.querySelectorAll("body *")] + .filter((element) => element instanceof HTMLElement) + .map( + (element) => + [ + element, + `${element.offsetLeft},${element.offsetTop},${element.offsetWidth},${element.offsetHeight}`, + ] as const, + ); + /** The first element whose box is not where it was, or null when none moved. */ + const moved = ( + before: ReturnType, + now: ReturnType, + ): string | null => { + if (before.length !== now.length) + return `elements came or went (${before.length} then ${now.length})`; + const index = now.findIndex( + ([element, box], at) => + before[at]?.[0] !== element || before[at]?.[1] !== box, + ); + if (index < 0) return null; + const [element, box] = now[index] as (typeof now)[number]; + return `${name(element)} moved from ${before[index]?.[1]} to ${box}`; }; - watcher.observe(document, { - subtree: true, - childList: true, - attributes: true, - characterData: true, - }); const deadline = performance.now() + timeout; - try { - for (let quiet = 0; quiet < 3; ) { - await frame(); - const now = running(); - const touched = take(); - if (now.length === 0 && touched === null) { - quiet += 1; - continue; - } - quiet = 0; - if (performance.now() > deadline) - return [ - ...now.map((animation) => { - const target = - animation.effect instanceof KeyframeEffect - ? animation.effect.target - : null; - const what = - animation instanceof CSSTransition - ? `transition of ${animation.transitionProperty}` - : animation instanceof CSSAnimation - ? `animation ${animation.animationName}` - : "animation"; - return `${what} on ${name(target)}`; - }), - ...(touched ? [`a change to ${name(touched)}`] : []), - ].join(", "); + let last = boxes(); + for (let quiet = 0; quiet < 3; ) { + await frame(); + const now = running(); + const laid = boxes(); + const shift = moved(last, laid); + last = laid; + if (now.length === 0 && shift === null) { + quiet += 1; + continue; } - return null; - } finally { - watcher.disconnect(); + quiet = 0; + if (performance.now() > deadline) + return [ + ...now.map((animation) => { + const target = + animation.effect instanceof KeyframeEffect + ? animation.effect.target + : null; + const what = + animation instanceof CSSTransition + ? `a transition of ${animation.transitionProperty}` + : animation instanceof CSSAnimation + ? `the animation ${animation.animationName}` + : "an animation"; + return `${what} on ${name(target)}`; + }), + ...(shift ? [shift] : []), + ].join(", "); } + return null; }, timeout); if (moving) throw new Error( From a1b6a1192791bc89752fe966c421fba0ecbf3f0c Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:41:10 -0800 Subject: [PATCH 4/7] Give two browser tests' teardown time to close their browsers under load --- app/tests/admin-providers-connection.test.tsx | 5 +++-- app/tests/bot-long-instructions-layout.test.tsx | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/tests/admin-providers-connection.test.tsx b/app/tests/admin-providers-connection.test.tsx index 616b6d327d..5e659b442c 100644 --- a/app/tests/admin-providers-connection.test.tsx +++ b/app/tests/admin-providers-connection.test.tsx @@ -511,9 +511,10 @@ beforeAll(async () => { } }, 120_000); +// Closing two browsers takes longer than a hook's five seconds when the machine runs eight files at once. afterAll(async () => { - for (const browser of browsers.values()) await browser.close(); -}); + await Promise.all([...browsers.values()].map((browser) => browser.close())); +}, 30_000); /** The page at `path`, its server answering from `server`. */ async function open( diff --git a/app/tests/bot-long-instructions-layout.test.tsx b/app/tests/bot-long-instructions-layout.test.tsx index e32e1fc4aa..38253de782 100644 --- a/app/tests/bot-long-instructions-layout.test.tsx +++ b/app/tests/bot-long-instructions-layout.test.tsx @@ -121,9 +121,10 @@ let script: string; if (asked) script = await bundle(); const browsers: Browser[] = []; +// Closing two browsers takes longer than a hook's five seconds when the machine runs eight files at once. afterAll(async () => { await Promise.all(browsers.map((browser) => browser.close())); -}); +}, 30_000); /** * Style what is on the page now, as the app's build would have, and let it settle. From 45c12c03704a76b9721e5eba41c5de05e000df2d Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:55:32 -0800 Subject: [PATCH 5/7] Remove the temporary still-page proof job --- .github/workflows/settle-proof.yml | 111 ----------------------------- 1 file changed, 111 deletions(-) delete mode 100644 .github/workflows/settle-proof.yml diff --git a/.github/workflows/settle-proof.yml b/.github/workflows/settle-proof.yml deleted file mode 100644 index f47c8a387b..0000000000 --- a/.github/workflows/settle-proof.yml +++ /dev/null @@ -1,111 +0,0 @@ -# TEMPORARY: removed before merge. Runs every browser test that now waits for a still page, -# together, eight at a time, in Chromium and WebKit, several rounds side by side. -name: settle proof - -on: - pull_request: - -permissions: - contents: read - -jobs: - # The two sidebar files no CI job runs, as they are on main, to tell their own failures from ours. - main-baseline: - name: main baseline - runs-on: openbot-ubuntu-16core - timeout-minutes: 30 - env: - PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright:v1.62.1-noble@sha256:dcc5531e97840b9b5e794f2814476b21571c5124a3fca2267d73041f56e7580e - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: main - persist-credentials: false - - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 - with: - bun-version: 1.4.3 - - run: bun install --frozen-lockfile - - run: bun run generate:app-config - - run: | - docker run --rm --ipc=host \ - --volume "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --workdir "$GITHUB_WORKSPACE" \ - --volume "$(command -v bun):/usr/local/bin/bun:ro" \ - --env OPENBOT_APP_BROWSER=1 --env OPENBOT_APP_ENGINES=chromium,webkit \ - "$PLAYWRIGHT_IMAGE" \ - bun test app/tests/sidebar-current-row.test.tsx app/tests/sidebar-window-buttons.test.tsx - - round: - name: round ${{ matrix.round }} - runs-on: openbot-ubuntu-16core - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - round: [1, 2, 3, 4, 5, 6] - env: - PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright:v1.62.1-noble@sha256:dcc5531e97840b9b5e794f2814476b21571c5124a3fca2267d73041f56e7580e - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 - with: - bun-version: 1.4.3 - - run: bun install --frozen-lockfile - - run: bun run generate:app-config - - run: | - docker run --rm --ipc=host \ - --volume "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --workdir "$GITHUB_WORKSPACE" \ - --volume "$(command -v bun):/usr/local/bin/bun:ro" \ - --env OPENBOT_APP_BROWSER=1 --env OPENBOT_APP_ENGINES=chromium,webkit \ - "$PLAYWRIGHT_IMAGE" \ - bun test --parallel=8 \ - app/tests/admin-people-remove-layout.test.tsx \ - app/tests/admin-providers-connection.test.tsx \ - app/tests/ai-connection-dialog.test.tsx \ - app/tests/audit-computer-limit-layout.test.tsx \ - app/tests/bot-long-instructions-layout.test.tsx \ - app/tests/bot-screen-record-layout.test.tsx \ - app/tests/bots-panel-start-conversation.test.tsx \ - app/tests/checkbox-contrast.test.tsx \ - app/tests/chunk-recovery.test.tsx \ - app/tests/composer-keeps-draft-browser.test.tsx \ - app/tests/computer-panel-phone-layout.test.tsx \ - app/tests/connect-your-ai.test.tsx \ - app/tests/connected-bot-mistakes-layout.test.tsx \ - app/tests/conversation-refusal-layout.test.tsx \ - app/tests/delete-account-layout.test.tsx \ - app/tests/home-no-answer.test.tsx \ - app/tests/large-picture-tile.test.tsx \ - app/tests/member-rows-long-names.test.tsx \ - app/tests/model-picker-phone-layout.test.tsx \ - app/tests/move-to-cloud-settings.test.tsx \ - app/tests/moved-elsewhere.test.tsx \ - app/tests/needs-you-board-layout.test.tsx \ - app/tests/offline-conversation-layout.test.tsx \ - app/tests/organization-members-remove.test.tsx \ - app/tests/people-lists.test.tsx \ - app/tests/plan-notices-layout.test.tsx \ - app/tests/routine-run-now-layout.test.tsx \ - app/tests/run-ended-unheard-layout.test.tsx \ - app/tests/section-strip-routines.test.tsx \ - app/tests/service-terms.test.tsx \ - app/tests/settings-tool-cards-admin-layout.test.tsx \ - app/tests/settings-tool-cards-personal.test.tsx \ - app/tests/sidebar-current-row.test.tsx \ - app/tests/sidebar-window-buttons.test.tsx \ - app/tests/task-report-chip.test.tsx \ - app/tests/team-grants-screens-layout.test.tsx \ - app/tests/team-models-screens-layout.test.tsx \ - app/tests/teams-screens-layout.test.tsx \ - app/tests/web-push-browser.test.tsx \ - app/tests/workspace-snapshots-layout.test.tsx \ - app/tests/organization-held-actions.test.tsx \ - app/tests/organization-held-recovery.test.tsx \ - app/tests/organization-held-reload.test.tsx \ - app/tests/organization-moving.test.tsx \ - app/tests/organization-removed.test.tsx \ - app/tests/organization-unavailable-admin-pages.test.tsx \ - app/tests/organization-unavailable-chat.test.tsx \ - app/tests/organization-unavailable-pages.test.tsx \ - app/tests/strip-version-layout.test.tsx From 9ece74f490970c8bc0f8f82fd1369ea01bf5dc4f Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 00:56:14 -0800 Subject: [PATCH 6/7] Fixed-wait list: drop the reply toolbar test, which no longer waits --- app/tests/no-fixed-settle-waits.test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/tests/no-fixed-settle-waits.test.ts b/app/tests/no-fixed-settle-waits.test.ts index 8185397ff0..efe8aadcb7 100644 --- a/app/tests/no-fixed-settle-waits.test.ts +++ b/app/tests/no-fixed-settle-waits.test.ts @@ -51,13 +51,9 @@ const ALLOWED: Record = { most: 1, why: "lets three seconds of the access read's clock go by", }, - "conversation-reply-toolbar-layout.test.tsx": { - most: 1, - why: "its wait for the Copy button's fade is being replaced on its own", - }, "moved-apps-reconnect.test.tsx": { most: 9, - why: "proves nothing is said or asked after a move; its settle waits are being replaced on their own", + why: "proves nothing is said or asked after a move; its one settle wait, after styling, is still to move to still()", }, "moved-elsewhere.test.tsx": { most: 8, @@ -69,7 +65,7 @@ const ALLOWED: Record = { }, "organization-unavailable-chat.test.tsx": { most: 7, - why: "holds the organization out of reach for the time a send takes; being reworked on its own", + why: "holds the organization out of reach for the time a send takes, and lets a stopped turn's notice land", }, "people-lists.test.tsx": { most: 2, From fd056e5c19e97aa9db5f2c5325492ada44c7c5d2 Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 27 Nov 2026 01:43:14 -0800 Subject: [PATCH 7/7] Hand back row test: wait for a still page, not 400ms --- app/tests/hand-back-row-layout.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/tests/hand-back-row-layout.test.tsx b/app/tests/hand-back-row-layout.test.tsx index 52dfde315a..15c1e196c5 100644 --- a/app/tests/hand-back-row-layout.test.tsx +++ b/app/tests/hand-back-row-layout.test.tsx @@ -4,6 +4,7 @@ import { dirname, join } from "node:path"; import type { BotBrowserApiState } from "@openbot/shared/bot-browser"; import type { Browser, BrowserType, Page } from "playwright-core"; import { compile } from "tailwindcss"; +import { still } from "./page-still"; /** * The row with Hand back, in a Bot's full-size screen taken over from a phone. @@ -225,7 +226,7 @@ async function open( await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); await page.evaluate(() => document.fonts.ready); // The page is sized to the space it is given once that space has been measured (`useFittedWidth`). - await page.waitForTimeout(400); + await still(page); return page; }