diff --git a/src/gateway/http-common.fuzz.test.ts b/src/gateway/http-common.fuzz.test.ts index eeb5134dc37..57ddfd5dd08 100644 --- a/src/gateway/http-common.fuzz.test.ts +++ b/src/gateway/http-common.fuzz.test.ts @@ -318,7 +318,8 @@ describe("fuzz: readJsonBodyOrError", () => { } const maxBytes = randInt(rng, 1, 1 << 20); - const result = await readJsonBodyOrError(makeRequest(), res, maxBytes); + const req = makeRequest(); + const result = await readJsonBodyOrError(req, res, maxBytes); if (pick === 0) { expect(result).toEqual(expectedValue); } else { @@ -326,7 +327,7 @@ describe("fuzz: readJsonBodyOrError", () => { expect(res.statusCode).toBe(expectedStatus); expect(end).toHaveBeenCalledWith(expectedBody); } - expect(readJsonBodyMock).toHaveBeenLastCalledWith(expect.anything(), maxBytes); + expect(readJsonBodyMock).toHaveBeenLastCalledWith(req, maxBytes); } }); }); diff --git a/src/gateway/http-endpoint-helpers.test.ts b/src/gateway/http-endpoint-helpers.test.ts index 951e4c12cab..36d7c6b7ecf 100644 --- a/src/gateway/http-endpoint-helpers.test.ts +++ b/src/gateway/http-endpoint-helpers.test.ts @@ -107,6 +107,7 @@ describe("handleGatewayPostJsonEndpoint", () => { const mockedSendMissingScopeForbidden = vi.mocked(sendMissingScopeForbidden); mockedSendMissingScopeForbidden.mockClear(); vi.mocked(readJsonBodyOrError).mockClear(); + const res = {} as unknown as ServerResponse; const result = await handleGatewayPostJsonEndpoint( { @@ -114,7 +115,7 @@ describe("handleGatewayPostJsonEndpoint", () => { method: "POST", headers: { host: "localhost" }, } as unknown as IncomingMessage, - {} as unknown as ServerResponse, + res, { pathname: "/v1/ok", auth: {} as unknown as ResolvedGatewayAuth, @@ -127,10 +128,7 @@ describe("handleGatewayPostJsonEndpoint", () => { expect(vi.mocked(authorizeOperatorScopesForMethod)).toHaveBeenCalledWith("chat.send", [ "operator.approvals", ]); - expect(mockedSendMissingScopeForbidden).toHaveBeenCalledWith( - expect.anything(), - "operator.write", - ); + expect(mockedSendMissingScopeForbidden).toHaveBeenCalledWith(res, "operator.write"); expect(vi.mocked(readJsonBodyOrError)).not.toHaveBeenCalled(); }); diff --git a/src/gateway/server.sessions.delete-lifecycle.test.ts b/src/gateway/server.sessions.delete-lifecycle.test.ts index e88a52b7f45..80b971abf82 100644 --- a/src/gateway/server.sessions.delete-lifecycle.test.ts +++ b/src/gateway/server.sessions.delete-lifecycle.test.ts @@ -368,9 +368,9 @@ test("sessions.delete returns unavailable when active run does not stop", async >; expect(store["agent:main:discord:group:dev"]?.sessionId).toBe("sess-active"); const filesAfterDeleteAttempt = await fs.readdir(dir); - expect(filesAfterDeleteAttempt).not.toContainEqual( - expect.stringMatching(/^sess-active\.jsonl\.deleted\./), - ); + expect( + filesAfterDeleteAttempt.filter((fileName) => fileName.startsWith("sess-active.jsonl.deleted.")), + ).toEqual([]); ws.close(); });