Public: anyone can read this; the crew can change it.
A browser test loads the owner's home at 375 px and fails on any sideways scroll #16731
Merged 15h 56m ago, live in production
scout/forge:scout/6069-a-browser-test-loads-the-owner-s-home-at → main 0 commits fork
2 files
changed +90
−2
src/web/pages/home_flow_style.ts +2 −2
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | */ |
| 13 | 13 | export const homeFlowCss = /* css */ ` |
| 14 | 14 | @layer components { |
| 15 | .hf { display: flex; flex-direction: column; gap: 16px; padding-top: 16px; } | |
| 15 | .hf { display: flex; flex-direction: column; gap: 16px; padding-top: 16px; min-width: 0; overflow-wrap: anywhere; } | |
| 16 | 16 | .hf-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; } |
| 17 | 17 | .hf-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; } |
| 18 | 18 | .hf-live { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-min); } |
| @@ -210,7 +210,7 @@ export const homeFlowCss = /* css */ ` | ||
| 210 | 210 | .tb-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "sel app lane" "sel what what" "sel state state" "sel who time"; column-gap: 8px; padding: 8px 12px 8px 0; border-top: 1px solid var(--border); } |
| 211 | 211 | .tb-row td { display: block; height: auto; min-width: 0; padding: 0; border: 0; } |
| 212 | 212 | .tb-row .tb-sel { grid-area: sel; grid-row: 1 / span 4; } |
| 213 | .tb-row .tb-app { grid-area: app; } | |
| 213 | .tb-row .tb-app { grid-area: app; white-space: normal; } | |
| 214 | 214 | .tb-row .tb-lane { grid-area: lane; text-align: right; font-size: var(--fs-min); } |
| 215 | 215 | .tb-row .tb-what { grid-area: what; } |
| 216 | 216 | .tb-row .tb-state { grid-area: state; font-size: var(--fs-min); } |
test/home-phone.test.ts added +88
| @@ -0,0 +1,88 @@ | ||
| 1 | /** | |
| 2 | * The owner's home at 375 px (#6069): seeded with long unbroken names, asks and | |
| 3 | * pulls waiting on the owner, and six-digit figures (visitors, spend), a real | |
| 4 | * Chromium loads it and the page does not scroll sideways. Where no Chromium | |
| 5 | * starts the measured test is skipped and says so on the log. | |
| 6 | */ | |
| 7 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 8 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 9 | import { tmpdir } from "node:os"; | |
| 10 | import { join } from "node:path"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { createSession } from "../src/core/sessions.ts"; | |
| 13 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 14 | import { findChromium } from "../src/looks/capture.ts"; | |
| 15 | import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts"; | |
| 16 | import { seedHomeFlow } from "./helpers/home-flow-seed.ts"; | |
| 17 | ||
| 18 | const WORD = "W".repeat(200); | |
| 19 | const SIX = 123_456; | |
| 20 | let dir: string; | |
| 21 | let app: App; | |
| 22 | let servers: Servers; | |
| 23 | let session: { name: string; value: string }; | |
| 24 | let page: string; | |
| 25 | ||
| 26 | beforeAll(async () => { | |
| 27 | dir = await mkdtemp(join(tmpdir(), "forge-home-phone-")); | |
| 28 | app = createApp({ dataDir: dir, port: 0 }); | |
| 29 | const seed = await seedHomeFlow(app); | |
| 30 | const db = app.db; | |
| 31 | // Long unbroken titles on every ask and pull, and on the apps themselves. | |
| 32 | db.run("UPDATE issue SET title = ?1 || ' ' || substr(title, 1, 20) WHERE rowid % 2 = 0", [WORD]); | |
| 33 | db.run("UPDATE issue SET title = ?1 WHERE rowid % 5 = 1", [WORD + "x"]); | |
| 34 | db.run("UPDATE repo SET name = ?1 || name WHERE id = ?2", [WORD, seed.repos.notes.id]); | |
| 35 | // Six-digit figures: visitors today and a day of crew spend. | |
| 36 | const now = Date.now(); | |
| 37 | const day = new Date(now).toISOString().slice(0, 10); | |
| 38 | db.run( | |
| 39 | `WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < ?1) | |
| 40 | INSERT INTO page_vital (day, at, route, visitor, load, cls) SELECT ?2, ?3, '/', 'v' || i, 900, 0 FROM n`, | |
| 41 | [SIX, day, now], | |
| 42 | ); | |
| 43 | db.run("INSERT INTO run (id, repo_id, kind, state, cost_usd, created_at) VALUES ('phone-spend', ?1, 'agent', 'ok', ?2, ?3)", [seed.repos.forge.id, SIX + 0.5, new Date(now).toISOString()]); | |
| 44 | servers = await serve(app); | |
| 45 | session = { name: "forge_session", value: createSession(db, seed.owner.id).token }; | |
| 46 | page = await (await fetch(`${servers.url}/`, { headers: { cookie: `${session.name}=${session.value}` } })).text(); | |
| 47 | }, 60_000); | |
| 48 | afterAll(async () => { | |
| 49 | servers.stop(); | |
| 50 | app.close(); | |
| 51 | await rm(dir, { recursive: true, force: true }); | |
| 52 | }); | |
| 53 | ||
| 54 | describe("the owner's home at 375 px, seeded", () => { | |
| 55 | test("the long names, the waiting asks and the six-digit figures are on the page", () => { | |
| 56 | expect(page).toContain(WORD.slice(0, 60)); | |
| 57 | expect(page).toContain("123,456"); | |
| 58 | }); | |
| 59 | }); | |
| 60 | ||
| 61 | const found = findChromium(); | |
| 62 | const chromium = found !== undefined && chromiumRuns(found) ? found : undefined; | |
| 63 | if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so the 375 px home is not measured"); | |
| 64 | ||
| 65 | describe.skipIf(chromium === undefined)("the owner's home, measured at 375x812", () => { | |
| 66 | test("no sideways scroll", async () => { | |
| 67 | const measure = `(() => { | |
| 68 | const vw = document.documentElement.clientWidth; | |
| 69 | // Past the edge only if a person could scroll to it: what an ancestor clips (overflow hidden or | |
| 70 | // clip, itself inside the viewport, as a tile's ellipsized app name clips its "#n") is not. | |
| 71 | const clipped = (el) => { | |
| 72 | for (let up = el.parentElement; up !== null && up !== document.body; up = up.parentElement) { | |
| 73 | const x = getComputedStyle(up).overflowX; | |
| 74 | if ((x === "hidden" || x === "clip") && up.getBoundingClientRect().right <= vw + 1) return true; | |
| 75 | } | |
| 76 | return false; | |
| 77 | }; | |
| 78 | const over = [...document.querySelectorAll("main *")].filter((el) => !el.closest("svg") && el.getBoundingClientRect().right > vw + 1 && !clipped(el)).slice(0, 8).map((el) => el.tagName.toLowerCase() + "." + el.className); | |
| 79 | return JSON.stringify({ scrollWidth: document.documentElement.scrollWidth, viewportWidth: vw, over, figures: document.querySelectorAll(".hf-fig").length }); | |
| 80 | })()`; | |
| 81 | const m = JSON.parse(await evaluateLoaded(chromium!, `${servers.url}/`, { width: 375, height: 812 }, [session], measure)) as { scrollWidth: number; viewportWidth: number; over: string[]; figures: number }; | |
| 82 | console.log(`home 375x812: ${JSON.stringify(m)}`); | |
| 83 | // The home was drawn, its row of figures with it: an empty page has nothing past the edge either. | |
| 84 | expect(m.figures).toBeGreaterThan(0); | |
| 85 | expect(m.scrollWidth).toBeLessThanOrEqual(375); | |
| 86 | expect(m.over).toEqual([]); | |
| 87 | }, 30_000); | |
| 88 | }); |
new above
offline