test: speed up targeted unit suites

This commit is contained in:
Peter Steinberger
2026-03-24 19:31:02 +00:00
parent 698c02e775
commit 4029ce738c
11 changed files with 103 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
import type { MessageEvent, PostbackEvent } from "@line/bot-sdk";
import type { HistoryEntry } from "openclaw/plugin-sdk/reply-history";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { LineAccountConfig } from "./types.js";
// Avoid pulling in globals/pairing/media dependencies; this suite only asserts
@@ -209,8 +209,12 @@ async function startInflightReplayDuplicate(params: {
}
describe("handleLineWebhookEvents", () => {
beforeEach(async () => {
beforeAll(async () => {
vi.resetModules();
({ handleLineWebhookEvents, createLineWebhookReplayCache } = await import("./bot-handlers.js"));
});
beforeEach(() => {
buildLineMessageContextMock.mockReset();
buildLineMessageContextMock.mockImplementation(async () => ({
ctxPayload: { From: "line:group:group-1" },
@@ -225,7 +229,6 @@ describe("handleLineWebhookEvents", () => {
readAllowFromStoreMock.mockImplementation(async () => [] as string[]);
upsertPairingRequestMock.mockReset();
upsertPairingRequestMock.mockImplementation(async () => ({ code: "CODE", created: true }));
({ handleLineWebhookEvents, createLineWebhookReplayCache } = await import("./bot-handlers.js"));
});
it("blocks group messages when groupPolicy is disabled", async () => {
const processMessage = vi.fn();