Files
reverse-engineering-anything/src/browser/CdpResourceContentSize.test.ts
T
morluto 79d2b71896 fix(electron): preserve unknown resource sizes
Use one typed CDP resource-size owner in web and Electron capture. Supplied invalid sizes retain null plus completeness diagnostics; omitted sizes remain unknown without inventing malformed metadata. Preserve other resource facts and valid zero/positive values.

Validation: public CLI regression failed against baseline clamping; 36 focused controls passed after the fix, check:fast and docs:check passed. Fake CDP producer with real CLI/transport and tiny local files; no real Electron/browser or heavy profiling qualification.

Refs #4708
2026-10-17 15:41:07 +08:00

22 lines
570 B
TypeScript

import { expect, it } from "vitest";
import { resourceContentSize } from "./CdpCaptureValues.js";
it.each([
[undefined, null],
[0, 0],
[128, 128],
[0.5, 0.5],
])("preserves optional CDP size %s as %s", (input, value) => {
expect(resourceContentSize(input)).toEqual({ ok: true, value });
});
it.each([-1, null, "4", NaN, Infinity, -Infinity, {}])(
"rejects supplied invalid CDP size %s without inventing zero",
(value) => {
expect(resourceContentSize(value)).toEqual({
ok: false,
error: { _tag: "InvalidCdpResourceSize" },
});
},
);