test(mattermost): slim leaf runtime fixtures

This commit is contained in:
Vincent Koc
2026-04-03 21:20:35 +09:00
parent f0a4423271
commit 7fa0c76ffc
2 changed files with 9 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import { type IncomingMessage, type ServerResponse } from "node:http";
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
import { createPluginRuntimeMock } from "../../../../test/helpers/plugins/plugin-runtime-mock.js";
import type { PluginRuntime } from "../../runtime-api.js";
import { setMattermostRuntime } from "../runtime.js";
import { resolveMattermostAccount } from "./accounts.js";
import type { MattermostClient, MattermostPost } from "./client.js";
@@ -441,13 +441,11 @@ describe("createMattermostInteractionHandler", () => {
options: { sessionKey?: string | null; sessionId?: string | null; userId?: string | null },
) => boolean = () => true,
) {
setMattermostRuntime(
createPluginRuntimeMock({
system: {
enqueueSystemEvent,
},
}),
);
setMattermostRuntime({
system: {
enqueueSystemEvent,
},
} as unknown as PluginRuntime);
}
function createMattermostClientMock(

View File

@@ -3,8 +3,7 @@ import os from "node:os";
import path from "node:path";
import type { ChunkMode } from "openclaw/plugin-sdk/reply-runtime";
import { describe, expect, it, vi } from "vitest";
import { createPluginRuntimeMock } from "../../../../test/helpers/plugins/plugin-runtime-mock.js";
import type { OpenClawConfig } from "../../runtime-api.js";
import type { OpenClawConfig, PluginRuntime } from "../../runtime-api.js";
import { deliverMattermostReplyPayload } from "./reply-delivery.js";
type DeliverMattermostReplyPayloadParams = Parameters<typeof deliverMattermostReplyPayload>[0];
@@ -13,7 +12,7 @@ type ReplyDeliveryMarkdownTableMode = Parameters<
>[1];
function createReplyDeliveryCore(): DeliverMattermostReplyPayloadParams["core"] {
return createPluginRuntimeMock({
return {
channel: {
text: {
chunkByNewline: vi.fn((text: string) => [text]),
@@ -35,7 +34,7 @@ function createReplyDeliveryCore(): DeliverMattermostReplyPayloadParams["core"]
chunkMarkdownTextWithMode: vi.fn((text: string) => [text]),
},
},
});
} as unknown as PluginRuntime;
}
describe("deliverMattermostReplyPayload", () => {