mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
fix(browser-scenario): summarize all captured numeric statuses (#9936)
* fix(browser-scenario): summarize all captured numeric statuses * test(browser-scenario): position status regression before view groups
This commit is contained in:
1 parent
77100250de
commit
914363fbfb
2 files changed
+73
-12
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { Ajv2020 } from "ajv/dist/2020.js";
|
||||
import { z } from "zod";
|
||||
|
||||
import { ANALYSIS_VIEW_TOOL_CONTRACTS } from "../../contracts/analysisViewToolContracts.js";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
@@ -79,6 +83,57 @@ const view = async (
|
||||
return projected.value.normalized_result as Record<string, unknown>;
|
||||
};
|
||||
|
||||
it("summarizes every three-digit status bucket within the advertised output contract", async () => {
|
||||
const contract = ANALYSIS_VIEW_TOOL_CONTRACTS.find(
|
||||
({ name }) => name === "inspect_analysis_view",
|
||||
);
|
||||
if (contract === undefined)
|
||||
throw new Error("Missing inspect_analysis_view contract");
|
||||
const validateOutput = new Ajv2020({
|
||||
strict: false,
|
||||
validateFormats: false,
|
||||
inlineRefs: false,
|
||||
code: { optimize: false },
|
||||
}).compile(z.toJSONSchema(contract.outputSchema));
|
||||
for (const [status, statusClass] of [
|
||||
[100, "1xx"],
|
||||
[200, "2xx"],
|
||||
[300, "3xx"],
|
||||
[400, "4xx"],
|
||||
[599, "5xx"],
|
||||
[600, "6xx"],
|
||||
[700, "7xx"],
|
||||
[800, "8xx"],
|
||||
[999, "9xx"],
|
||||
] as const) {
|
||||
const capture = scenarioCaptureFixture([
|
||||
{ method: "GET", url: "/status", status },
|
||||
]);
|
||||
const original = JSON.stringify(capture);
|
||||
const result = await inspectAnalysisView({
|
||||
source: { kind: "inline", evidence: scenarioCaptureEvidence(capture) },
|
||||
view: { kind: "summary" },
|
||||
});
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.normalized_result).toMatchObject({
|
||||
summary: {
|
||||
network: {
|
||||
by_status_class: [{ status_class: statusClass, transactions: 1 }],
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(contract.outputSchema.safeParse(result.value).success).toBe(true);
|
||||
expect(
|
||||
validateOutput(result.value),
|
||||
JSON.stringify(validateOutput.errors),
|
||||
).toBe(true);
|
||||
expect(JSON.stringify(capture)).toBe(original);
|
||||
expect(capture.events.items).toContainEqual(
|
||||
expect.objectContaining({ kind: "response", status }),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
describe("browser scenario analysis views", () => {
|
||||
it("counts inherited Evidence limitations alongside capture-local caveats", async () => {
|
||||
const capture = scenarioCaptureFixture();
|
||||
|
||||
Reference in new issue
Block a user