fix(browser): close scenario containment gaps

This commit is contained in:
morluto
2026-07-24 14:40:07 +00:00
parent 83b3368d8d
commit 1bd65f68bc
6 changed files with 206 additions and 78 deletions
+11
View File
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { BrowserScenarioSecrets } from "../src/browser/BrowserScenarioSecrets.js";
import { browserScenarioSchema } from "../src/domain/browserScenario.js";
const secret = (secret_id: string) => ({ source: "secret", secret_id });
@@ -159,6 +160,16 @@ describe("browserScenarioSchema", () => {
]);
});
it("redacts overlapping secrets longest-first", () => {
const scenario = browserScenarioSchema.parse(baseScenario());
const secrets = BrowserScenarioSecrets.resolve(scenario, {
REA_TEST_SESSION: "prefix",
REA_TEST_PASSWORD: "prefix-suffix",
REA_TEST_COOKIE: "cookie",
});
expect(secrets?.redact("prefix-suffix")).toBe("[REDACTED:login_input]");
});
it("rejects unsupported actions", () => {
const scenario = baseScenario();
scenario.actions = [
+2
View File
@@ -10,6 +10,7 @@ describe("PlaywrightScenarioEvents", () => {
it("bounds oversized page errors before validating captured events", () => {
const listeners = new Map<string, (value: Error) => void>();
const page = {
url: () => "https://app.example.test/",
on: (name: string, listener: (value: Error) => void) => {
listeners.set(name, listener);
},
@@ -78,6 +79,7 @@ describe("PlaywrightScenarioEvents", () => {
limits: scenario.limits,
secrets,
budget: new BrowserScenarioCaptureBudget(1, 1_000_000),
allowedOrigins: scenario.allowed_origins,
});
const error = new Error("m".repeat(70_000));
error.stack = "s".repeat(300_000);