feat(browser)!: require the redirect list the CDP capture always writes (#11344)

The CDP capture handler writes redirects on every network request, empty
when the request was not redirected, so the schema requires it and
compare_web_captures no longer substitutes an empty list.

BREAKING CHANGE: browser network requests without redirects are refused as
malformed; recreate the capture.
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 03:38:28 +08:00
1 parent ff6d1d8142
commit cfd2b4bedf
5 files changed
+34 -20

No files matched your search

+17 -2
View File
@@ -50,13 +50,28 @@ const redirectCapture = (resourceType: string | null): WebPageInspection => {
return capture;
};
it("refuses a captured request without its redirect list", () => {
const capture = unselectedShapes(passiveNetworkCapture());
const { redirects: _redirects, ...request } = capture.network.requests[0]!;
const malformed = {
...capture,
network: { ...capture.network, requests: [request] },
};
expect(
browserCaptureComparisonInputSchema.safeParse({
before: { inspection: malformed },
after: { inspection: capture },
}).success,
).toBe(false);
});
describe("nullable redirect resource types", () => {
it.each([true, false])(
"retains uncertainty when a redirect type is omitted (reversed=%s)",
(reversed) => {
const before = redirectCapture("Document");
const after = structuredClone(before);
after.network.requests[0]!.redirects![0]!.resource_type = null;
after.network.requests[0]!.redirects[0]!.resource_type = null;
const [left, right] = reversed
? ([after, before] as const)
: ([before, after] as const);
@@ -73,7 +88,7 @@ describe("nullable redirect resource types", () => {
(resourceType) => {
const before = redirectCapture("Document");
const after = structuredClone(before);
after.network.requests[0]!.redirects![0]!.resource_type = resourceType;
after.network.requests[0]!.redirects[0]!.resource_type = resourceType;
expect(compare(before, after)).toMatchObject({
status: resourceType === "Document" ? "unchanged" : "changed",
total_changes: resourceType === "Document" ? 0 : 1,