Files
HealthLog/e2e/setup-flow-child.spec.ts
T
Marc-André Bombeck 2686da2803 Add the setup flow's browser journeys, axe sweep and string-headroom check
Four journeys, one account each, from the welcome screen to the
dashboard: blood pressure and weight typed in, a daily medication added
inline, a visit within a month with labs, and a child's managed profile
created on the confirm screen. Each asserts what the walk wrote — the
module map, the tile order, the checklist, the settled ledger — and the
first proves that leaving after Q3 resumes at Q4.

Two sweeps on accounts of their own drive the state through the answers
route and visit every screen by URL: axe at both widths plus one
keyboard-only answer, and every locale with every text node lengthened
by 30% before the page, the shell, every clipping box and every control
are measured. All six run in one project because each mutates the
account it walks.

The medication wizard learns to stay where it was mounted after a
create, which the first-result screen needs and the medications list
does not.
2026-09-10 15:57:41 +02:00

102 lines
3.5 KiB
TypeScript

/**
* v1.39 (C2) — the setup flow, path 4: a child's managed profile.
*
* Q1 "someone I look after" keeps the questions in the guardian's own record
* and creates the profile on the confirm screen, after the questions — the
* maintainer's answer to spec question 2, and the only order the routes
* allow, since the three writes refuse under an acting-account switch. The
* immunization log is on for that answer, the first-result screen is not in
* the order (its tasks would write the wrong record), and the done screen
* offers the new record through the same switch the account menu uses.
*
* Creating the profile resolves `requireFreshMfa`, so the account carries a
* confirmed factor (stamped by global setup after its login) and the fixture
* makes the session's step-up fresh right before the walk.
*/
import {
E2E_SETUP_CHILD,
SETUP_CHILD_STORAGE_STATE_PATH,
} from "./setup/global-setup";
import {
clearManagedProfilesOf,
resetSetupFlow,
stampFreshMfa,
} from "./setup/setup-flow-fixture";
import { expect, test } from "./setup/test";
import {
acceptAndSetUp,
choose,
expectScreen,
next,
readMe,
} from "./setup-flow-helpers";
const PROFILE_NAME = "Setup journey child";
test.describe("setup flow — a child's managed profile", () => {
test.use({ storageState: SETUP_CHILD_STORAGE_STATE_PATH });
test.beforeEach(async () => {
await clearManagedProfilesOf(E2E_SETUP_CHILD.username);
await resetSetupFlow(E2E_SETUP_CHILD.username);
await stampFreshMfa(E2E_SETUP_CHILD.username);
});
test("creates the profile on the confirm screen and offers its record", async ({
page,
}) => {
test.setTimeout(90_000);
await page.goto("/onboarding");
await acceptAndSetUp(page);
await choose(page, "who", ["someone-else"]);
await next(page);
await expectScreen(page, "areas");
await choose(page, "areas", ["blood-pressure"]);
await next(page);
await expectScreen(page, "medication");
await choose(page, "medication", ["no"]);
await next(page);
await expectScreen(page, "sources");
await choose(page, "sources", ["manual"]);
await next(page);
await expectScreen(page, "visit");
await choose(page, "visit", ["no"]);
await next(page);
// The confirm screen is the managed-profile form for this answer.
await expectScreen(page, "confirm");
const managed = page.locator('[data-slot="onboarding-confirm-managed"]');
await expect(managed).toBeVisible();
await managed
.locator('[data-slot="managed-profile-name"]')
.fill(PROFILE_NAME);
await managed
.locator('[data-slot="managed-profile-create-submit"]')
.click();
// No first-result screen for this answer: straight to done, with the new
// record offered.
await expectScreen(page, "done");
await expect(
page.locator('[data-slot="onboarding-open-managed-record"]'),
).toBeVisible({ timeout: 15_000 });
const me = await readMe(page);
expect(me.modules.vaccinations).not.toBe(false);
expect(me.modules.glucose).toBe(false);
expect(me.onboarding.completedAt).not.toBeNull();
expect(
me.onboarding.steps.find((step) => step.id === "first-result")?.status,
).toBe("skipped");
const managedEntries = (me.accountAccess?.accounts ?? []).filter(
(entry) => entry.recordKind === "managed",
);
expect(managedEntries).toHaveLength(1);
await page.locator('[data-slot="onboarding-open-dashboard"]').click();
await expect.poll(() => new URL(page.url()).pathname).toBe("/");
});
});