From 4f791220688f45c9cd18f358f1521e9d4a298f58 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 10 Jan 2026 03:14:13 +0000 Subject: [PATCH] test: stabilize gateway mock + lint --- .../gateway.tool-calling.mock-openai.test.ts | 23 +++++++++++-------- src/slack/monitor.ts | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gateway/gateway.tool-calling.mock-openai.test.ts b/src/gateway/gateway.tool-calling.mock-openai.test.ts index 4f8420798..854ce32b5 100644 --- a/src/gateway/gateway.tool-calling.mock-openai.test.ts +++ b/src/gateway/gateway.tool-calling.mock-openai.test.ts @@ -137,16 +137,18 @@ async function* fakeOpenAIResponsesStream( }; } -vi.mock("openai", () => { - class OpenAI { - responses = { - create: async (params: OpenAIResponsesParams) => - fakeOpenAIResponsesStream(params), - }; - } +function installOpenAIMock() { + vi.doMock("openai", () => { + class OpenAI { + responses = { + create: async (params: OpenAIResponsesParams) => + fakeOpenAIResponsesStream(params), + }; + } - return { default: OpenAI }; -}); + return { default: OpenAI }; + }); +} async function getFreePort(): Promise { return await new Promise((resolve, reject) => { @@ -244,6 +246,9 @@ async function connectClient(params: { url: string; token: string }) { describe("gateway (mock openai): tool calling", () => { it("runs a Read tool call end-to-end via gateway agent loop", async () => { + vi.resetModules(); + installOpenAIMock(); + const prev = { home: process.env.HOME, configPath: process.env.CLAWDBOT_CONFIG_PATH, diff --git a/src/slack/monitor.ts b/src/slack/monitor.ts index 11a8a17ce..46413e119 100644 --- a/src/slack/monitor.ts +++ b/src/slack/monitor.ts @@ -45,7 +45,7 @@ import { import { danger, logVerbose, shouldLogVerbose } from "../globals.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; import { getChildLogger } from "../logging.js"; -import { fetchRemoteMedia, type FetchLike } from "../media/fetch.js"; +import { type FetchLike, fetchRemoteMedia } from "../media/fetch.js"; import { saveMediaBuffer } from "../media/store.js"; import { buildPairingReply } from "../pairing/pairing-messages.js"; import {