test(browser): consolidate CDP and source map coverage

Use shared captures to verify discovery, document identity, screenshot recovery, and source map evidence and cleanup across varied responses. Remove redundant tests and unused fixture controls.
This commit is contained in:
morluto committed 2026-11-18 03:51:31 -05:00
1 parent 1592b7f2c0
commit caedefa00d
19 files changed
+1729 -2195

No files matched your search

+34 -41
View File
@@ -627,48 +627,41 @@ describe("CDP DOM snapshot empty strings", () => {
});
});
it.each([7, null, "without-hash"])(
"retains base URL evidence with malformed fragment %s",
(urlFragment) => {
it("preserves the base URL when fragment syntax is unreadable", () => {
for (const urlFragment of [7, null, "without-hash"]) {
expect(
observeCdpFrameUrl({ url: `${origin}/page?x=1#old`, urlFragment }),
).toEqual({ kind: "invalid_fragment", scopeUrl: `${origin}/page?x=1#old` });
},
);
}
});
it.each([7, "missing-hash"])(
"retains foreign frame scope independently of malformed fragment %s",
(urlFragment) => {
const completeness = new CdpCaptureCompleteness();
const captured = captureFrames(
frameTreeReply({
frameTree: {
frame: { id: "root", url: origin },
childFrames: [
{
frame: {
id: "foreign",
parentId: "root",
url: "https://foreign.test/page",
urlFragment,
},
},
],
},
}),
new Set([origin]),
undefined,
completeness,
);
expect(captured.items.map((frame) => frame.frame_id)).toEqual(["root"]);
expect(completeness.snapshot().excluded).toEqual(
expect.arrayContaining([
{ section: "frames", reason: "invalid_protocol_value", count: 1 },
{ section: "frames", reason: "disallowed_origin", count: 1 },
]),
);
expect(completeness.snapshot().policy_filtered_sections).toContain(
"frames",
);
},
);
it("counts both malformed foreign fragments and their origin exclusions", () => {
const completeness = new CdpCaptureCompleteness();
const captured = captureFrames(
frameTreeReply({
frameTree: {
frame: { id: "root", url: origin },
childFrames: [7, "missing-hash"].map((urlFragment, index) => ({
frame: {
id: `foreign-${index}`,
parentId: "root",
url: `https://foreign.test/page-${index}`,
urlFragment,
},
})),
},
}),
new Set([origin]),
undefined,
completeness,
);
const snapshot = completeness.snapshot();
expect(captured.items.map((frame) => frame.frame_id)).toEqual(["root"]);
expect(snapshot.excluded).toEqual(
expect.arrayContaining([
{ section: "frames", reason: "invalid_protocol_value", count: 2 },
{ section: "frames", reason: "disallowed_origin", count: 2 },
]),
);
expect(snapshot.policy_filtered_sections).toContain("frames");
});