From 9a65a5166fd7424bcf1143629f20554bb9cbf3cb Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 8 Apr 2026 07:03:21 +0100 Subject: [PATCH] test: load narrow Discord inbound context harness --- .../channels/inbound-contract.discord.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/helpers/channels/inbound-contract.discord.ts b/test/helpers/channels/inbound-contract.discord.ts index 472d5de7480..ada975492b5 100644 --- a/test/helpers/channels/inbound-contract.discord.ts +++ b/test/helpers/channels/inbound-contract.discord.ts @@ -1,27 +1,27 @@ import { it } from "vitest"; import { expectChannelInboundContextContract } from "../../../src/channels/plugins/contracts/test-helpers.js"; -import { loadBundledPluginTestApiSync } from "../../../src/test-utils/bundled-plugin-public-surface.js"; +import { resolveRelativeBundledPluginPublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js"; type BuildFinalizedDiscordDirectInboundContext = () => import("../../../src/auto-reply/templating.js").MsgContext; -let buildFinalizedDiscordDirectInboundContextCache: - | BuildFinalizedDiscordDirectInboundContext - | undefined; +const discordInboundContextHarnessModuleId = resolveRelativeBundledPluginPublicModuleId({ + fromModuleUrl: import.meta.url, + pluginId: "discord", + artifactBasename: "src/monitor/inbound-context.test-helpers.js", +}); -function getBuildFinalizedDiscordDirectInboundContext(): BuildFinalizedDiscordDirectInboundContext { - if (!buildFinalizedDiscordDirectInboundContextCache) { - ({ buildFinalizedDiscordDirectInboundContext: buildFinalizedDiscordDirectInboundContextCache } = - loadBundledPluginTestApiSync<{ - buildFinalizedDiscordDirectInboundContext: BuildFinalizedDiscordDirectInboundContext; - }>("discord")); - } - return buildFinalizedDiscordDirectInboundContextCache; +async function getBuildFinalizedDiscordDirectInboundContext(): Promise { + const module = (await import(discordInboundContextHarnessModuleId)) as { + buildFinalizedDiscordDirectInboundContext: BuildFinalizedDiscordDirectInboundContext; + }; + return module.buildFinalizedDiscordDirectInboundContext; } export function installDiscordInboundContractSuite() { - it("keeps inbound context finalized", () => { - const ctx = getBuildFinalizedDiscordDirectInboundContext()(); + it("keeps inbound context finalized", async () => { + const buildContext = await getBuildFinalizedDiscordDirectInboundContext(); + const ctx = buildContext(); expectChannelInboundContextContract(ctx); });