test(javascript): separate map format and row-limit failures

Use a valid canonical embedded map in the decoder row-budget regression.
The old empty map fails version admission before it can reach the row limit.
Retain that malformed-map case separately and assert typed constraint metadata
for format, external-section and capacity failures from the real codec process.

Validation: source-map source suites and all sixteen physical decoder boundary
tests passed. Static, documentation and test-discovery checks passed.
This commit is contained in:
morluto committed 2026-10-24 02:57:12 +08:00
1 parent 1a38745295
commit 6b56ba2d63
1 file changed
+46 -5
@@ -115,8 +115,16 @@ it("runs the real pinned codec with an independent heap and removes its private
await expect(access(path)).rejects.toMatchObject({ code: "ENOENT" });
});
it.each([
{ text: "{", tag: "AnalysisInputError" },
{
failure: "malformed JSON",
text: "{",
error: {
_tag: "AnalysisInputError",
issues: [{ reason: "invalid_format" }],
},
},
{
failure: "external section",
text: JSON.stringify({
version: 3,
sections: [
@@ -126,19 +134,52 @@ it.each([
},
],
}),
tag: "AnalysisCapabilityUnavailableError",
error: {
_tag: "AnalysisCapabilityUnavailableError",
reason: "unsupported_source_map_profile",
userMessage: expect.stringContaining("https://app.test/external.map"),
},
},
{
failure: "malformed embedded map before row admission",
text: JSON.stringify({
version: 3,
sections: [{ offset: { line: 1000000000, column: 0 }, map: {} }],
}),
tag: "ArtifactOperationError",
error: {
_tag: "AnalysisInputError",
issues: [
{
reason: "invalid_format",
message: expect.stringContaining("not a version 3 map"),
},
],
},
},
])("preserves actual producer failures: $tag", async ({ text, tag }) => {
{
failure: "indexed row limit",
text: JSON.stringify({
version: 3,
sections: [
{
offset: { line: 1000000000, column: 0 },
map: JSON.parse(fixture.sourceMap.text) as unknown,
},
],
}),
error: {
_tag: "ArtifactOperationError",
reason: "limit",
detail: expect.stringContaining("generated-row decoder budget"),
},
},
])("preserves actual producer failures: $failure", async ({ text, error }) => {
const response = await realDecoder().trace({ ...input, text });
if (response.ok) throw new Error("expected failed map");
expect(response.error._tag).toBe(tag);
expect(response.error).toMatchObject({
operation: "trace_web_source_location",
...error,
});
});
it("keeps indexed section overlap typed as a malformed source map", async () => {