mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 21:34:46 +00:00
test: tighten chat abort auth assertions
This commit is contained in:
@@ -6,6 +6,11 @@ import {
|
||||
} from "./chat.abort.test-helpers.js";
|
||||
import { chatHandlers } from "./chat.js";
|
||||
|
||||
type AbortResponsePayload = {
|
||||
aborted?: boolean;
|
||||
runIds?: string[];
|
||||
};
|
||||
|
||||
async function invokeSingleRunAbort({
|
||||
context,
|
||||
runId = "run-1",
|
||||
@@ -55,7 +60,8 @@ describe("chat.abort authorization", () => {
|
||||
const [ok, payload, error] = respond.mock.calls.at(-1) ?? [];
|
||||
expect(ok).toBe(false);
|
||||
expect(payload).toBeUndefined();
|
||||
expect(error).toMatchObject({ code: "INVALID_REQUEST", message: "unauthorized" });
|
||||
expect(error?.code).toBe("INVALID_REQUEST");
|
||||
expect(error?.message).toBe("unauthorized");
|
||||
expect(context.chatAbortControllers.has("run-1")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -78,7 +84,9 @@ describe("chat.abort authorization", () => {
|
||||
|
||||
const [ok, payload] = respond.mock.calls.at(-1) ?? [];
|
||||
expect(ok).toBe(true);
|
||||
expect(payload).toMatchObject({ aborted: true, runIds: ["run-1"] });
|
||||
const abortPayload = payload as AbortResponsePayload | undefined;
|
||||
expect(abortPayload?.aborted).toBe(true);
|
||||
expect(abortPayload?.runIds).toEqual(["run-1"]);
|
||||
expect(context.chatAbortControllers.has("run-1")).toBe(false);
|
||||
});
|
||||
|
||||
@@ -102,7 +110,9 @@ describe("chat.abort authorization", () => {
|
||||
|
||||
const [ok, payload] = respond.mock.calls.at(-1) ?? [];
|
||||
expect(ok).toBe(true);
|
||||
expect(payload).toMatchObject({ aborted: true, runIds: ["run-mine"] });
|
||||
const abortPayload = payload as AbortResponsePayload | undefined;
|
||||
expect(abortPayload?.aborted).toBe(true);
|
||||
expect(abortPayload?.runIds).toEqual(["run-mine"]);
|
||||
expect(context.chatAbortControllers.has("run-mine")).toBe(false);
|
||||
expect(context.chatAbortControllers.has("run-other")).toBe(true);
|
||||
});
|
||||
@@ -119,6 +129,8 @@ describe("chat.abort authorization", () => {
|
||||
|
||||
const [ok, payload] = respond.mock.calls.at(-1) ?? [];
|
||||
expect(ok).toBe(true);
|
||||
expect(payload).toMatchObject({ aborted: true, runIds: ["run-1"] });
|
||||
const abortPayload = payload as AbortResponsePayload | undefined;
|
||||
expect(abortPayload?.aborted).toBe(true);
|
||||
expect(abortPayload?.runIds).toEqual(["run-1"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user