@@ -28,6 +28,13 @@ function makeStartContext<T>(cfg: T, accountId: string, abortSignal: AbortSignal
|
28 | 28 | }; |
29 | 29 | } |
30 | 30 | |
| 31 | +function requireRecord(value: unknown, label: string): Record<string, unknown> { |
| 32 | +if (value === null || typeof value !== "object" || Array.isArray(value)) { |
| 33 | +throw new Error(`expected ${label} to be a record`); |
| 34 | +} |
| 35 | +return value as Record<string, unknown>; |
| 36 | +} |
| 37 | + |
31 | 38 | describe("Synology channel wiring integration", () => { |
32 | 39 | beforeAll(async () => { |
33 | 40 | ({ createSynologyChatPlugin } = await import("./channel.js")); |
@@ -173,14 +180,12 @@ describe("Synology channel wiring integration", () => {
|
173 | 180 | |
174 | 181 | const alphaCtx = finalizeInboundContextMock.mock.calls[0]?.[0]; |
175 | 182 | const betaCtx = finalizeInboundContextMock.mock.calls[1]?.[0]; |
176 | | -expect(alphaCtx).toMatchObject({ |
177 | | -AccountId: "alpha", |
178 | | -SessionKey: "agent:agent-alpha:synology-chat:alpha:direct:123", |
179 | | -}); |
180 | | -expect(betaCtx).toMatchObject({ |
181 | | -AccountId: "beta", |
182 | | -SessionKey: "agent:agent-beta:synology-chat:beta:direct:123", |
183 | | -}); |
| 183 | +const alphaContext = requireRecord(alphaCtx, "alpha inbound context"); |
| 184 | +expect(alphaContext.AccountId).toBe("alpha"); |
| 185 | +expect(alphaContext.SessionKey).toBe("agent:agent-alpha:synology-chat:alpha:direct:123"); |
| 186 | +const betaContext = requireRecord(betaCtx, "beta inbound context"); |
| 187 | +expect(betaContext.AccountId).toBe("beta"); |
| 188 | +expect(betaContext.SessionKey).toBe("agent:agent-beta:synology-chat:beta:direct:123"); |
184 | 189 | |
185 | 190 | alphaAbortController.abort(); |
186 | 191 | betaAbortController.abort(); |
|