test: remove no-op mock registrars · openclaw/openclaw@0a3e0d0
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Slack tests cover actions.blocks plugin behavior. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | | -import { createSlackEditTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; |
| 3 | +import { createSlackEditTestClient } from "./blocks.test-helpers.js"; |
4 | 4 | |
5 | | -installSlackBlockTestMocks(); |
6 | 5 | const { editSlackMessage } = await import("./actions.js"); |
7 | 6 | const SLACK_TEXT_LIMIT = 8000; |
8 | 7 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,9 +35,6 @@ vi.mock("./accounts.js", async () => {
|
35 | 35 | }; |
36 | 36 | }); |
37 | 37 | |
38 | | -// Kept for compatibility with existing tests; mocks install at module evaluation. |
39 | | -export function installSlackBlockTestMocks() {} |
40 | | - |
41 | 38 | export function createSlackEditTestClient(): SlackEditTestClient { |
42 | 39 | return { |
43 | 40 | chat: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Slack tests cover send.blocks plugin behavior. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | | -import { createSlackSendTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; |
| 3 | +import { createSlackSendTestClient } from "./blocks.test-helpers.js"; |
4 | 4 | import { |
5 | 5 | clearSlackThreadParticipationCache, |
6 | 6 | hasSlackThreadParticipation, |
7 | 7 | } from "./sent-thread-cache.js"; |
8 | 8 | |
9 | | -installSlackBlockTestMocks(); |
10 | 9 | const { sendMessageSlack } = await import("./send.js"); |
11 | 10 | const SLACK_TEST_CFG = { channels: { slack: { botToken: "xoxb-test" } } }; |
12 | 11 | const SLACK_TEXT_LIMIT = 8000; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Slack tests cover send.identity fallback plugin behavior. |
2 | 2 | import { logVerbose } from "openclaw/plugin-sdk/runtime-env"; |
3 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
4 | | -import { createSlackSendTestClient, installSlackBlockTestMocks } from "./blocks.test-helpers.js"; |
| 4 | +import { createSlackSendTestClient } from "./blocks.test-helpers.js"; |
5 | 5 | |
6 | 6 | vi.mock("openclaw/plugin-sdk/runtime-env", () => ({ |
7 | 7 | logVerbose: vi.fn(), |
8 | 8 | danger: (message: string) => message, |
9 | 9 | shouldLogVerbose: () => false, |
10 | 10 | })); |
11 | 11 | |
12 | | -installSlackBlockTestMocks(); |
13 | 12 | const { sendMessageSlack } = await import("./send.js"); |
14 | 13 | const SLACK_TEST_CFG = { channels: { slack: { botToken: "xoxb-test" } } }; |
15 | 14 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Slack tests cover send.upload plugin behavior. |
2 | 2 | import type { WebClient } from "@slack/web-api"; |
3 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | | -import { installSlackBlockTestMocks } from "./blocks.test-helpers.js"; |
| 4 | +import "./blocks.test-helpers.js"; |
5 | 5 | import { |
6 | 6 | clearSlackThreadParticipationCache, |
7 | 7 | hasSlackThreadParticipation, |
8 | 8 | } from "./sent-thread-cache.js"; |
9 | 9 | |
10 | 10 | // --- Module mocks (must precede dynamic import) --- |
11 | | -installSlackBlockTestMocks(); |
12 | 11 | const loadOutboundMediaFromUrlMock = vi.hoisted(() => |
13 | 12 | vi.fn(async (_mediaUrl: string, _options?: unknown) => ({ |
14 | 13 | buffer: Buffer.from("fake-image"), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ import {
|
10 | 10 | registerGetReplyRuntimeOverrides, |
11 | 11 | } from "./get-reply.test-fixtures.js"; |
12 | 12 | import { loadGetReplyModuleForTest } from "./get-reply.test-loader.js"; |
13 | | -import { registerGetReplyCommonMocks } from "./get-reply.test-mocks.js"; |
| 13 | +import "./get-reply.test-mocks.js"; |
14 | 14 | |
15 | 15 | const mocks = vi.hoisted(() => ({ |
16 | 16 | applyMediaUnderstanding: vi.fn(async (..._args: unknown[]) => undefined), |
@@ -22,8 +22,6 @@ const mocks = vi.hoisted(() => ({
|
22 | 22 | initSessionState: vi.fn(), |
23 | 23 | })); |
24 | 24 | |
25 | | -registerGetReplyCommonMocks(); |
26 | | - |
27 | 25 | vi.mock("../../globals.js", () => ({ |
28 | 26 | logVerbose: vi.fn(), |
29 | 27 | })); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -77,6 +77,3 @@ vi.mock("./stage-sandbox-media.runtime.js", () => ({
|
77 | 77 | vi.mock("./typing.js", () => ({ |
78 | 78 | createTypingController: vi.fn(() => createMockTypingController()), |
79 | 79 | })); |
80 | | - |
81 | | -/** Shared placeholder mock registrar for get-reply tests that need common mock imports. */ |
82 | | -export function registerGetReplyCommonMocks(): void {} |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Installs shared runtime mocks used by get-reply test modules. |
2 | 2 | import { vi } from "vitest"; |
3 | | -import { registerGetReplyCommonMocks } from "./get-reply.test-mocks.js"; |
4 | | - |
5 | | -registerGetReplyCommonMocks(); |
| 3 | +import "./get-reply.test-mocks.js"; |
6 | 4 | |
7 | 5 | vi.mock("../../link-understanding/apply.runtime.js", () => ({ |
8 | 6 | applyLinkUnderstanding: vi.fn(async () => undefined), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,9 +2,7 @@
|
2 | 2 | import { Command } from "commander"; |
3 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 4 | import { createIosNodeListResponse } from "./program.nodes-test-helpers.js"; |
5 | | -import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js"; |
6 | | - |
7 | | -installBaseProgramMocks(); |
| 5 | +import { callGateway, runtime } from "./program.test-mocks.js"; |
8 | 6 | |
9 | 7 | let registerNodesCli: typeof import("./nodes-cli.js").registerNodesCli; |
10 | 8 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,9 +3,8 @@ import * as fs from "node:fs/promises";
|
3 | 3 | import { Command } from "commander"; |
4 | 4 | import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
5 | 5 | import { IOS_NODE, createIosNodeListResponse } from "./program.nodes-test-helpers.js"; |
6 | | -import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js"; |
| 6 | +import { callGateway, runtime } from "./program.test-mocks.js"; |
7 | 7 | |
8 | | -installBaseProgramMocks(); |
9 | 8 | let registerNodesCli: typeof import("./nodes-cli.js").registerNodesCli; |
10 | 9 | |
11 | 10 | function getFirstRuntimeLogLine(): string { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。