test(inbound): share dispatch capture mock across channels

This commit is contained in:
Peter Steinberger
2026-02-21 22:23:02 +00:00
parent be0e0ebf89
commit df35829810
3 changed files with 13 additions and 20 deletions

View File

@@ -1,14 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { buildDispatchInboundContextCapture } from "../../../test/helpers/inbound-contract-capture.js";
import { describe, expect, it } from "vitest";
import { inboundCtxCapture as capture } from "../../../test/helpers/inbound-contract-dispatch-mock.js";
import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js";
import type { MsgContext } from "../../auto-reply/templating.js";
const capture = vi.hoisted(() => ({ ctx: undefined as MsgContext | undefined }));
vi.mock("../../auto-reply/dispatch.js", async (importOriginal) => {
return await buildDispatchInboundContextCapture(importOriginal, capture);
});
import type { DiscordMessagePreflightContext } from "./message-handler.preflight.js";
import { processDiscordMessage } from "./message-handler.process.js";
import { createBaseDiscordMessageContext } from "./message-handler.test-harness.js";

View File

@@ -1,14 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { buildDispatchInboundContextCapture } from "../../../test/helpers/inbound-contract-capture.js";
import { describe, expect, it } from "vitest";
import { inboundCtxCapture as capture } from "../../../test/helpers/inbound-contract-dispatch-mock.js";
import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js";
import type { MsgContext } from "../../auto-reply/templating.js";
const capture = vi.hoisted(() => ({ ctx: undefined as MsgContext | undefined }));
vi.mock("../../auto-reply/dispatch.js", async (importOriginal) => {
return await buildDispatchInboundContextCapture(importOriginal, capture);
});
import { createSignalEventHandler } from "./event-handler.js";
import {
createBaseSignalEventHandlerDeps,

View File

@@ -0,0 +1,9 @@
import { vi } from "vitest";
import { createInboundContextCapture } from "./inbound-contract-capture.js";
import { buildDispatchInboundContextCapture } from "./inbound-contract-capture.js";
export const inboundCtxCapture = createInboundContextCapture();
vi.mock("../../src/auto-reply/dispatch.js", async (importOriginal) => {
return await buildDispatchInboundContextCapture(importOriginal, inboundCtxCapture);
});