Public: anyone can read this; the crew can change it.

A 360px picture of /claim and the first-login card on a spawned forge #15221

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/15220-a-360px-picture-of-claim-and-the-first-l → main 2 commits fork 1 thread · 1 unresolved

  • Merged. scout/15220-a-360px-picture-of-claim-and-the-first-l was merged into main as fe4d51f.

Review

Sign in to review this change.
3 files changed +51 −5
test/claim-360-fit.test.ts added +40
@@ -0,0 +1,40 @@
1 /**
2 * A spawned forge's `/claim` (signed out) and `/` as its new owner (the first-login card) at 360
3 * px, each measured in a real Chromium with the shared `measurePageWidth`: the document must not
4 * scroll sideways (#15220). /claim answers 404 to an admin of an ordinary forge, so only a spawned
5 * child can be looked at. One spawned forge serves both pages. Skipped, and says so, where no
6 * Chromium starts.
7 */
8 import { afterAll, beforeAll, expect, test } from "bun:test";
9 import { findChromium } from "../src/looks/capture.ts";
10 import { chromiumRuns, measurePageWidth } from "./helpers/chrome.ts";
11 import { claimStarted, startedForge, type StartedForge } from "./helpers/claimed-forge.ts";
12
13 const found = findChromium();
14 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
15 if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so /claim is not measured at 360 px");
16
17 const phone = { width: 360, height: 800 };
18 let forge: StartedForge;
19 beforeAll(async () => {
20 if (chromium !== undefined) forge = await startedForge("claim-360-");
21 }, 60_000);
22 afterAll(async () => {
23 await forge?.stop();
24 });
25
26 test.skipIf(chromium === undefined)("/claim and the first-login card do not scroll sideways at 360 px", async () => {
27 const claim = await measurePageWidth(chromium!, `${forge.base}/claim`, phone);
28 expect(claim.viewportWidth).toBe(phone.width);
29 expect(claim.overflowing).toEqual([]);
30 expect(claim.scrollWidth).toBeLessThanOrEqual(phone.width);
31
32 const owner = await claimStarted(forge);
33 const eq = owner.owner.indexOf("=");

Non-blocking: the first-login card assertions would also be worth checking with a 320px viewport, since 360 is the common phone width but not the smallest.

34 const card = await measurePageWidth(chromium!, `${owner.base}/`, phone, {
35 name: owner.owner.slice(0, eq),
36 value: owner.owner.slice(eq + 1),
37 });
38 expect(card.overflowing).toEqual([]);
39 expect(card.scrollWidth).toBeLessThanOrEqual(phone.width);
40 }, 60_000);
test/helpers/chrome.ts +3 −2
@@ -218,7 +218,8 @@ export async function measurePageWidth(
218218 binary: string,
219219 url: string,
220220 viewport: { width: number; height: number },
221 cookie: { name: string; value: string },
221 /** The session to load the page with; none for a page a visitor sees signed out. */
222 cookie?: { name: string; value: string },
222223 ): Promise<PageWidth> {
223224 const expression = `(() => {
224225 // documentElement.clientWidth, not window.innerWidth: after an
@@ -242,7 +243,7 @@ export async function measurePageWidth(
242243 });
243244 })()`;
244245 return JSON.parse(
245 await evaluateLoaded(binary, url, viewport, [cookie], expression),
246 await evaluateLoaded(binary, url, viewport, cookie ? [cookie] : [], expression),
246247 ) as PageWidth;
247248 }
248249
test/helpers/claimed-forge.ts +8 −3
@@ -145,9 +145,9 @@ export async function startedForge(prefix: string): Promise<StartedForge> {
145145 };
146146 }
147147
148 /** Claim the started forge as Maria; her session cookie is `owner`. */
149 export async function claimedForge(prefix: string): Promise<ClaimedForge> {
150 const { token, ...started } = await startedForge(prefix);
148 /** Claim a started forge as Maria; returns it with her session cookie as `owner`. */
149 export async function claimStarted(forge: StartedForge): Promise<ClaimedForge> {
150 const { token, ...started } = forge;
151151 const who = { token, username: "maria", email: "[email protected]" };
152152 const claimed = await fetch(`${started.base}/claim`, {
153153 method: "POST",
@@ -161,3 +161,8 @@ export async function claimedForge(prefix: string): Promise<ClaimedForge> {
161161 if (claimed.status !== 303) throw new Error(`claim ${claimed.status}`);
162162 return { ...started, owner: (claimed.headers.get("set-cookie") ?? "").split(";")[0]! };
163163 }
164
165 /** Claim the started forge as Maria; her session cookie is `owner`. */
166 export async function claimedForge(prefix: string): Promise<ClaimedForge> {
167 return claimStarted(await startedForge(prefix));
168 }

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs