refactor(domain): encode comparison and lifecycle states exactly (#473)
* refactor(domain): encode comparison states exactly * refactor(domain): make evidence lifecycles explicit * refactor(browser): parse capture states once * test: prefer behavior over implementation seams * chore: refresh schema-derived metadata * test(process): preserve lifecycle cleanup coverage * test(hopper): bind rename cache coverage to dispatch
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { fetchWebSourceMaps } from "../../../src/browser/WebSourceMapFetcher.js";
|
||||
import { analyzeWebBundleInputSchema } from "../../../src/domain/webBundleAnalysis.js";
|
||||
import {
|
||||
analyzeWebBundleInputSchema,
|
||||
webSourceMapsSchema,
|
||||
type WebSourceMaps,
|
||||
} from "../../../src/domain/webBundleAnalysis.js";
|
||||
|
||||
const origin = "https://app.example.test";
|
||||
const request = {
|
||||
@@ -10,6 +14,18 @@ const request = {
|
||||
fetchUrl: `${origin}/assets/app.js.map?token=secret`,
|
||||
};
|
||||
|
||||
const expectInvalidSourceMaps = (value: unknown): void => {
|
||||
expect(webSourceMapsSchema.safeParse(value).success).toBe(false);
|
||||
};
|
||||
|
||||
const expectInvalidIncludedSourceMaps = (result: WebSourceMaps): void => {
|
||||
expectInvalidSourceMaps({
|
||||
...result,
|
||||
items: [{ ...result.items[0], artifact: null }],
|
||||
});
|
||||
expectInvalidSourceMaps({ ...result, status: "unavailable" });
|
||||
};
|
||||
|
||||
describe("web source-map fetching and validation", () => {
|
||||
it("fetches without credentials and derives mappings and original modules", async () => {
|
||||
const calls: Array<{ url: string; init: RequestInit | undefined }> = [];
|
||||
@@ -77,6 +93,7 @@ describe("web source-map fetching and validation", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
expectInvalidIncludedSourceMaps(result);
|
||||
});
|
||||
|
||||
it("validates sectioned maps and reports bounded mapping truncation", async () => {
|
||||
@@ -136,6 +153,10 @@ describe("web source-map fetching and validation", () => {
|
||||
status: "unavailable",
|
||||
items: [{ status: "policy_filtered" }],
|
||||
});
|
||||
expectInvalidSourceMaps({
|
||||
...result,
|
||||
items: [{ ...result.items[0], limitation: null }],
|
||||
});
|
||||
});
|
||||
|
||||
it("distinguishes invalid JSON from declared or streamed byte truncation", async () => {
|
||||
|
||||
Reference in New Issue
Block a user