




























@@ -208,7 +208,11 @@ function firstRespondCall(respond: ReturnType<typeof vi.fn>) {
208208Record<string, any> | undefined,
209209]
210210>;
211-return calls[0];
211+const call = calls[0];
212+if (!call) {
213+throw new Error("Expected respond call");
214+}
215+return call;
212216}
213217214218function lastDispatchChannelMessageActionCall(): Record<string, any> | undefined {
@@ -218,9 +222,13 @@ function lastDispatchChannelMessageActionCall(): Record<string, any> | undefined
218222return calls.at(-1)?.[0];
219223}
220224221-function pollCall(index = 0): Record<string, any> | undefined {
225+function pollCall(index = 0): Record<string, any> {
222226const calls = mocks.sendPoll.mock.calls as unknown as Array<[Record<string, any>]>;
223-return calls[index]?.[0];
227+const call = calls[index]?.[0];
228+if (!call) {
229+throw new Error(`Expected poll call at index ${index}`);
230+}
231+return call;
224232}
225233226234function outboundRouteCall(index = 0): Record<string, any> | undefined {
@@ -679,9 +687,10 @@ describe("gateway send mirroring", () => {
679687{ connect: { scopes: ["operator.admin"] } },
680688);
681689682-expect(pollCall()?.cfg).toBeDefined();
683-expect(pollCall()?.to).toBe("resolved");
684-expect(pollCall()?.gatewayClientScopes).toEqual(["operator.admin"]);
690+const call = pollCall();
691+expect(call.cfg).toBeDefined();
692+expect(call.to).toBe("resolved");
693+expect(call.gatewayClientScopes).toEqual(["operator.admin"]);
685694});
686695687696it("forwards an empty gateway scope array into outbound poll delivery", async () => {
@@ -696,9 +705,10 @@ describe("gateway send mirroring", () => {
696705{ connect: { scopes: [] } },
697706);
698707699-expect(pollCall()?.cfg).toBeDefined();
700-expect(pollCall()?.to).toBe("resolved");
701-expect(pollCall()?.gatewayClientScopes).toEqual([]);
708+const call = pollCall();
709+expect(call.cfg).toBeDefined();
710+expect(call.to).toBe("resolved");
711+expect(call.gatewayClientScopes).toEqual([]);
702712});
703713704714it("includes optional poll delivery identifiers in the gateway payload", async () => {
@@ -743,10 +753,10 @@ describe("gateway send mirroring", () => {
743753744754expect(mocks.resolveMessageChannelSelection).toHaveBeenCalled();
745755const response = firstRespondCall(respond);
746-expect(response?.[0]).toBe(true);
747-expect(response?.[1]).toBeDefined();
748-expect(response?.[2]).toBeUndefined();
749-expect(response?.[3]).toEqual({ channel: "slack" });
756+expect(response[0]).toBe(true);
757+expect(response[1]).toBeDefined();
758+expect(response[2]).toBeUndefined();
759+expect(response[3]).toEqual({ channel: "slack" });
750760});
751761752762it("returns invalid request when poll channel selection is ambiguous", async () => {
@@ -1313,7 +1323,7 @@ describe("gateway send mirroring", () => {
13131323idempotencyKey: "idem-message-action-media-roots",
13141324});
131513251316-expect(firstRespondCall(respond)?.[0]).toBe(true);
1326+expect(firstRespondCall(respond)[0]).toBe(true);
13171327const actionCall = lastDispatchChannelMessageActionCall();
13181328expect(actionCall?.mediaLocalRoots).toContain(TEST_AGENT_WORKSPACE);
13191329});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。