feat(assessment): record capture hints and keep one window per attempt

This commit is contained in:
shira committed 2026-10-11 13:16:52 +03:00
1 parent c975a0d506
commit bb917bf62e
108 files changed
+6649 -139

No files matched your search

@@ -154,3 +154,37 @@ describe("assessment answer response validation", () => {
]);
});
});
describe("assessment answer command page identifier", () => {
it("sends the open page identifier so a second window is refused, and omits it when there is none", async () => {
const interceptedFetch = globalThis.fetch;
vi.stubGlobal("fetch", (input: string, init?: RequestInit) =>
interceptedFetch(new URL(input, "http://localhost"), init),
);
const clients: Array<string | null> = [];
server.use(
http.post(
`http://localhost/api/v1/me/assessment-attempts/${attemptId}/answers`,
({ request }) => {
clients.push(request.headers.get("X-Attempt-Client"));
return HttpResponse.json(validAttempt, { status: 200 });
},
),
);
const command: PendingAnswerCommand = {
key: "answer-command-key",
body: '{"expected_version":1,"item_id":"item-1","answer":{"format":"number","number":1}}',
itemId: "item-1",
};
const withClient = await submitPendingAnswerCommand(
command,
attemptId,
"csrf-token",
"7mK2pQx9Rt4vWc1Zb8NfYd3Ha6Js0LeG",
);
const withoutClient = await submitPendingAnswerCommand(command, attemptId, "csrf-token");
expect(withClient.kind).toBe("accepted");
expect(withoutClient.kind).toBe("accepted");
expect(clients).toEqual(["7mK2pQx9Rt4vWc1Zb8NfYd3Ha6Js0LeG", null]);
});
});