import assert from "node:assert/strict"; import { interviewService } from "../src/services/product-service-clients.js"; const originalFetch = globalThis.fetch; const requests: Array<{ url: string; headers: Headers; body: string }> = []; globalThis.fetch = async (input, init) => { const request = new Request(input, init); requests.push({ url: request.url, headers: request.headers, body: await request.text(), }); return new Response("{}", { status: 200, headers: { "content-type": "application/json" } }); }; try { await interviewService.configure({ user_id: "user_from_payload" }, "user_canonical"); await interviewService.preview({ user_id: "user_from_payload" }, "user_canonical"); await interviewService.editQuestions({ session_id: "session-1", questions: ["q1"] }, "user_canonical"); await interviewService.approve("session-1", "user_canonical"); assert.equal(requests.length, 4); for (const request of requests) { assert.equal(request.headers.get("x-growqr-user"), "user_canonical"); assert.match(request.headers.get("authorization") ?? "", /^Bearer /); } console.log("interview user identity forwarding: all assertions passed"); } finally { globalThis.fetch = originalFetch; }