test(onboarding): put the setup flow's cases through the finished questionnaire

Two cases in the integration file answered one or two questions and posted
the confirm, which the gate now refuses; they answer or pass all six. The
audit assertion reads the details column as the JSON string it is.
This commit is contained in:
Marc-André Bombeck committed 2026-09-10 12:20:50 +02:00
1 parent 44b6ea01c6
commit f5df6111a1
1 file changed
+10 -3
+10 -3
View File
@@ -333,9 +333,12 @@ describe("POST /api/onboarding/complete", () => {
where: { userId: user.id, action: "user.modules.update" },
});
expect(audit).toHaveLength(1);
expect(
(audit[0].details as { changed?: string[] } | null)?.changed,
).toContain("medications");
const details = JSON.parse(audit[0].details ?? "{}") as {
changed?: string[];
source?: string;
};
expect(details.changed).toContain("medications");
expect(details.source).toBe("onboarding");
// Somebody changes their mind in Settings, then the confirm screen is
// replayed. The second call must leave that decision alone: the latch is
@@ -410,6 +413,10 @@ describe("POST /api/onboarding/complete", () => {
await signIn(user.id);
await patchAnswer({ step: "who", recordTarget: "me" });
await patchAnswer({ step: "areas", areas: ["cycle"] });
await patchAnswer({ step: "medication", status: "skipped" });
await patchAnswer({ step: "sources", status: "skipped" });
await patchAnswer({ step: "visit", status: "skipped" });
await patchAnswer({ step: "units", status: "skipped" });
await postComplete();
const profile = await getPrismaClient().cycleProfile.findUniqueOrThrow({