


























@@ -138,6 +138,19 @@ function requireMockCallArg(mock: ReturnType<typeof vi.fn>, callIndex: number, a
138138return requireRecord(mock.mock.calls[callIndex]?.[argIndex], "mock call argument");
139139}
140140141+function findSchemaEntry(
142+schema: unknown,
143+actions: string[],
144+label: string,
145+): Record<string, unknown> {
146+const entries = requireArray(schema, label);
147+const entry = entries.find((candidate) => {
148+const record = requireRecord(candidate, `${label} entry`);
149+return JSON.stringify(record.actions) === JSON.stringify(actions);
150+});
151+return requireRecord(entry, `${label} ${actions.join(",")} entry`);
152+}
153+141154describe("slackPlugin actions", () => {
142155it("prefers session lookup for announce target routing", () => {
143156expect(slackPlugin.meta.preferSessionLookupForAnnounceTarget).toBe(true);
@@ -158,16 +171,9 @@ describe("slackPlugin actions", () => {
158171159172expect(discovery?.actions).toContain("send");
160173expect(discovery?.capabilities).toContain("presentation");
161-expect(discovery?.schema).toEqual(
162-expect.arrayContaining([
163-expect.objectContaining({
164-actions: ["download-file"],
165-properties: expect.objectContaining({
166-fileId: expect.any(Object),
167-}),
168-}),
169-]),
170-);
174+const downloadFile = findSchemaEntry(discovery?.schema, ["download-file"], "Slack schema");
175+const downloadProperties = requireRecord(downloadFile.properties, "download-file properties");
176+expect(isRecord(downloadProperties.fileId)).toBe(true);
171177});
172178173179it("honors the selected Slack account during message tool discovery", () => {
@@ -296,23 +302,18 @@ describe("slackPlugin actions", () => {
296302},
297303} as OpenClawConfig,
298304});
299-expect(discovery?.schema).toEqual(
300-expect.arrayContaining([
301-expect.objectContaining({
302-actions: ["download-file"],
303-properties: expect.objectContaining({
304-fileId: expect.any(Object),
305-}),
306-}),
307-expect.objectContaining({
308-actions: ["react", "reactions", "edit", "delete", "pin", "unpin"],
309-properties: expect.objectContaining({
310-messageId: expect.any(Object),
311-message_id: expect.any(Object),
312-}),
313-}),
314-]),
305+const downloadFile = findSchemaEntry(discovery?.schema, ["download-file"], "Slack schema");
306+const downloadProperties = requireRecord(downloadFile.properties, "download-file properties");
307+expect(isRecord(downloadProperties.fileId)).toBe(true);
308+309+const messageActions = findSchemaEntry(
310+discovery?.schema,
311+["react", "reactions", "edit", "delete", "pin", "unpin"],
312+"Slack schema",
315313);
314+const messageProperties = requireRecord(messageActions.properties, "message properties");
315+expect(isRecord(messageProperties.messageId)).toBe(true);
316+expect(isRecord(messageProperties.message_id)).toBe(true);
316317});
317318318319it("treats interactive reply payloads as structured Slack payloads", () => {
@@ -486,15 +487,18 @@ describe("slackPlugin status", () => {
486487prevent_creation: true,
487488return_im: true,
488489});
489-expect(route).toMatchObject({
490+expectRecordFields(route, "Slack direct route", {
490491sessionKey: "agent:main:slack:direct:u09g2dj0275:thread:1778110574.653649",
491492baseSessionKey: "agent:main:slack:direct:u09g2dj0275",
492-peer: { kind: "direct", id: "U09G2DJ0275" },
493493chatType: "direct",
494494from: "slack:U09G2DJ0275",
495495to: "user:U09G2DJ0275",
496496threadId: "1778110574.653649",
497497});
498+expectRecordFields(requireRecord(route?.peer, "Slack direct peer"), "Slack direct peer", {
499+kind: "direct",
500+id: "U09G2DJ0275",
501+});
498502});
499503500504it("canonicalizes explicit channel-prefixed Slack IM targets for mirror routing", async () => {
@@ -524,10 +528,17 @@ describe("slackPlugin status", () => {
524528target: "channel:D123",
525529});
526530527-expect(route).toMatchObject({
531+expectRecordFields(route, "Slack explicit IM route", {
528532sessionKey: "agent:main:slack:direct:u123",
529-peer: { kind: "direct", id: "U123" },
530533});
534+expectRecordFields(
535+requireRecord(route?.peer, "Slack explicit IM peer"),
536+"Slack explicit IM peer",
537+{
538+kind: "direct",
539+id: "U123",
540+},
541+);
531542});
532543533544it("skips mirror routing for unresolved Slack IM channel targets", async () => {
@@ -560,13 +571,16 @@ describe("slackPlugin status", () => {
560571target: "G123",
561572});
562573563-expect(route).toMatchObject({
574+expectRecordFields(route, "Slack MPIM route", {
564575sessionKey: "agent:main:slack:group:g123",
565-peer: { kind: "group", id: "G123" },
566576chatType: "channel",
567577from: "slack:group:G123",
568578to: "channel:G123",
569579});
580+expectRecordFields(requireRecord(route?.peer, "Slack MPIM peer"), "Slack MPIM peer", {
581+kind: "group",
582+id: "G123",
583+});
570584});
571585});
572586此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。