From 988cb1ebfe9224606e30deb426732e525a7e6942 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 26 Apr 2026 18:44:51 -0700 Subject: [PATCH] fix(test): stabilize restart sentinel mocks --- src/gateway/server-restart-sentinel.test.ts | 41 ++++++++++----------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/gateway/server-restart-sentinel.test.ts b/src/gateway/server-restart-sentinel.test.ts index 8fc9ea98f76..cb3288f62c3 100644 --- a/src/gateway/server-restart-sentinel.test.ts +++ b/src/gateway/server-restart-sentinel.test.ts @@ -1,6 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; -import { mergeMockedModule } from "../test-utils/vitest-module-mocks.js"; type LoadedSessionEntry = ReturnType; type RecordInboundSessionAndDispatchReplyParams = Parameters< @@ -158,21 +157,20 @@ vi.mock("../utils/delivery-context.shared.js", () => ({ })); vi.mock("../channels/plugins/index.js", async () => { - return await mergeMockedModule( - await vi.importActual( - "../channels/plugins/index.js", - ), - (actual) => ({ - getChannelPlugin: mocks.getChannelPlugin, - normalizeChannelId: mocks.normalizeChannelId.mockImplementation( - (channel?: string | null) => - actual.normalizeChannelId(channel) ?? - (typeof channel === "string" && channel.trim().length > 0 - ? channel.trim().toLowerCase() - : null), - ), - }), + const actual = await vi.importActual( + "../channels/plugins/index.js", ); + return { + ...actual, + getChannelPlugin: mocks.getChannelPlugin, + normalizeChannelId: mocks.normalizeChannelId.mockImplementation( + (channel?: string | null) => + actual.normalizeChannelId(channel) ?? + (typeof channel === "string" && channel.trim().length > 0 + ? channel.trim().toLowerCase() + : null), + ), + }; }); vi.mock("../infra/outbound/targets.js", () => ({ @@ -198,14 +196,13 @@ vi.mock("../plugin-sdk/inbound-reply-dispatch.js", () => ({ })); vi.mock("../infra/heartbeat-wake.js", async () => { - return await mergeMockedModule( - await vi.importActual( - "../infra/heartbeat-wake.js", - ), - () => ({ - requestHeartbeatNow: mocks.requestHeartbeatNow, - }), + const actual = await vi.importActual( + "../infra/heartbeat-wake.js", ); + return { + ...actual, + requestHeartbeatNow: mocks.requestHeartbeatNow, + }; }); vi.mock("../logging/subsystem.js", () => ({