From 0a3e0d081dc49b1f8ca5b58fd82c7175d5de03ae Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 19 Jun 2026 22:30:27 +0800 Subject: [PATCH] test: remove no-op mock registrars --- extensions/slack/src/actions.blocks.test.ts | 3 +-- extensions/slack/src/blocks.test-helpers.ts | 3 --- extensions/slack/src/send.blocks.test.ts | 3 +-- extensions/slack/src/send.identity-fallback.test.ts | 3 +-- extensions/slack/src/send.upload.test.ts | 3 +-- src/auto-reply/reply/get-reply.message-hooks.test.ts | 4 +--- src/auto-reply/reply/get-reply.test-mocks.ts | 3 --- src/auto-reply/reply/get-reply.test-runtime-mocks.ts | 4 +--- src/cli/program.nodes-basic.e2e.test.ts | 4 +--- src/cli/program.nodes-media.e2e.test.ts | 3 +-- src/cli/program.smoke.test.ts | 5 ----- src/cli/program.test-mocks.ts | 4 ---- 12 files changed, 8 insertions(+), 34 deletions(-) diff --git a/extensions/slack/src/actions.blocks.test.ts b/extensions/slack/src/actions.blocks.test.ts index 63d02c4a10e..8b1c70e8ab7 100644 --- a/extensions/slack/src/actions.blocks.test.ts +++ b/extensions/slack/src/actions.blocks.test.ts @@ -1,8 +1,7 @@ // Slack tests cover actions.blocks plugin behavior. import { describe, expect, it } from "vitest"; -import { createSlackEditTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; +import { createSlackEditTestClient } from "./blocks.test-helpers.js"; -installSlackBlockTestMocks(); const { editSlackMessage } = await import("./actions.js"); const SLACK_TEXT_LIMIT = 8000; diff --git a/extensions/slack/src/blocks.test-helpers.ts b/extensions/slack/src/blocks.test-helpers.ts index 1b3de22fca1..5ad279c4b55 100644 --- a/extensions/slack/src/blocks.test-helpers.ts +++ b/extensions/slack/src/blocks.test-helpers.ts @@ -35,9 +35,6 @@ vi.mock("./accounts.js", async () => { }; }); -// Kept for compatibility with existing tests; mocks install at module evaluation. -export function installSlackBlockTestMocks() {} - export function createSlackEditTestClient(): SlackEditTestClient { return { chat: { diff --git a/extensions/slack/src/send.blocks.test.ts b/extensions/slack/src/send.blocks.test.ts index 913c8fa20da..83c65291162 100644 --- a/extensions/slack/src/send.blocks.test.ts +++ b/extensions/slack/src/send.blocks.test.ts @@ -1,12 +1,11 @@ // Slack tests cover send.blocks plugin behavior. import { describe, expect, it } from "vitest"; -import { createSlackSendTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; +import { createSlackSendTestClient } from "./blocks.test-helpers.js"; import { clearSlackThreadParticipationCache, hasSlackThreadParticipation, } from "./sent-thread-cache.js"; -installSlackBlockTestMocks(); const { sendMessageSlack } = await import("./send.js"); const SLACK_TEST_CFG = { channels: { slack: { botToken: "xoxb-test" } } }; const SLACK_TEXT_LIMIT = 8000; diff --git a/extensions/slack/src/send.identity-fallback.test.ts b/extensions/slack/src/send.identity-fallback.test.ts index ed88ca6a4cf..54d28e6b9fe 100644 --- a/extensions/slack/src/send.identity-fallback.test.ts +++ b/extensions/slack/src/send.identity-fallback.test.ts @@ -1,7 +1,7 @@ // Slack tests cover send.identity fallback plugin behavior. import { logVerbose } from "openclaw/plugin-sdk/runtime-env"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createSlackSendTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; +import { createSlackSendTestClient } from "./blocks.test-helpers.js"; vi.mock("openclaw/plugin-sdk/runtime-env", () => ({ logVerbose: vi.fn(), @@ -9,7 +9,6 @@ vi.mock("openclaw/plugin-sdk/runtime-env", () => ({ shouldLogVerbose: () => false, })); -installSlackBlockTestMocks(); const { sendMessageSlack } = await import("./send.js"); const SLACK_TEST_CFG = { channels: { slack: { botToken: "xoxb-test" } } }; diff --git a/extensions/slack/src/send.upload.test.ts b/extensions/slack/src/send.upload.test.ts index 30d9f98e756..bfc5731527e 100644 --- a/extensions/slack/src/send.upload.test.ts +++ b/extensions/slack/src/send.upload.test.ts @@ -1,14 +1,13 @@ // Slack tests cover send.upload plugin behavior. import type { WebClient } from "@slack/web-api"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { installSlackBlockTestMocks } from "./blocks.test-helpers.js"; +import "./blocks.test-helpers.js"; import { clearSlackThreadParticipationCache, hasSlackThreadParticipation, } from "./sent-thread-cache.js"; // --- Module mocks (must precede dynamic import) --- -installSlackBlockTestMocks(); const loadOutboundMediaFromUrlMock = vi.hoisted(() => vi.fn(async (_mediaUrl: string, _options?: unknown) => ({ buffer: Buffer.from("fake-image"), diff --git a/src/auto-reply/reply/get-reply.message-hooks.test.ts b/src/auto-reply/reply/get-reply.message-hooks.test.ts index 5303f72701b..89c943a4875 100644 --- a/src/auto-reply/reply/get-reply.message-hooks.test.ts +++ b/src/auto-reply/reply/get-reply.message-hooks.test.ts @@ -10,7 +10,7 @@ import { registerGetReplyRuntimeOverrides, } from "./get-reply.test-fixtures.js"; import { loadGetReplyModuleForTest } from "./get-reply.test-loader.js"; -import { registerGetReplyCommonMocks } from "./get-reply.test-mocks.js"; +import "./get-reply.test-mocks.js"; const mocks = vi.hoisted(() => ({ applyMediaUnderstanding: vi.fn(async (..._args: unknown[]) => undefined), @@ -22,8 +22,6 @@ const mocks = vi.hoisted(() => ({ initSessionState: vi.fn(), })); -registerGetReplyCommonMocks(); - vi.mock("../../globals.js", () => ({ logVerbose: vi.fn(), })); diff --git a/src/auto-reply/reply/get-reply.test-mocks.ts b/src/auto-reply/reply/get-reply.test-mocks.ts index df2d45d8b35..8d160d9ec86 100644 --- a/src/auto-reply/reply/get-reply.test-mocks.ts +++ b/src/auto-reply/reply/get-reply.test-mocks.ts @@ -77,6 +77,3 @@ vi.mock("./stage-sandbox-media.runtime.js", () => ({ vi.mock("./typing.js", () => ({ createTypingController: vi.fn(() => createMockTypingController()), })); - -/** Shared placeholder mock registrar for get-reply tests that need common mock imports. */ -export function registerGetReplyCommonMocks(): void {} diff --git a/src/auto-reply/reply/get-reply.test-runtime-mocks.ts b/src/auto-reply/reply/get-reply.test-runtime-mocks.ts index 6adc3a78558..6ebf44fb681 100644 --- a/src/auto-reply/reply/get-reply.test-runtime-mocks.ts +++ b/src/auto-reply/reply/get-reply.test-runtime-mocks.ts @@ -1,8 +1,6 @@ // Installs shared runtime mocks used by get-reply test modules. import { vi } from "vitest"; -import { registerGetReplyCommonMocks } from "./get-reply.test-mocks.js"; - -registerGetReplyCommonMocks(); +import "./get-reply.test-mocks.js"; vi.mock("../../link-understanding/apply.runtime.js", () => ({ applyLinkUnderstanding: vi.fn(async () => undefined), diff --git a/src/cli/program.nodes-basic.e2e.test.ts b/src/cli/program.nodes-basic.e2e.test.ts index 7b6143b9f4c..42ef52f772e 100644 --- a/src/cli/program.nodes-basic.e2e.test.ts +++ b/src/cli/program.nodes-basic.e2e.test.ts @@ -2,9 +2,7 @@ import { Command } from "commander"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { createIosNodeListResponse } from "./program.nodes-test-helpers.js"; -import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js"; - -installBaseProgramMocks(); +import { callGateway, runtime } from "./program.test-mocks.js"; let registerNodesCli: typeof import("./nodes-cli.js").registerNodesCli; diff --git a/src/cli/program.nodes-media.e2e.test.ts b/src/cli/program.nodes-media.e2e.test.ts index dc1d96c2d67..5cf4b33be05 100644 --- a/src/cli/program.nodes-media.e2e.test.ts +++ b/src/cli/program.nodes-media.e2e.test.ts @@ -3,9 +3,8 @@ import * as fs from "node:fs/promises"; import { Command } from "commander"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { IOS_NODE, createIosNodeListResponse } from "./program.nodes-test-helpers.js"; -import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js"; +import { callGateway, runtime } from "./program.test-mocks.js"; -installBaseProgramMocks(); let registerNodesCli: typeof import("./nodes-cli.js").registerNodesCli; function getFirstRuntimeLogLine(): string { diff --git a/src/cli/program.smoke.test.ts b/src/cli/program.smoke.test.ts index 0fbb2934fd7..a35ad24225e 100644 --- a/src/cli/program.smoke.test.ts +++ b/src/cli/program.smoke.test.ts @@ -4,8 +4,6 @@ import { buildProgram } from "./program.js"; import { configureCommand, ensureConfigReady, - installBaseProgramMocks, - installSmokeProgramMocks, runCrestodian, runTui, runtime, @@ -13,9 +11,6 @@ import { setupWizardCommand, } from "./program.test-mocks.js"; -installBaseProgramMocks(); -installSmokeProgramMocks(); - vi.mock("./config-cli.js", () => ({ registerConfigCli: (program: { command: (name: string) => { action: (fn: () => unknown) => void }; diff --git a/src/cli/program.test-mocks.ts b/src/cli/program.test-mocks.ts index 6439cfa7420..f4a4a738d4e 100644 --- a/src/cli/program.test-mocks.ts +++ b/src/cli/program.test-mocks.ts @@ -110,7 +110,3 @@ vi.mock("./program/config-guard.js", () => ({ ensureConfigReady: programMocks.ensureConfigReady, })); vi.mock("./preaction.js", () => ({ registerPreActionHooks: () => {} })); - -export function installBaseProgramMocks() {} - -export function installSmokeProgramMocks() {}