test: tighten qa credential fetch assertion

This commit is contained in:
Shakker
2026-05-08 20:29:21 +01:00
parent f8187cadc8
commit 2187f98434

View File

@@ -16,6 +16,15 @@ function jsonResponse(payload: unknown, status = 200) {
});
}
function requireFirstFetchInput(fetchImpl: ReturnType<typeof vi.fn>): RequestInfo | URL {
const input = fetchImpl.mock.calls[0]?.[0] as RequestInfo | URL | undefined;
expect(input).toBeDefined();
if (!input) {
throw new Error("expected fetch input");
}
return input;
}
describe("qa credential admin runtime", () => {
it("adds a credential set through the admin endpoint", async () => {
const fetchImpl = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
@@ -112,7 +121,9 @@ describe("qa credential admin runtime", () => {
fetchImpl,
});
expect(fetchImpl.mock.calls[0]?.[0]).toBe("http://127.0.0.1:3210/qa-credentials/v1/admin/list");
expect(requireFirstFetchInput(fetchImpl)).toBe(
"http://127.0.0.1:3210/qa-credentials/v1/admin/list",
);
});
it("rejects unsafe endpoint-prefix overrides", async () => {