Files
rea/src/domain/browserNetworkEvidence.test.ts
T
morluto 966f7cc84b fix(browser): preserve body API provenance through script export
Label new captured response bytes as Playwright body API results and retain the possibility of a credentialed follow-up load. Preserve legacy representations and source limitations through export without treating body-origin uncertainty as missing event coverage.

Validated source and filesystem boundary tests plus real Chrome CLI and MCP network workflows covering binary, compressed, empty, unfinished, and same-URL responses and profile cleanup.
2026-10-12 14:12:19 +08:00

35 lines
1.0 KiB
TypeScript

import { createHash } from "node:crypto";
import { expect, it } from "vitest";
import { browserNetworkBodySchema } from "./browserNetworkEvidence.js";
const bytes = Buffer.from([0xff, 0, 0xfe]);
const retained = {
state: "captured",
representation: "browser-decoded-response-bytes",
encoding: "base64",
content: bytes.toString("base64"),
bytes: bytes.length,
sha256: createHash("sha256").update(bytes).digest("hex"),
media_type: null,
redacted: false,
};
it("validates the actual retained bytes against canonical base64, count, and digest", () => {
expect(browserNetworkBodySchema.safeParse(retained).success).toBe(true);
expect(
browserNetworkBodySchema.safeParse({
...retained,
representation: "playwright-response-body-bytes",
}).success,
).toBe(true);
for (const mutation of [
{ bytes: 4 },
{ sha256: "0".repeat(64) },
{ content: `${retained.content}\n` },
])
expect(
browserNetworkBodySchema.safeParse({ ...retained, ...mutation }).success,
).toBe(false);
});