Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/tests/admin-people-remove-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions app/tests/admin-providers-connection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -510,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(
Expand Down Expand Up @@ -593,7 +595,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(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/ai-connection-dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/audit-computer-limit-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
26 changes: 6 additions & 20 deletions app/tests/bot-long-instructions-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,17 +121,18 @@ 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.
*
* 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(() =>
Expand All @@ -140,23 +142,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(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/bot-screen-record-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -199,7 +200,7 @@ async function open(window: { width: number; height: number }): Promise<Page> {
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;
}

Expand Down
3 changes: 2 additions & 1 deletion app/tests/bots-panel-start-conversation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion app/tests/checkbox-contrast.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion app/tests/chunk-recovery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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", () => {
Expand Down
5 changes: 3 additions & 2 deletions app/tests/composer-keeps-draft-browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`),
});
Expand Down
3 changes: 2 additions & 1 deletion app/tests/computer-panel-phone-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`) });
Expand Down
5 changes: 3 additions & 2 deletions app/tests/connect-your-ai.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/connected-bot-mistakes-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`) });
Expand Down
5 changes: 3 additions & 2 deletions app/tests/conversation-refusal-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion app/tests/delete-account-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/hand-back-row-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion app/tests/home-no-answer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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. */
Expand Down
3 changes: 2 additions & 1 deletion app/tests/large-picture-tile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)(
Expand Down
3 changes: 2 additions & 1 deletion app/tests/member-rows-long-names.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
Loading
Loading