From b19595c5c8f57bbc85f7ed2b055338b9f8014d48 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 6 Jun 2026 13:44:32 +0530 Subject: [PATCH] test(replay-ui): dedup step/summary fixtures into shared module --- replay-ui/src/__tests__/action-format.test.ts | 12 +----------- replay-ui/src/__tests__/fixtures.ts | 15 +++++++++++++++ replay-ui/src/__tests__/property-status.test.ts | 12 +++++------- replay-ui/src/__tests__/run-history.test.ts | 17 ++--------------- 4 files changed, 23 insertions(+), 33 deletions(-) create mode 100644 replay-ui/src/__tests__/fixtures.ts diff --git a/replay-ui/src/__tests__/action-format.test.ts b/replay-ui/src/__tests__/action-format.test.ts index 17b8cae..fc65fa6 100644 --- a/replay-ui/src/__tests__/action-format.test.ts +++ b/replay-ui/src/__tests__/action-format.test.ts @@ -5,17 +5,7 @@ import { parseSelector, tagFromSelector, } from "../lib/action-format"; -import type { StepSummary } from "../types"; - -function summary(over: Partial): StepSummary { - return { - index: 0, - timestamp: "1970-01-01T00:00:00.000Z", - has_violations: false, - has_exceptions: false, - ...over, - }; -} +import { summary } from "./fixtures"; // Bug class: selector parsing mislabels every action row — splitting on the // wrong colon, treating a value-with-colon as the kind, or dropping the prefix diff --git a/replay-ui/src/__tests__/fixtures.ts b/replay-ui/src/__tests__/fixtures.ts new file mode 100644 index 0000000..1b5e49a --- /dev/null +++ b/replay-ui/src/__tests__/fixtures.ts @@ -0,0 +1,15 @@ +import type { Step, StepSummary } from "../types"; + +export function step(over: Partial): Step { + return { step: 0, timestamp: "1970-01-01T00:00:00.000Z", ...over }; +} + +export function summary(over: Partial): StepSummary { + return { + index: 0, + timestamp: "1970-01-01T00:00:00.000Z", + has_violations: false, + has_exceptions: false, + ...over, + }; +} diff --git a/replay-ui/src/__tests__/property-status.test.ts b/replay-ui/src/__tests__/property-status.test.ts index b2746b0..bf52641 100644 --- a/replay-ui/src/__tests__/property-status.test.ts +++ b/replay-ui/src/__tests__/property-status.test.ts @@ -4,7 +4,7 @@ import { statusFor, statusForStep, } from "../lib/property-status"; -import type { Step } from "../types"; +import { step } from "./fixtures"; // Bug class: RunDetail and ViolationsPanel once carried two copies of this // status logic; if they drift, the same property shows a different verdict in @@ -22,14 +22,12 @@ describe("statusFor", () => { describe("statusForStep", () => { it("matches statusFor for the same step and is pending for a null step", () => { - const step: Step = { - step: 0, - timestamp: "1970-01-01T00:00:00.000Z", + const s = step({ violations: ["v"], residuals: { v: { op: "true" }, h: { op: "true" } }, - }; - expect(statusForStep("v", step)).toBe("violated"); - expect(statusForStep("h", step)).toBe("holds"); + }); + expect(statusForStep("v", s)).toBe("violated"); + expect(statusForStep("h", s)).toBe("holds"); expect(statusForStep("v", null)).toBe("pending"); }); }); diff --git a/replay-ui/src/__tests__/run-history.test.ts b/replay-ui/src/__tests__/run-history.test.ts index 5a678c7..e9bc1d3 100644 --- a/replay-ui/src/__tests__/run-history.test.ts +++ b/replay-ui/src/__tests__/run-history.test.ts @@ -6,21 +6,8 @@ import { statusForProperty, } from "../lib/run-history"; import type { PropertyLane } from "../panels/Timeline"; -import type { Run, Step, StepSummary } from "../types"; - -function step(over: Partial): Step { - return { step: 0, timestamp: "1970-01-01T00:00:00.000Z", ...over }; -} - -function summary(over: Partial): StepSummary { - return { - index: 0, - timestamp: "1970-01-01T00:00:00.000Z", - has_violations: false, - has_exceptions: false, - ...over, - }; -} +import type { Run } from "../types"; +import { step, summary } from "./fixtures"; function lane(name: string, statuses: PropertyLane["statuses"]): PropertyLane { return { name, statuses };