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
5 changes: 5 additions & 0 deletions changelog.d/browser-checks-wait-for-what-they-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Maintenance
- Four browser checks no longer fail on a slow run: the terminal input check waits for the
connection before it asks for a liveness probe, the update line and plan-limit checks count a
request once it has been answered or by the page that made it, and the phone transcript check
reads the transcript's style in one step.
4 changes: 3 additions & 1 deletion scripts/mobile-viewport-regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export async function checkMobileViewport(browser: Browser, origin: string, pane
await page.getByTitle("Chat transcript (⌘⇧J)", { exact: true }).click();
const composer = page.getByRole("textbox", { name: "Message", exact: true });
await composer.waitFor();
assert.equal(await page.locator(".chat-view").evaluate((node) => getComputedStyle(node).overscrollBehaviorY), "contain",
// read in one step: the transcript's first node is replaced as the conversation loads, and a node
// found before that and read after it is out of the document, with no style at all
assert.equal(await page.evaluate(() => { const view = document.querySelector(".chat-view"); return view ? getComputedStyle(view).overscrollBehaviorY : "no .chat-view"; }), "contain",
"a drag past the transcript's top stays in the transcript, or Android Chrome reloads the app");
assert.deepEqual(await page.evaluate(() => [document.documentElement, document.body].map((node) => getComputedStyle(node).overscrollBehaviorY)),
["contain", "contain"], "a drag on a surface with nothing to scroll reaches the page, which Android Chrome before 144 reloads unless html and body contain it");
Expand Down
3 changes: 3 additions & 0 deletions scripts/terminal-input-regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export async function checkTerminalInput(browser: Browser, origin: string, pane:
// A liveness probe refuses input without a frame to say so: on a quiet pane the 1 s poll reads
// it, so the terminal shows it waits instead of looking ready while typing goes to the draft.
const waiting = page.locator(".terminal-banner", { hasText: "Waiting for terminal input…" });
// the banner is drawn only on a connected pane: before the socket opens it is absent too, and
// a wake then finds nothing to probe
await page.locator(".conn-live").waitFor();
await waiting.waitFor({ state: "hidden" });
holdPings = true;
await page.evaluate(() => window.dispatchEvent(new Event("online")));
Expand Down
6 changes: 6 additions & 0 deletions scripts/update-notice-regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ export async function checkUpdateNotice(browser: Browser, origin: string, shots?
await fits("available");
await oneLine("available");
await shot("1-available");
// the line says it started as the button is pressed, before the request it sends is counted here
const installAnswered = () => page.waitForResponse((response) => new URL(response.url()).pathname === "/api/updates/install");
const firstInstall = installAnswered();
await page.getByRole("button", { name: "Update", exact: true }).click();
await page.getByText("Starting the update…", { exact: true }).waitFor();
await firstInstall;
assert.equal(installs, 1, "one tap asks for the install");
assert.equal(await page.getByRole("dialog", { name: "Settings" }).count(), 0, "Settings stays closed");

Expand All @@ -93,8 +97,10 @@ export async function checkUpdateNotice(browser: Browser, origin: string, shots?
await page.getByRole("button", { name: "Details", exact: true }).click();
await page.getByRole("dialog", { name: "Settings" }).getByText("bun run build failed: fixture").waitFor();
await page.getByRole("button", { name: "Close settings", exact: true }).click();
const secondInstall = installAnswered();
await page.getByRole("button", { name: "Try again", exact: true }).click();
await page.getByText("Starting the update…", { exact: true }).waitFor();
await secondInstall;
assert.equal(installs, 2, "Try again asks for the install again");
// the check an install starts with fails: nothing is available any more, and the line still says so
status = { ...status, phase: "error", available: false, error: "git fetch failed: fixture" };
Expand Down
18 changes: 13 additions & 5 deletions scripts/usage-regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,24 @@ const report = (): UsageReport => ({
],
});

async function staged(context: BrowserContext): Promise<string[]> {
/** a header the check puts on every request of the page it reloads: what that page asked for, whenever it is counted */
const RELOADED = "x-usage-qa-reloaded";

async function staged(context: BrowserContext): Promise<{ asked: string[]; afterReload: string[] }> {
const asked: string[] = [];
const afterReload: string[] = [];
await context.route("**/api/usage*", (route) => {
asked.push(new URL(route.request().url()).search);
if (route.request().headers()[RELOADED]) afterReload.push(route.request().url());
return route.fulfill({ json: report() });
});
return asked;
return { asked, afterReload };
}

export async function checkUsageMeters(browser: Browser, origin: string): Promise<void> {
const context = await browser.newContext({ viewport: { width: 1280, height: 800 }, locale: "en-US" });
try {
const asked = await staged(context);
const { asked, afterReload } = await staged(context);
const page = await context.newPage();
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(error.message));
Expand Down Expand Up @@ -151,10 +156,13 @@ export async function checkUsageMeters(browser: Browser, origin: string): Promis
await openSettingsPage(page, "Subscription usage");
await toggle.click();
await strip.waitFor({ state: "detached" });
const before = asked.length;
// a request Settings made before the switch can still be on its way here, so the count is of
// the reloaded page's own requests, not of what arrives after the reload
await context.setExtraHTTPHeaders({ [RELOADED]: "1" });
await page.reload();
await page.locator(".sidebar-footer").waitFor();
assert.equal(asked.length, before, "a hidden strip asks for nothing");
assert.deepEqual(afterReload, [], "a hidden strip asks for nothing");
await context.setExtraHTTPHeaders({});
assert.deepEqual(errors, []);
} finally {
await context.close();
Expand Down