mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 18:51:04 +00:00
test: load narrow Discord inbound context harness
This commit is contained in:
@@ -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<BuildFinalizedDiscordDirectInboundContext> {
|
||||
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user