test: harden channel suite isolation

This commit is contained in:
Peter Steinberger
2026-03-23 12:57:02 +00:00
parent 949d6be1d1
commit b393effba6
44 changed files with 431 additions and 213 deletions

View File

@@ -1,10 +1,8 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { MsgContext } from "../../../../src/auto-reply/templating.js";
import { expectChannelInboundContextContract as expectInboundContextContract } from "../../../../src/channels/plugins/contracts/suites.js";
import {
createBaseSignalEventHandlerDeps,
createSignalReceiveEvent,
} from "./event-handler.test-harness.js";
let expectInboundContextContract: typeof import("../../../../src/channels/plugins/contracts/suites.js").expectChannelInboundContextContract;
let createBaseSignalEventHandlerDeps: typeof import("./event-handler.test-harness.js").createBaseSignalEventHandlerDeps;
let createSignalReceiveEvent: typeof import("./event-handler.test-harness.js").createSignalReceiveEvent;
const { sendTypingMock, sendReadReceiptMock, dispatchInboundMessageMock, capture } = vi.hoisted(
() => {
@@ -52,7 +50,12 @@ let createSignalEventHandler: typeof import("./event-handler.js").createSignalEv
describe("signal createSignalEventHandler inbound context", () => {
beforeEach(async () => {
vi.useRealTimers();
vi.resetModules();
({ expectChannelInboundContextContract: expectInboundContextContract } =
await import("../../../../src/channels/plugins/contracts/suites.js"));
({ createBaseSignalEventHandlerDeps, createSignalReceiveEvent } =
await import("./event-handler.test-harness.js"));
({ createSignalEventHandler } = await import("./event-handler.js"));
capture.ctx = undefined;
sendTypingMock.mockReset().mockResolvedValue(true);