mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:20:43 +00:00
test: share outbound action mock fixture
This commit is contained in:
@@ -1,21 +1,10 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { normalizeMessageActionInput } from "./message-action-normalization.js";
|
||||
|
||||
vi.mock("../../channels/plugins/bootstrap-registry.js", () => ({
|
||||
getBootstrapChannelPlugin: (channel: string) =>
|
||||
channel === "feishu"
|
||||
? {
|
||||
actions: {
|
||||
messageActionTargetAliases: {
|
||||
read: { aliases: ["messageId"] },
|
||||
pin: { aliases: ["messageId"] },
|
||||
unpin: { aliases: ["messageId"] },
|
||||
"list-pins": { aliases: ["chatId"] },
|
||||
"channel-info": { aliases: ["chatId"] },
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
vi.mock("../../channels/plugins/bootstrap-registry.js", async () => ({
|
||||
getBootstrapChannelPlugin: (
|
||||
await import("./message-action-test-fixtures.js")
|
||||
).createFeishuMessageActionBootstrapRegistryMock(),
|
||||
}));
|
||||
|
||||
describe("normalizeMessageActionInput", () => {
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { actionHasTarget, actionRequiresTarget } from "./message-action-spec.js";
|
||||
|
||||
vi.mock("../../channels/plugins/bootstrap-registry.js", () => ({
|
||||
getBootstrapChannelPlugin: (channel: string) =>
|
||||
channel === "feishu"
|
||||
? {
|
||||
actions: {
|
||||
messageActionTargetAliases: {
|
||||
read: { aliases: ["messageId"] },
|
||||
pin: { aliases: ["messageId"] },
|
||||
unpin: { aliases: ["messageId"] },
|
||||
"list-pins": { aliases: ["chatId"] },
|
||||
"channel-info": { aliases: ["chatId"] },
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
vi.mock("../../channels/plugins/bootstrap-registry.js", async () => ({
|
||||
getBootstrapChannelPlugin: (
|
||||
await import("./message-action-test-fixtures.js")
|
||||
).createFeishuMessageActionBootstrapRegistryMock(),
|
||||
}));
|
||||
|
||||
describe("actionRequiresTarget", () => {
|
||||
|
||||
16
src/infra/outbound/message-action-test-fixtures.ts
Normal file
16
src/infra/outbound/message-action-test-fixtures.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export function createFeishuMessageActionBootstrapRegistryMock() {
|
||||
return (channel: string) =>
|
||||
channel === "feishu"
|
||||
? {
|
||||
actions: {
|
||||
messageActionTargetAliases: {
|
||||
read: { aliases: ["messageId"] },
|
||||
pin: { aliases: ["messageId"] },
|
||||
unpin: { aliases: ["messageId"] },
|
||||
"list-pins": { aliases: ["chatId"] },
|
||||
"channel-info": { aliases: ["chatId"] },
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user