test: tighten channel turn context assertions

This commit is contained in:
Peter Steinberger
2026-05-09 22:35:02 +01:00
parent 56d58f21e0
commit 2575c6aea6

View File

@@ -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", () => {