test: speed up slack monitor suites

This commit is contained in:
Peter Steinberger
2026-03-24 22:16:24 +00:00
parent d282667321
commit 40ab7aca3d
5 changed files with 7 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { resetInboundDedupe } from "../../../src/auto-reply/reply/inbound-dedupe.js";
import {
flush,
@@ -71,9 +71,11 @@ beforeEach(() => {
resetInboundDedupe();
});
beforeEach(async () => {
vi.resetModules();
beforeAll(async () => {
({ monitorSlackProvider } = await import("./monitor.js"));
});
beforeEach(async () => {
resetInboundDedupe();
resetSlackTestState({
messages: { responsePrefix: "PFX" },

View File

@@ -26,7 +26,6 @@ describe("resolveSlackEffectiveAllowFrom", () => {
const prevTtl = process.env.OPENCLAW_SLACK_PAIRING_ALLOWFROM_CACHE_TTL_MS;
beforeAll(async () => {
vi.resetModules();
({ clearSlackAllowFromCacheForTest, resolveSlackEffectiveAllowFrom } =
await import("./auth.js"));
});

View File

@@ -118,7 +118,6 @@ async function createInFlightMessageScenario(ts: string) {
describe("createSlackMessageHandler app_mention race handling", () => {
beforeAll(async () => {
vi.resetModules();
({ createSlackMessageHandler } = await import("./message-handler.js"));
});

View File

@@ -1,5 +1,5 @@
import type { App } from "@slack/bolt";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../../../../src/config/config.js";
import type { SlackMessageEvent } from "../../types.js";
@@ -48,8 +48,7 @@ function buildChannelMessage(overrides?: Partial<SlackMessageEvent>): SlackMessa
}
describe("thread-level session keys", () => {
beforeEach(async () => {
vi.resetModules();
beforeAll(async () => {
await loadSlackPrepareModules();
});

View File

@@ -185,7 +185,6 @@ let registerSlackMonitorSlashCommands: RegisterFn;
const { dispatchMock } = getSlackSlashMocks();
beforeAll(async () => {
vi.resetModules();
({ registerSlackMonitorSlashCommands } = (await import("./slash.js")) as {
registerSlackMonitorSlashCommands: RegisterFn;
});