Skip to content

Commit 11eae6b

Browse files
committed
test: use synthetic message action fixtures
1 parent c1be9ac commit 11eae6b

9 files changed

Lines changed: 204 additions & 198 deletions

src/infra/outbound/message-action-normalization.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { normalizeMessageActionInput } from "./message-action-normalization.js";
44
vi.mock("../../channels/plugins/bootstrap-registry.js", async () => ({
55
getBootstrapChannelPlugin: (
66
await import("./message-action-test-fixtures.js")
7-
).createFeishuMessageActionBootstrapRegistryMock(),
7+
).createPinboardMessageActionBootstrapRegistryMock(),
8+
}));
9+
10+
vi.mock("../../utils/message-channel.js", () => ({
11+
isDeliverableMessageChannel: (value: string) => ["workspace", "forum"].includes(value),
12+
normalizeMessageChannel: (value?: string | null) =>
13+
typeof value === "string" ? value.trim().toLowerCase() : undefined,
814
}));
915

1016
describe("normalizeMessageActionInput", () => {
@@ -66,10 +72,10 @@ describe("normalizeMessageActionInput", () => {
6672
},
6773
toolContext: {
6874
currentChannelId: "C1",
69-
currentChannelProvider: "slack",
75+
currentChannelProvider: "workspace",
7076
},
7177
},
72-
expectedFields: { channel: "slack" },
78+
expectedFields: { channel: "workspace" },
7379
},
7480
{
7581
input: {
@@ -110,7 +116,7 @@ describe("normalizeMessageActionInput", () => {
110116
input: {
111117
action: "pin",
112118
args: {
113-
channel: "feishu",
119+
channel: "pinboard",
114120
messageId: "om_123",
115121
},
116122
},
@@ -121,7 +127,7 @@ describe("normalizeMessageActionInput", () => {
121127
input: {
122128
action: "list-pins",
123129
args: {
124-
channel: "feishu",
130+
channel: "pinboard",
125131
chatId: "oc_123",
126132
},
127133
},
@@ -132,12 +138,12 @@ describe("normalizeMessageActionInput", () => {
132138
input: {
133139
action: "read",
134140
args: {
135-
channel: "slack",
141+
channel: "workspace",
136142
messageId: "123.456",
137143
},
138144
toolContext: {
139145
currentChannelId: "C12345678",
140-
currentChannelProvider: "slack",
146+
currentChannelProvider: "workspace",
141147
},
142148
},
143149
expectedFields: { target: "C12345678", messageId: "123.456" },

src/infra/outbound/message-action-params.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ describe("message action media helpers", () => {
3535
resolveExtraActionMediaSourceParamKeys({
3636
cfg,
3737
action: "send",
38-
channel: "slack",
38+
channel: "workspace",
3939
args: {
40-
channel: "slack",
40+
channel: "workspace",
4141
target: "#C12345678",
4242
message: "hi",
4343
media: "https://example.com/photo.png",
@@ -157,7 +157,7 @@ describe("message action media helpers", () => {
157157
}
158158
});
159159

160-
maybeIt("normalizes Discord event image sandbox media params", async () => {
160+
maybeIt("normalizes extension event image sandbox media params", async () => {
161161
const sandboxRoot = await fs.mkdtemp(path.join(os.tmpdir(), "msg-params-image-"));
162162
try {
163163
const args: Record<string, unknown> = {
@@ -180,7 +180,7 @@ describe("message action media helpers", () => {
180180
}
181181
});
182182

183-
maybeIt("normalizes Matrix avatarPath and avatarUrl sandbox media params", async () => {
183+
maybeIt("normalizes extension avatarPath and avatarUrl sandbox media params", async () => {
184184
const sandboxRoot = await fs.mkdtemp(path.join(os.tmpdir(), "msg-params-avatar-"));
185185
try {
186186
const args: Record<string, unknown> = {
@@ -227,7 +227,7 @@ describe("message action media helpers", () => {
227227
]);
228228
});
229229

230-
maybeIt("normalizes Matrix snake_case avatar_path and avatar_url aliases", async () => {
230+
maybeIt("normalizes extension snake_case avatar_path and avatar_url aliases", async () => {
231231
const sandboxRoot = await fs.mkdtemp(path.join(os.tmpdir(), "msg-params-avatar-snake-"));
232232
try {
233233
const args: Record<string, unknown> = {
@@ -253,7 +253,7 @@ describe("message action media helpers", () => {
253253
}
254254
});
255255

256-
maybeIt("prefers canonical Matrix media params over invalid snake_case aliases", async () => {
256+
maybeIt("prefers canonical extension media params over invalid snake_case aliases", async () => {
257257
const sandboxRoot = await fs.mkdtemp(path.join(os.tmpdir(), "msg-params-avatar-canonical-"));
258258
try {
259259
const args: Record<string, unknown> = {
@@ -369,7 +369,7 @@ describe("message action media helpers", () => {
369369
};
370370
await hydrateAttachmentParamsForAction({
371371
cfg,
372-
channel: "slack",
372+
channel: "workspace",
373373
args: mediaArgs,
374374
action: "sendAttachment",
375375
dryRun: true,
@@ -382,7 +382,7 @@ describe("message action media helpers", () => {
382382
};
383383
await hydrateAttachmentParamsForAction({
384384
cfg,
385-
channel: "slack",
385+
channel: "workspace",
386386
args: fileArgs,
387387
action: "sendAttachment",
388388
dryRun: true,
@@ -398,7 +398,7 @@ describe("message action media helpers", () => {
398398

399399
await hydrateAttachmentParamsForAction({
400400
cfg,
401-
channel: "slack",
401+
channel: "workspace",
402402
args,
403403
action: "sendAttachment",
404404
dryRun: true,
@@ -441,7 +441,7 @@ describe("message action sandbox media hydration", () => {
441441
await expect(
442442
hydrateAttachmentParamsForAction({
443443
cfg,
444-
channel: "slack",
444+
channel: "workspace",
445445
args,
446446
action: "sendAttachment",
447447
mediaPolicy,

0 commit comments

Comments
 (0)