From 64a9233a96886f823b3a9f5d37ed5af8549f3fd6 Mon Sep 17 00:00:00 2001 From: shankar0123 Date: Mon, 4 May 2026 05:13:03 +0000 Subject: [PATCH] test(web): drop unused mock helpers in client.error.test.ts (CodeQL #3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeQL alert #3 (js/unused-local-variable, severity: Note) flagged mockJsonResponse at web/src/api/client.error.test.ts:39 as dead. Audit: client.error.test.ts is the error-path companion to client.test.ts. Every test in this file drives a non-2xx response through the client function under test via mockErrorResponse (52 call sites). Both mockJsonResponse AND mockBlobResponse were drafted alongside the scaffolding but never used — the success-path coverage lives in client.test.ts, not this file. CodeQL only flagged mockJsonResponse, but mockBlobResponse is the same shape (defined, never called). Cleaning both up for consistency with the file's error-only scope. Replaced with a one-paragraph comment explaining the file's scope so future contributors don't re-add the helpers expecting them to be used. Verified locally: tsc --noEmit: exit 0. grep -c mockJsonResponse + mockBlobResponse: 1 each (the comment mention only). No behavioral change. Reference: https://github.com/certctl-io/certctl/security/code-scanning/3 Closes CodeQL alert #3 (js/unused-local-variable). --- web/src/api/client.error.test.ts | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/web/src/api/client.error.test.ts b/web/src/api/client.error.test.ts index ecfc999..8c4ea98 100644 --- a/web/src/api/client.error.test.ts +++ b/web/src/api/client.error.test.ts @@ -36,23 +36,14 @@ import { const mockFetch = vi.fn(); globalThis.fetch = mockFetch; -function mockJsonResponse(data: unknown, status = 200) { - return Promise.resolve({ - ok: status >= 200 && status < 300, - status, - json: () => Promise.resolve(data), - statusText: 'OK', - } as Response); -} - -function mockBlobResponse(status = 200) { - return Promise.resolve({ - ok: status >= 200 && status < 300, - status, - blob: () => Promise.resolve(new Blob(['test data'])), - statusText: 'OK', - } as Response); -} +// This file is the error-path companion to client.test.ts; every test +// uses mockErrorResponse (defined below) to drive a non-2xx response +// through the client function under test. The success-path +// (mockJsonResponse / mockBlobResponse) helpers were drafted alongside +// this scaffolding but never used — CodeQL alert #3 caught the +// mockJsonResponse leftover. Both helpers were removed for consistency +// with the file's error-only scope; success-path coverage lives in +// client.test.ts. function mockErrorResponse(status: number, body: { message?: string; error?: string } = {}) { return Promise.resolve({