mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
"Someone I look after" derived the child's answers onto the guardian's own record. The completion now takes the managed record the profile step just created, checks the same access rule the guardian's modules route applies, and lands the same derivation and dashboard seed on that record through the same record-keyed write; the guardian's own flow is stamped complete and latched without touching its map. Three integration cases pin it, and the child journey reads the child's map through a real switch — it asserted the guardian's map before, which pinned the wrong record. Also from the review: the checklist's visit row read a meta the visits list never publishes and now counts its body; the first-result tile read the measurements list as an array and now shows the reading; the demo allowlist admits the disclaimer and tour writes, with a structural test over every onboarding route file; restart clears the old first result, and the screen trusts the ledger before painting a result as done; the headroom sweep's raw-key check matches the flow's own key shapes; the demo migration script stops copying the dropped column; the questions-to-pass rule and the shell's onboarding-path rule are pure and pinned; the baseline form composes the shared action row; the schema diff loses the unrelated formatting churn.
103 lines
3.7 KiB
TypeScript
103 lines
3.7 KiB
TypeScript
/**
|
|
* v1.39 (C2) — the setup flow, path 3: a doctor's visit within a month, with
|
|
* lab results.
|
|
*
|
|
* The visit answer is what switches the doctor report on and puts "prepare
|
|
* the visit" on the checklist; the labs area has no inline form, so the
|
|
* first-result screen points at the labs page and takes the person's word
|
|
* that the first entry was made.
|
|
*/
|
|
import {
|
|
E2E_SETUP_VISIT,
|
|
SETUP_VISIT_STORAGE_STATE_PATH,
|
|
} from "./setup/global-setup";
|
|
import { resetSetupFlow } from "./setup/setup-flow-fixture";
|
|
import { expect, test } from "./setup/test";
|
|
import {
|
|
acceptAndSetUp,
|
|
choose,
|
|
expectScreen,
|
|
next,
|
|
readMe,
|
|
} from "./setup-flow-helpers";
|
|
|
|
test.describe("setup flow — a visit within a month, with labs", () => {
|
|
test.use({ storageState: SETUP_VISIT_STORAGE_STATE_PATH });
|
|
|
|
test.beforeEach(async () => {
|
|
await resetSetupFlow(E2E_SETUP_VISIT.username);
|
|
});
|
|
|
|
test("switches the report on and puts the visit on the checklist", async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(90_000);
|
|
|
|
await page.goto("/onboarding");
|
|
await acceptAndSetUp(page);
|
|
|
|
await choose(page, "who", ["me"]);
|
|
await next(page);
|
|
await expectScreen(page, "areas");
|
|
await choose(page, "areas", ["labs"]);
|
|
await next(page);
|
|
await expectScreen(page, "medication");
|
|
await choose(page, "medication", ["no"]);
|
|
await next(page);
|
|
await expectScreen(page, "sources");
|
|
await choose(page, "sources", ["file"]);
|
|
await next(page);
|
|
await expectScreen(page, "visit");
|
|
await choose(page, "visit", ["within-a-month"]);
|
|
await next(page);
|
|
|
|
await expectScreen(page, "confirm");
|
|
await next(page);
|
|
|
|
await expectScreen(page, "first-result");
|
|
const screen = page.locator("section[data-task]");
|
|
await expect(screen).toHaveAttribute("data-task", "log-reading");
|
|
await expect(screen).toHaveAttribute("data-target", "labs");
|
|
await expect(
|
|
page.locator('[data-slot="onboarding-task-reading-link"]'),
|
|
).toBeVisible();
|
|
await page.locator('[data-slot="onboarding-reading-done"]').click();
|
|
await expect(
|
|
page.locator('[data-slot="onboarding-first-result-done"]'),
|
|
).toBeVisible();
|
|
await next(page);
|
|
|
|
await expectScreen(page, "done");
|
|
await page.locator('[data-slot="onboarding-open-dashboard"]').click();
|
|
await expect.poll(() => new URL(page.url()).pathname).toBe("/");
|
|
|
|
// The checklist opens with the visit row on it, not yet done.
|
|
const checklist = page.locator('[data-testid="onboarding-card"]');
|
|
await expect(checklist).toBeVisible({ timeout: 15_000 });
|
|
await expect(checklist.locator("#getting-started-body")).toBeVisible();
|
|
const visitRow = checklist.locator('li[data-item-id="visit"]');
|
|
await expect(visitRow).toHaveAttribute("data-done", "false");
|
|
await expect(visitRow.locator('a[href="/checkups"]')).toBeVisible();
|
|
|
|
// Book the visit; the row reads the visits list's own body and flips.
|
|
const booked = await page.request.post("/api/encounters", {
|
|
data: {
|
|
occurredAt: new Date(Date.now() + 7 * 86_400_000).toISOString(),
|
|
status: "PLANNED",
|
|
},
|
|
});
|
|
expect(booked.status(), "booking the visit").toBe(201);
|
|
await page.reload({ waitUntil: "domcontentloaded" });
|
|
await expect(
|
|
page.locator('[data-testid="onboarding-card"] li[data-item-id="visit"]'),
|
|
).toHaveAttribute("data-done", "true", { timeout: 15_000 });
|
|
|
|
const me = await readMe(page);
|
|
expect(me.modules.labs).not.toBe(false);
|
|
expect(me.modules.doctorReport).not.toBe(false);
|
|
expect(me.modules.medications).toBe(false);
|
|
expect(me.onboarding.firstResult?.task).toBe("log-reading");
|
|
expect(me.onboarding.firstResult?.completedAt).not.toBeNull();
|
|
});
|
|
});
|