From 2575c6aea6484baaaf37489d236d3ebaa85dbe9f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 22:35:02 +0100 Subject: [PATCH] test: tighten channel turn context assertions --- src/channels/turn/context.test.ts | 98 ++++++++++++++++--------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/src/channels/turn/context.test.ts b/src/channels/turn/context.test.ts index 24353024f33..e7a66b35dcc 100644 --- a/src/channels/turn/context.test.ts +++ b/src/channels/turn/context.test.ts @@ -125,54 +125,56 @@ describe("buildChannelTurnContext", () => { }, }); - expect(ctx).toEqual( - expect.objectContaining({ - Body: "[User One] hello", - BodyForAgent: "hello", - RawBody: "hello", - CommandBody: "/status", - BodyForCommands: "/status", - From: "test:user:u1", - To: "test:room:room-1", - SessionKey: "agent:main:test:group:room-1", - AccountId: "acct", - ParentSessionKey: "agent:main:test:group", - ModelParentSessionKey: "agent:main:test:model", - MessageSid: "msg-1", - ReplyToId: "root-1", - ReplyToBody: "quoted", - ReplyToSender: "Quoted User", - MediaPath: "/tmp/image.png", - MediaUrl: "/tmp/image.png", - MediaType: "image/png", - MediaPaths: ["/tmp/image.png"], - MediaUrls: ["/tmp/image.png", "https://example.test/audio.mp3"], - MediaTypes: ["image/png", "audio/mpeg"], - MediaTranscribedIndexes: [1], - ChatType: "group", - ConversationLabel: "Room One", - GroupSubject: "Room One", - GroupSpace: "workspace", - GroupSystemPrompt: "group prompt", - SenderName: "User One", - SenderId: "u1", - SenderUsername: "userone", - SenderTag: "User#0001", - MemberRoleIds: ["admin"], - Timestamp: 123, - Provider: "test-provider", - Surface: "test-surface", - WasMentioned: true, - CommandAuthorized: true, - MessageThreadId: "thread-1", - NativeChannelId: "native-room-1", - OriginatingChannel: "test", - OriginatingTo: "test:room:room-1", - ThreadStarterBody: "thread starter", - ThreadHistoryBody: "thread history", - ThreadLabel: "thread label", - }), - ); + const expectedFields = { + Body: "[User One] hello", + BodyForAgent: "hello", + RawBody: "hello", + CommandBody: "/status", + BodyForCommands: "/status", + From: "test:user:u1", + To: "test:room:room-1", + SessionKey: "agent:main:test:group:room-1", + AccountId: "acct", + ParentSessionKey: "agent:main:test:group", + ModelParentSessionKey: "agent:main:test:model", + MessageSid: "msg-1", + ReplyToId: "root-1", + ReplyToBody: "quoted", + ReplyToSender: "Quoted User", + MediaPath: "/tmp/image.png", + MediaUrl: "/tmp/image.png", + MediaType: "image/png", + MediaPaths: ["/tmp/image.png"], + MediaUrls: ["/tmp/image.png", "https://example.test/audio.mp3"], + MediaTypes: ["image/png", "audio/mpeg"], + MediaTranscribedIndexes: [1], + ChatType: "group", + ConversationLabel: "Room One", + GroupSubject: "Room One", + GroupSpace: "workspace", + GroupSystemPrompt: "group prompt", + SenderName: "User One", + SenderId: "u1", + SenderUsername: "userone", + SenderTag: "User#0001", + MemberRoleIds: ["admin"], + Timestamp: 123, + Provider: "test-provider", + Surface: "test-surface", + WasMentioned: true, + CommandAuthorized: true, + MessageThreadId: "thread-1", + NativeChannelId: "native-room-1", + OriginatingChannel: "test", + OriginatingTo: "test:room:room-1", + ThreadStarterBody: "thread starter", + ThreadHistoryBody: "thread history", + ThreadLabel: "thread label", + } as const; + + for (const [key, value] of Object.entries(expectedFields)) { + expect(ctx[key as keyof typeof ctx]).toEqual(value); + } }); it("filters supplemental context with channel visibility policy", () => {