test: speed up channel probe tests

This commit is contained in:
Peter Steinberger
2026-04-07 13:36:41 +01:00
parent b747e0c34d
commit 46db833772
3 changed files with 6 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { clearProbeCache, FEISHU_PROBE_REQUEST_TIMEOUT_MS, probeFeishu } from "./probe.js";
const createFeishuClientMock = vi.hoisted(() => vi.fn());
@@ -6,10 +7,6 @@ vi.mock("./client.js", () => ({
createFeishuClient: createFeishuClientMock,
}));
let FEISHU_PROBE_REQUEST_TIMEOUT_MS: typeof import("./probe.js").FEISHU_PROBE_REQUEST_TIMEOUT_MS;
let probeFeishu: typeof import("./probe.js").probeFeishu;
let clearProbeCache: typeof import("./probe.js").clearProbeCache;
const DEFAULT_CREDS = { appId: "cli_123", appSecret: "secret" } as const; // pragma: allowlist secret
const DEFAULT_SUCCESS_RESPONSE = {
code: 0,
@@ -100,11 +97,6 @@ async function readSequentialDefaultProbePair() {
}
describe("probeFeishu", () => {
beforeAll(async () => {
({ FEISHU_PROBE_REQUEST_TIMEOUT_MS, probeFeishu, clearProbeCache } =
await import("./probe.js"));
});
beforeEach(() => {
clearProbeCache();
vi.restoreAllMocks();

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { probeIrc } from "./probe.js";
const resolveIrcAccountMock = vi.hoisted(() => vi.fn());
const buildIrcConnectOptionsMock = vi.hoisted(() => vi.fn());
@@ -16,13 +17,7 @@ vi.mock("./client.js", () => ({
connectIrcClient: connectIrcClientMock,
}));
let probeIrc: typeof import("./probe.js").probeIrc;
describe("probeIrc", () => {
beforeAll(async () => {
({ probeIrc } = await import("./probe.js"));
});
beforeEach(() => {
resolveIrcAccountMock.mockReset();
buildIrcConnectOptionsMock.mockReset();

View File

@@ -1,4 +1,5 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { probeSlack } from "./probe.js";
const authTestMock = vi.hoisted(() => vi.fn());
const createSlackWebClientMock = vi.hoisted(() => vi.fn());
@@ -12,13 +13,7 @@ vi.mock("openclaw/plugin-sdk/text-runtime", () => ({
withTimeout: withTimeoutMock,
}));
let probeSlack: typeof import("./probe.js").probeSlack;
describe("probeSlack", () => {
beforeAll(async () => {
({ probeSlack } = await import("./probe.js"));
});
beforeEach(() => {
authTestMock.mockReset();
createSlackWebClientMock.mockReset();