fix(process): index late scenario events in validation issues (#6160)

Co-authored-by: Abelo9996 <Abelo9996@users.noreply.github.com>
This commit is contained in:
Abel YagubyanandAbelo9996 authored and GitHub committed 2026-10-22 05:53:22 +08:00
1 parent d54c4345d3
commit cbbd317fb5
2 files changed
+29 -2

No files matched your search

@@ -210,3 +210,30 @@ it("applies the selected scrollback budget to every scheduled resize", () => {
}).success,
).toBe(true);
});
it("identifies each event scheduled after the scenario timeout", () => {
const parsed = processScenarioSchema.safeParse({
executable: "/bin/true",
timeout_ms: 1_000,
events: [
{ type: "input", at_ms: 1_000, data: "a" },
{ type: "input", at_ms: 1_500, data: "b" },
{ type: "signal", at_ms: 2_000, signal: "SIGINT" },
],
});
expect(parsed.success).toBe(false);
if (parsed.success) throw new Error("expected late event rejection");
expect(parsed.error.issues).toEqual([
expect.objectContaining({
code: "custom",
path: ["events", 1],
message: "event at 1500 ms occurs after the 1000 ms scenario timeout",
}),
expect.objectContaining({
code: "custom",
path: ["events", 2],
message: "event at 2000 ms occurs after the 1000 ms scenario timeout",
}),
]);
});
+2 -2
View File
@@ -298,8 +298,8 @@ export const processScenarioSchema = z
if (event.at_ms > scenario.timeout_ms) {
context.addIssue({
code: "custom",
message: "event occurs after the scenario timeout",
path: ["events"],
message: `event at ${String(event.at_ms)} ms occurs after the ${String(scenario.timeout_ms)} ms scenario timeout`,
path: ["events", index],
});
}
}