test: migrate suites to e2e coverage layout

This commit is contained in:
Peter Steinberger
2026-02-13 14:28:12 +00:00
parent f5160ca6be
commit 9131b22a28
329 changed files with 1455 additions and 1077 deletions

View File

@@ -3,6 +3,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
const dispatchMock = vi.fn();
const readAllowFromMock = vi.fn();
vi.mock("../auto-reply/dispatch.js", () => ({
dispatchInboundMessage: (...args: unknown[]) => dispatchMock(...args),
dispatchInboundMessageWithDispatcher: (...args: unknown[]) => dispatchMock(...args),
dispatchInboundMessageWithBufferedDispatcher: (...args: unknown[]) => dispatchMock(...args),
}));
vi.mock("../pairing/pairing-store.js", () => ({
readChannelAllowFromStore: (...args: unknown[]) => readAllowFromMock(...args),
upsertChannelPairingRequest: vi.fn(),
@@ -19,10 +25,6 @@ describe("signal event handler sender prefix", () => {
it("prefixes group bodies with sender label", async () => {
let capturedBody = "";
const dispatchModule = await import("../auto-reply/dispatch.js");
vi.spyOn(dispatchModule, "dispatchInboundMessage").mockImplementation(
async (...args: unknown[]) => dispatchMock(...args),
);
dispatchMock.mockImplementationOnce(async ({ dispatcher, ctx }) => {
capturedBody = ctx.Body ?? "";
dispatcher.sendFinalReply({ text: "ok" });

View File

@@ -2,6 +2,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
const sendTypingMock = vi.fn();
const sendReadReceiptMock = vi.fn();
const dispatchInboundMessageMock = vi.fn(
async (params: { replyOptions?: { onReplyStart?: () => void } }) => {
await Promise.resolve(params.replyOptions?.onReplyStart?.());
return { queuedFinal: false, counts: { tool: 0, block: 0, final: 0 } };
},
);
vi.mock("./send.js", () => ({
sendMessageSignal: vi.fn(),
@@ -9,21 +15,12 @@ vi.mock("./send.js", () => ({
sendReadReceiptSignal: (...args: unknown[]) => sendReadReceiptMock(...args),
}));
vi.mock("../auto-reply/dispatch.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../auto-reply/dispatch.js")>();
const dispatchInboundMessage = vi.fn(
async (params: { replyOptions?: { onReplyStart?: () => void } }) => {
await Promise.resolve(params.replyOptions?.onReplyStart?.());
return { queuedFinal: false, counts: { tool: 0, block: 0, final: 0 } };
},
);
return {
...actual,
dispatchInboundMessage,
dispatchInboundMessageWithDispatcher: dispatchInboundMessage,
dispatchInboundMessageWithBufferedDispatcher: dispatchInboundMessage,
};
});
vi.mock("../auto-reply/dispatch.js", () => ({
dispatchInboundMessage: (...args: unknown[]) => dispatchInboundMessageMock(...args),
dispatchInboundMessageWithDispatcher: (...args: unknown[]) => dispatchInboundMessageMock(...args),
dispatchInboundMessageWithBufferedDispatcher: (...args: unknown[]) =>
dispatchInboundMessageMock(...args),
}));
vi.mock("../pairing/pairing-store.js", () => ({
readChannelAllowFromStore: vi.fn().mockResolvedValue([]),
@@ -35,10 +32,10 @@ describe("signal event handler typing + read receipts", () => {
vi.useRealTimers();
sendTypingMock.mockReset().mockResolvedValue(true);
sendReadReceiptMock.mockReset().mockResolvedValue(true);
dispatchInboundMessageMock.mockClear();
});
it("sends typing + read receipt for allowed DMs", async () => {
vi.resetModules();
const { createSignalEventHandler } = await import("./monitor/event-handler.js");
const handler = createSignalEventHandler({
// oxlint-disable-next-line typescript/no-explicit-any