























@@ -6,6 +6,11 @@ import {
66} from "./chat.abort.test-helpers.js";
77import { chatHandlers } from "./chat.js";
889+type AbortResponsePayload = {
10+aborted?: boolean;
11+runIds?: string[];
12+};
13+914async function invokeSingleRunAbort({
1015 context,
1116 runId = "run-1",
@@ -55,7 +60,8 @@ describe("chat.abort authorization", () => {
5560const [ok, payload, error] = respond.mock.calls.at(-1) ?? [];
5661expect(ok).toBe(false);
5762expect(payload).toBeUndefined();
58-expect(error).toMatchObject({ code: "INVALID_REQUEST", message: "unauthorized" });
63+expect(error?.code).toBe("INVALID_REQUEST");
64+expect(error?.message).toBe("unauthorized");
5965expect(context.chatAbortControllers.has("run-1")).toBe(true);
6066});
6167@@ -78,7 +84,9 @@ describe("chat.abort authorization", () => {
78847985const [ok, payload] = respond.mock.calls.at(-1) ?? [];
8086expect(ok).toBe(true);
81-expect(payload).toMatchObject({ aborted: true, runIds: ["run-1"] });
87+const abortPayload = payload as AbortResponsePayload | undefined;
88+expect(abortPayload?.aborted).toBe(true);
89+expect(abortPayload?.runIds).toEqual(["run-1"]);
8290expect(context.chatAbortControllers.has("run-1")).toBe(false);
8391});
8492@@ -102,7 +110,9 @@ describe("chat.abort authorization", () => {
102110103111const [ok, payload] = respond.mock.calls.at(-1) ?? [];
104112expect(ok).toBe(true);
105-expect(payload).toMatchObject({ aborted: true, runIds: ["run-mine"] });
113+const abortPayload = payload as AbortResponsePayload | undefined;
114+expect(abortPayload?.aborted).toBe(true);
115+expect(abortPayload?.runIds).toEqual(["run-mine"]);
106116expect(context.chatAbortControllers.has("run-mine")).toBe(false);
107117expect(context.chatAbortControllers.has("run-other")).toBe(true);
108118});
@@ -119,6 +129,8 @@ describe("chat.abort authorization", () => {
119129120130const [ok, payload] = respond.mock.calls.at(-1) ?? [];
121131expect(ok).toBe(true);
122-expect(payload).toMatchObject({ aborted: true, runIds: ["run-1"] });
132+const abortPayload = payload as AbortResponsePayload | undefined;
133+expect(abortPayload?.aborted).toBe(true);
134+expect(abortPayload?.runIds).toEqual(["run-1"]);
123135});
124136});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。