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
39 changes: 39 additions & 0 deletions .github/workflows/pm-aggregator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,42 @@ jobs:
run: bun install --frozen-lockfile
- name: Run projector tests
run: bun test

browser:
name: browser acceptance (MOB-00)
runs-on: ubuntu-latest
timeout-minutes: 30
# Same fixture contract as the test job (#5557): the MOB-00
# Playwright harness (#9467) boots the aggregator in fixture mode
# and aborts every non-local request, so the run is deterministic
# and needs no GitHub/Project/session credentials.
env:
PM_AGG_SOURCE: fixtures
PM_AGG_DEV: "1"
defaults:
run:
working-directory: pm-stack/aggregator
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Resolve pinned Playwright version
id: pw
run: echo "version=$(bunx playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers (pinned by @playwright/test in bun.lock)
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.pw.outputs.version }}-${{ hashFiles('pm-stack/aggregator/bun.lock') }}
- name: Install Chromium for the pinned Playwright version
run: bunx playwright install --with-deps chromium
- name: Run browser acceptance (MOB-00 contract test)
run: bunx playwright test --config playwright.config.ts --grep pmo_mob_03/04
- name: Upload Playwright trace/video on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-test-results
path: pm-stack/aggregator/test-results
if-no-files-found: ignore
7 changes: 7 additions & 0 deletions pm-stack/aggregator/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pm-stack/aggregator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build:css": "tailwindcss -i src/ui.css -o src/assets/app.css"
},
"devDependencies": {
"@playwright/test": "1.64.0",
"@tailwindcss/cli": "^4.3.4",
"@types/bun": "latest",
"daisyui": "^5.7.50",
Expand Down
46 changes: 46 additions & 0 deletions pm-stack/aggregator/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// MOB-00 (#9467): deterministic browser acceptance harness for the
// pm-stack aggregator's mobile work views. The harness boots the real
// server in fixture mode (PM_AGG_SOURCE=fixtures — the same fixture
// contract as the bun suite) on loopback-only ports and drives it with
// a pinned @playwright/test + Chromium. No GitHub/Project/session
// credentials are involved; the spec additionally aborts every request
// that is not aimed at the fixture server, so a passing run proves the
// flow works on isolated deterministic fixture data only.
//
// Trace and video are retained on failure (never a screenshot-only
// pass). The bun contract/read-model fixtures stay in `bun test` and
// are not part of this config: testDir is test/browser only.
import { defineConfig } from "@playwright/test";

const PORT = 4797;
const FRESHNESS_PORT = 4897;
const ORIGIN = `http://127.0.0.1:${PORT}`;

export default defineConfig({
testDir: "./test/browser",
timeout: 60_000,
expect: { timeout: 10_000 },
fullyParallel: false,
workers: 1,
retries: 0,
reporter: [["list"]],
use: {
baseURL: ORIGIN,
viewport: { width: 360, height: 740 },
trace: "retain-on-failure",
video: "retain-on-failure",
screenshot: "only-on-failure",
},
projects: [{ name: "chromium-360", use: { browserName: "chromium" } }],
webServer: {
command: "bun run src/server.ts",
url: `${ORIGIN}/api/health`,
reuseExistingServer: false,
timeout: 60_000,
env: {
PM_AGG_SOURCE: "fixtures",
PM_AGG_PORT: String(PORT),
PM_AGG_FRESHNESS_PORT: String(FRESHNESS_PORT),
},
},
});
117 changes: 117 additions & 0 deletions pm-stack/aggregator/test/browser/mobile-work-view.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// MOB-00 (#9467): the browser acceptance contract for the mobile work
// views, named for the slices whose acceptance it carries — MOB-03
// (responsive mobile queue, item detail, saved views, #9470) and
// MOB-04 (accessible compact responsive interaction system, #9471).
//
// The test runs against the aggregator's deterministic fixture mode
// only: every request that is not aimed at the local fixture server
// is aborted, and the queue item under test is read from the fixture
// server's own /api/queue.json, so the run is reproducible offline
// with no GitHub/Project/session credentials.
//
// 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.
// 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
// its title as the page heading at 360px, again with no
// horizontal overflow.
// 4. Action + status announcement: on the needs-you work view, a
// triage action submitted from the keyboard (focus + Enter) is
// accepted by the actions API (201) and the app then presents
// the result back in the page — the acted item joins the
// "Dismissed / done by you" section, whose count increments.
// (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.)
import { expect, test, type Page } from "@playwright/test";

const ORIGIN = "http://127.0.0.1:4797";

test.beforeEach(async ({ page }) => {
// Network isolation: local fixture server only.
await page.route("**/*", (route) => {
const url = route.request().url();
if (url.startsWith(ORIGIN) || url.startsWith("data:") || url.startsWith("blob:")) {
return route.continue();
}
return route.abort();
});
});

async function expectNoHorizontalOverflow(page: Page) {
const overflow = await page.evaluate(
() => document.documentElement.scrollWidth - document.documentElement.clientWidth,
);
expect(overflow).toBeLessThanOrEqual(1);
}

test("pmo_mob_03/04_mobile_queue_keyboard_and_viewport_contract", async ({ page, request }) => {
// 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`);
expect(apiRes.ok()).toBe(true);
const queue = (await apiRes.json()) as {
inProgress: { id: string; title: string }[];
};
const item = queue.inProgress[0];
expect(item, "fixture queue must contain an in-progress item").toBeTruthy();

// 1. Queue flow at 360px (fragment shell, as a phone browser gets it).
await page.setViewportSize({ width: 360, height: 740 });
await page.goto("/queue");
const card = page.locator("#queue-main article.card", { hasText: item.title }).first();
await expect(card).toBeVisible();
await expectNoHorizontalOverflow(page);

// The same queue page must also fit the 768px tablet width.
await page.setViewportSize({ width: 768, height: 900 });
await expectNoHorizontalOverflow(page);
await page.setViewportSize({ width: 360, height: 740 });

// 2. Keyboard reachability: Tab from the top of the page until the
// card's title link holds focus.
const titleLink = card.locator("a").first();
await page.evaluate(() => window.scrollTo(0, 0));
let focused = false;
for (let i = 0; i < 80 && !focused; i += 1) {
await page.keyboard.press("Tab");
focused = await titleLink.evaluate((el) => document.activeElement === el);
}
expect(focused, "queue card title link must be reachable by Tab").toBe(true);

// 3. Detail flow for the same queue item, at phone width.
await page.goto(`/item/${encodeURIComponent(item.id)}`);
await expect(page.locator("h1")).toContainText(item.title);
await expectNoHorizontalOverflow(page);

// 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).
await page.goto("/attention?full=1");
const dismissedCount = async (): Promise<number> => {
try {
return await page.evaluate(() => {
const m = document.body.innerText.match(/Dismissed \/ done by you \((\d+)\)/);
return m ? Number(m[1]) : 0;
});
} catch {
return -1; // navigation in flight; the poll below retries
}
};
const before = await dismissedCount();
expect(before).toBeGreaterThanOrEqual(0);
const dismissButton = page
.locator('form.aform[data-verb="dismiss"] button[type="submit"]')
.first();
await expect(dismissButton).toBeVisible();
const actionResponse = page.waitForResponse(
(r) => r.url().includes("/api/actions") && r.request().method() === "POST",
);
await dismissButton.focus();
await page.keyboard.press("Enter");
expect((await actionResponse).status()).toBe(201);
await expect.poll(dismissedCount).toBe(before + 1);
});