mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(core): remove duplicate assertions (#122848)
This commit is contained in:
committed by
GitHub
parent
ef0cb2ed95
commit
9b9f2ab403
@@ -99,8 +99,4 @@ describe("isRequesterParentOfBackgroundAcpSession", () => {
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("delegates to isParentOwnedBackgroundAcpSession for target-only checks", () => {
|
||||
expect(isParentOwnedBackgroundAcpSession(backgroundEntry)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,11 +11,8 @@ import {
|
||||
sendJson,
|
||||
sendMethodNotAllowed,
|
||||
sendRateLimited,
|
||||
sendUnauthorized,
|
||||
setDefaultSecurityHeaders,
|
||||
setSseHeaders,
|
||||
watchClientDisconnect,
|
||||
writeDone,
|
||||
} from "./http-common.js";
|
||||
import { makeMockHttpReqRes, makeMockHttpResponse } from "./test-http-response.js";
|
||||
|
||||
@@ -176,20 +173,6 @@ describe("fuzz: sendMethodNotAllowed", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("fuzz: sendUnauthorized", () => {
|
||||
it("is deterministic: always 401 with the canonical error payload", () => {
|
||||
const expected = JSON.stringify({
|
||||
error: { message: "Unauthorized", type: "unauthorized" },
|
||||
});
|
||||
for (let i = 0; i < ITERATIONS; i += 1) {
|
||||
const { res, end } = makeMockHttpResponse();
|
||||
sendUnauthorized(res);
|
||||
expect(res.statusCode).toBe(401);
|
||||
expect(end).toHaveBeenCalledWith(expected);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("fuzz: sendRateLimited", () => {
|
||||
it("sets Retry-After iff retryAfterMs is truthy and > 0, with ceil-seconds value", () => {
|
||||
const rng = makeRng(0x429);
|
||||
@@ -318,42 +301,6 @@ describe("fuzz: readJsonBodyOrError", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("fuzz: writeDone", () => {
|
||||
it("always writes the DONE sentinel exactly once per call", () => {
|
||||
for (let i = 0; i < ITERATIONS; i += 1) {
|
||||
const { res } = makeMockHttpResponse();
|
||||
const write = vi.spyOn(res, "write");
|
||||
writeDone(res);
|
||||
expect(write).toHaveBeenCalledTimes(1);
|
||||
expect(write).toHaveBeenCalledWith("data: [DONE]\n\n");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("fuzz: setSseHeaders", () => {
|
||||
it("sets SSE headers and invokes flushHeaders when present", () => {
|
||||
const rng = makeRng(0x55e);
|
||||
for (let i = 0; i < ITERATIONS; i += 1) {
|
||||
const { res, setHeader } = makeMockHttpResponse();
|
||||
const hasFlush = rng() < 0.5;
|
||||
const flushHeaders = vi.fn();
|
||||
if (hasFlush) {
|
||||
(res as unknown as { flushHeaders: () => void }).flushHeaders = flushHeaders;
|
||||
}
|
||||
setSseHeaders(res);
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(setHeader).toHaveBeenCalledWith("Content-Type", "text/event-stream; charset=utf-8");
|
||||
expect(setHeader).toHaveBeenCalledWith("Cache-Control", "no-cache");
|
||||
expect(setHeader).toHaveBeenCalledWith("Connection", "keep-alive");
|
||||
if (hasFlush) {
|
||||
expect(flushHeaders).toHaveBeenCalledTimes(1);
|
||||
} else {
|
||||
expect(flushHeaders).not.toHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("fuzz: watchClientDisconnect", () => {
|
||||
it("invariants hold for arbitrary socket/controller/callback combinations", () => {
|
||||
const rng = makeRng(0xc105e);
|
||||
|
||||
@@ -9,13 +9,6 @@ import * as shim from "./boundary-file-read.js";
|
||||
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
|
||||
|
||||
describe("root file open shim", () => {
|
||||
it("re-exports the fs-safe root file helpers", () => {
|
||||
expect(shim.canUseRootFileOpen).toBe(upstream.canUseRootFileOpen);
|
||||
expect(shim.matchRootFileOpenFailure).toBe(upstream.matchRootFileOpenFailure);
|
||||
expect(shim.openRootFile).toBe(upstream.openRootFile);
|
||||
expect(shim.openRootFileSync).toBe(upstream.openRootFileSync);
|
||||
});
|
||||
|
||||
it("separates missing, unreadable, and boundary-violating open failures", () => {
|
||||
const messageFor = (failure: upstream.RootFileOpenFailure) =>
|
||||
shim.describeRootFileOpenFailure({
|
||||
|
||||
Reference in New Issue
Block a user