Files
PacketStation/tests/e2e/tests/presence.spec.ts
T
spencermandClaude Fable 5.1 6b6db0230f
ci / frontend (push) Successful in 43s
ci / server (push) Successful in 11m6s
ci / image (push) Successful in 38s
ci / e2e (push) Successful in 3m55s
Phase 8: Project Management, find bar, presence and motion
The Project Management screen (/pm, view only) with Overview, Projects & units, Bottlenecks & aging, Hours vs target,
Quality & issues and Find jobs, the period picker, health per unit and per project, drill down, Excel (CSV) per table
and for all, and the PESCO production status report PDF with the controlled-copy stamp; every export logged as
"report exported". The find bar on every home screen: the full search set, the dropdowns, quick flags with Mine, the
flag kinds, Board and List with sorts, filters saved per browser; every filter applied by the server on the list and
the boards, with facets. Presence in packets with role, lock and revoke drop; the motion switch with reduced motion
honoured, card glides, glow and count-up; Back restores the scroll spot; sheet placement and the iPad layout pass. The
data book compared page by page with the old build and six layout differences fixed. Tests for the PM aggregates,
search, filters, presence and exports; Playwright scenarios for the PM screen, the find bar and presence at desktop and
iPad viewports. Docs updated; PLAN.md questions 38 to 42.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-18 15:08:34 -06:00

70 lines
3.3 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test";
import { dcUser } from "./helpers";
import { actor, api, closeAll } from "./shophelpers";
import { L, makeDraft, makeProject, makeUnit, pullWithHeat, runSuffix, type Made } from "./pmhelpers";
// Phase 8 presence on the CI stack, modelled on the old sync.js presence and the "Also here" line. clerk.clara and
// wh.wade make one packet Ready to assign in 03. sup.wes and weld.andy open it in two browser contexts: each sees
// "Also in this packet now:" with the other's name and role. weld.andy closes the page: the callout on sup.wes's
// page clears within 10 s. weld.andy opens it again, then sup.wes locks the session through the API: weld.andy's
// callout drops sup.wes. Every UI label used here is in L (pmhelpers.ts).
let RUN = "";
let P: Made;
function callout(page: Page) {
return page.getByTestId(L.presence);
}
async function openPacket(page: Page, id: number): Promise<void> {
await page.goto(`/packets/${id}`);
await expect(page.getByRole("heading").first()).toBeVisible();
}
test.describe.serial("presence", () => {
test.setTimeout(180_000);
test("clerk.clara and wh.wade make the packet", async ({ browser }, info) => {
RUN = runSuffix(info.project.name);
const clara = await actor(browser, "clerk.clara");
const wade = await actor(browser, "wh.wade");
const proj = await makeProject(clara, `PR${RUN}`, { name: "Presence job" });
const unit = await makeUnit(clara, Number(proj.id), "001");
P = await makeDraft(clara, unit, `Presence ${RUN}`, { send: "warehouse" });
await pullWithHeat(wade, P.id, `HP${RUN}-`);
await closeAll(clara, wade);
});
test("two people on one packet see each other; leaving and locking drop out", async ({ browser }) => {
const wes = await actor(browser, "sup.wes");
const andy = await actor(browser, "weld.andy");
const wesName = dcUser("sup.wes").display_name;
const andyName = dcUser("weld.andy").display_name;
// alone: nothing is drawn
await openPacket(wes.page, P.id);
await expect(callout(wes.page)).toHaveCount(0);
// together: each sees the other with the role
await openPacket(andy.page, P.id);
await expect(callout(wes.page)).toContainText(L.alsoHere, { timeout: 10_000 });
await expect(callout(wes.page)).toContainText(`${andyName} (${L.roles.stall})`);
await expect(callout(andy.page)).toContainText(L.alsoHere, { timeout: 10_000 });
await expect(callout(andy.page)).toContainText(`${wesName} (${L.roles.supervisor})`);
await expect(callout(wes.page)).toHaveAttribute("role", "status");
await expect(callout(wes.page)).not.toContainText(wesName); // never yourself
// weld.andy closes the page: gone within 10 s
await andy.page.close();
await expect(callout(wes.page).filter({ hasText: andyName })).toHaveCount(0, { timeout: 10_000 });
// back again, then sup.wes locks: gone from weld.andy's callout
andy.page = await andy.ctx.newPage();
await openPacket(andy.page, P.id);
await expect(callout(andy.page)).toContainText(wesName, { timeout: 10_000 });
await api(wes, "post", "/api/auth/lock", undefined, { status: 204 });
await expect(callout(andy.page).filter({ hasText: wesName })).toHaveCount(0, { timeout: 10_000 });
await closeAll(wes, andy);
});
});