



























@@ -201,10 +201,8 @@ describe("qa-channel plugin", () => {
201201target: "thread:qa-room/thread-1",
202202});
203203204-expect(route).toMatchObject({
205-sessionKey: "agent:main:qa-channel:channel:thread:qa-room/thread-1",
206-baseSessionKey: "agent:main:qa-channel:channel:thread:qa-room/thread-1",
207-});
204+expect(route?.sessionKey).toBe("agent:main:qa-channel:channel:thread:qa-room/thread-1");
205+expect(route?.baseSessionKey).toBe("agent:main:qa-channel:channel:thread:qa-room/thread-1");
208206expect(route?.threadId).toBeUndefined();
209207});
210208@@ -216,12 +214,10 @@ describe("qa-channel plugin", () => {
216214target: "group:qa-room",
217215});
218216219-expect(route).toMatchObject({
220-sessionKey: "agent:main:qa-channel:group:group:qa-room",
221-baseSessionKey: "agent:main:qa-channel:group:group:qa-room",
222-chatType: "group",
223-to: "group:qa-room",
224-});
217+expect(route?.sessionKey).toBe("agent:main:qa-channel:group:group:qa-room");
218+expect(route?.baseSessionKey).toBe("agent:main:qa-channel:group:group:qa-room");
219+expect(route?.chatType).toBe("group");
220+expect(route?.to).toBe("group:qa-room");
225221});
226222227223it("normalizes explicit group targets for session group policy lookup", () => {
@@ -230,11 +226,9 @@ describe("qa-channel plugin", () => {
230226rawId: "group:qa-room",
231227});
232228233-expect(resolved).toMatchObject({
234-id: "qa-room",
235-baseConversationId: "qa-room",
236-parentConversationCandidates: ["qa-room"],
237-});
229+expect(resolved?.id).toBe("qa-room");
230+expect(resolved?.baseConversationId).toBe("qa-room");
231+expect(resolved?.parentConversationCandidates).toEqual(["qa-room"]);
238232});
239233240234it("recovers thread-aware outbound session routes from currentSessionKey", async () => {
@@ -246,11 +240,9 @@ describe("qa-channel plugin", () => {
246240currentSessionKey: "agent:main:qa-channel:channel:channel:qa-room:thread:thread-1",
247241});
248242249-expect(route).toMatchObject({
250-sessionKey: "agent:main:qa-channel:channel:channel:qa-room:thread:thread-1",
251-baseSessionKey: "agent:main:qa-channel:channel:channel:qa-room",
252-threadId: "thread-1",
253-});
243+expect(route?.sessionKey).toBe("agent:main:qa-channel:channel:channel:qa-room:thread:thread-1");
244+expect(route?.baseSessionKey).toBe("agent:main:qa-channel:channel:channel:qa-room");
245+expect(route?.threadId).toBe("thread-1");
254246});
255247256248it('does not recover currentSessionKey threads for shared dmScope "main" DMs', async () => {
@@ -262,10 +254,8 @@ describe("qa-channel plugin", () => {
262254currentSessionKey: "agent:main:main:thread:thread-1",
263255});
264256265-expect(route).toMatchObject({
266-sessionKey: "agent:main:main",
267-baseSessionKey: "agent:main:main",
268-});
257+expect(route?.sessionKey).toBe("agent:main:main");
258+expect(route?.baseSessionKey).toBe("agent:main:main");
269259expect(route?.threadId).toBeUndefined();
270260});
271261@@ -358,18 +348,19 @@ describe("qa-channel plugin", () => {
358348timeoutMs: 15_000,
359349});
360350361-expect(dispatchedCtx).toMatchObject({
362-ChatType: "group",
363-From: "group:qa-room",
364-To: "group:qa-room",
365-SessionKey: "qa-agent:group:group:qa-room",
366-SenderId: "alice",
367-GroupSubject: "QA Room",
368-});
369-expect("conversation" in outbound && outbound.conversation).toMatchObject({
370-id: "qa-room",
371-kind: "group",
372-});
351+const ctx = expectDispatchedContext(dispatchedCtx);
352+expect(ctx.ChatType).toBe("group");
353+expect(ctx.From).toBe("group:qa-room");
354+expect(ctx.To).toBe("group:qa-room");
355+expect(ctx.SessionKey).toBe("qa-agent:group:group:qa-room");
356+expect(ctx.SenderId).toBe("alice");
357+expect(ctx.GroupSubject).toBe("QA Room");
358+expect("conversation" in outbound).toBe(true);
359+if (!("conversation" in outbound)) {
360+throw new Error("expected outbound message conversation");
361+}
362+expect(outbound.conversation.id).toBe("qa-room");
363+expect(outbound.conversation.kind).toBe("group");
373364} finally {
374365await harness.stop();
375366}
@@ -418,7 +409,8 @@ describe("qa-channel plugin", () => {
418409MediaType?: string;
419410MediaTypes?: string[];
420411};
421-expect(mediaCtx.MediaPath).toEqual(expect.stringContaining("red-top-blue-bottom"));
412+expect(typeof mediaCtx.MediaPath).toBe("string");
413+expect(mediaCtx.MediaPath).toContain("red-top-blue-bottom");
422414expect(mediaCtx.MediaType).toBe("image/png");
423415expect(mediaCtx.MediaPaths).toEqual([mediaCtx.MediaPath]);
424416expect(mediaCtx.MediaTypes).toEqual(["image/png"]);
@@ -552,8 +544,8 @@ describe("qa-channel plugin", () => {
552544message: "hello from action",
553545},
554546});
555-const payload = extractToolPayload(result);
556-expect(payload).toMatchObject({ message: { text: "hello from action" } });
547+const payload = extractToolPayload(result) as { message: { text: string } };
548+expect(payload.message.text).toBe("hello from action");
557549558550const outbound = await state.waitFor({
559551kind: "message-text",
@@ -565,7 +557,8 @@ describe("qa-channel plugin", () => {
565557if (!("conversation" in outbound)) {
566558throw new Error("expected outbound message match");
567559}
568-expect(outbound.conversation).toMatchObject({ id: "qa-room", kind: "channel" });
560+expect(outbound.conversation.id).toBe("qa-room");
561+expect(outbound.conversation.kind).toBe("channel");
569562} finally {
570563await bus.stop();
571564}
@@ -589,8 +582,8 @@ describe("qa-channel plugin", () => {
589582message: "hello group",
590583},
591584});
592-const payload = extractToolPayload(result);
593-expect(payload).toMatchObject({ message: { text: "hello group" } });
585+const payload = extractToolPayload(result) as { message: { text: string } };
586+expect(payload.message.text).toBe("hello group");
594587595588const outbound = await state.waitFor({
596589kind: "message-text",
@@ -602,7 +595,8 @@ describe("qa-channel plugin", () => {
602595if (!("conversation" in outbound)) {
603596throw new Error("expected outbound message match");
604597}
605-expect(outbound.conversation).toMatchObject({ id: "qa-room", kind: "group" });
598+expect(outbound.conversation.id).toBe("qa-room");
599+expect(outbound.conversation.kind).toBe("group");
606600} finally {
607601await bus.stop();
608602}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。