Skip to content
Merged
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
52 changes: 50 additions & 2 deletions pm-stack/aggregator/test/browser/mobile-work-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// Assertions (the MOB-00 acceptance contract):
// 1. Queue flow at 360px: the queue shell loads its fragment and
// renders the fixture item's card; the page has no horizontal
// overflow at 360px or at 768px.
// overflow at 360px, at 768px, or at the 1280px desktop width
// (the MOB-03 acceptance checks rendered references at
// 360/768/1280 CSS px).
// 2. Keyboard reachability: repeated Tab presses move focus onto
// the queue card's title link (no mouse involved).
// 3. Detail flow: the same item's /item/<id> detail page renders
Expand All @@ -26,6 +28,11 @@
// (Comment posting is deliberately not used here: its author
// authorization resolves through the host secret store, which
// would make the harness non-deterministic across machines.)
// 5. 200% zoom: at 200% browser zoom a 720px-wide window shows a
// 360 CSS px layout viewport; emulated here as a 360 CSS px
// viewport rendered at deviceScaleFactor 2. The queue and
// detail flows must render their references with no horizontal
// overflow at that zoom (MOB-03 acceptance).
import { expect, test, type Page } from "@playwright/test";

const ORIGIN = "http://127.0.0.1:4797";
Expand All @@ -48,7 +55,7 @@ async function expectNoHorizontalOverflow(page: Page) {
expect(overflow).toBeLessThanOrEqual(1);
}

test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page, request }) => {
test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page, request, browser }) => {
// The deterministic fixture item: first in-progress row of the
// queue's own API, rendered by the queue page below.
const apiRes = await request.get(`${ORIGIN}/api/queue.json`);
Expand All @@ -69,6 +76,12 @@ test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page,
// The same queue page must also fit the 768px tablet width.
await page.setViewportSize({ width: 768, height: 900 });
await expectNoHorizontalOverflow(page);

// And the 1280px desktop width (MOB-03 acceptance: rendered
// references at 360/768/1280 CSS px).
await page.setViewportSize({ width: 1280, height: 900 });
await expect(card).toBeVisible();
await expectNoHorizontalOverflow(page);
await page.setViewportSize({ width: 360, height: 740 });

// 2. Keyboard reachability: Tab from the top of the page until the
Expand All @@ -87,6 +100,12 @@ test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page,
await expect(page.locator("h1")).toContainText(item.title);
await expectNoHorizontalOverflow(page);

// The detail reference must also render at the 1280px width.
await page.setViewportSize({ width: 1280, height: 900 });
await expect(page.locator("h1")).toContainText(item.title);
await expectNoHorizontalOverflow(page);
await page.setViewportSize({ width: 360, height: 740 });

// 4. Action + status announcement, driven from the keyboard:
// dismiss the first needs-you card and verify the result is
// presented back in the page (the Dismissed / done count grows).
Expand All @@ -112,4 +131,33 @@ test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page,
await page.keyboard.press("Enter");
expect((await actionResponse).status()).toBe(201);
await expect.poll(dismissedCount).toBe(before + 1);

// 5. 200% zoom: a 720px-wide window at 200% zoom presents a
// 360 CSS px layout viewport; emulate with a 360 CSS px viewport
// at deviceScaleFactor 2. Queue and detail flows must render
// their references with no horizontal overflow at that zoom.
const zoomContext = await browser.newContext({
baseURL: ORIGIN,
viewport: { width: 360, height: 740 },
deviceScaleFactor: 2,
});
try {
const zoomPage = await zoomContext.newPage();
await zoomPage.route("**/*", (route) => {
const url = route.request().url();
if (url.startsWith(ORIGIN) || url.startsWith("data:") || url.startsWith("blob:")) {
return route.continue();
}
return route.abort();
});
await zoomPage.goto("/queue");
const zoomCard = zoomPage.locator("#queue-main article.card", { hasText: item.title }).first();
await expect(zoomCard).toBeVisible();
await expectNoHorizontalOverflow(zoomPage);
await zoomPage.goto(`/item/${encodeURIComponent(item.id)}`);
await expect(zoomPage.locator("h1")).toContainText(item.title);
await expectNoHorizontalOverflow(zoomPage);
} finally {
await zoomContext.close();
}
});