perf(test): speed up line, models list, and memory batch

This commit is contained in:
Peter Steinberger
2026-02-14 15:20:35 +00:00
parent 9fb48f4dff
commit 684c18458a
6 changed files with 126 additions and 97 deletions

View File

@@ -1,6 +1,36 @@
import type { MessageEvent } from "@line/bot-sdk";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
// Avoid pulling in globals/pairing/media dependencies; this suite only asserts
// allowlist/groupPolicy gating and message-context wiring.
vi.mock("../globals.js", () => ({
danger: (text: string) => text,
logVerbose: () => {},
}));
vi.mock("../pairing/pairing-labels.js", () => ({
resolvePairingIdLabel: () => "lineUserId",
}));
vi.mock("../pairing/pairing-messages.js", () => ({
buildPairingReply: () => "pairing-reply",
}));
vi.mock("./download.js", () => ({
downloadLineMedia: async () => {
throw new Error("downloadLineMedia should not be called from bot-handlers tests");
},
}));
vi.mock("./send.js", () => ({
pushMessageLine: async () => {
throw new Error("pushMessageLine should not be called from bot-handlers tests");
},
replyMessageLine: async () => {
throw new Error("replyMessageLine should not be called from bot-handlers tests");
},
}));
const { buildLineMessageContextMock, buildLinePostbackContextMock } = vi.hoisted(() => ({
buildLineMessageContextMock: vi.fn(async () => ({
ctxPayload: { From: "line:group:group-1" },