mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(replay-ui): pin shared statusFor precedence and ordering
This commit is contained in:
1 parent
9219c529f3
commit
ae5ca403fb
1 file changed
+44
@@ -0,0 +1,44 @@
|
|||||||
|
import { describe, it, expect } from "bun:test";
|
||||||
|
import {
|
||||||
|
STATUS_ORDER,
|
||||||
|
statusFor,
|
||||||
|
statusForStep,
|
||||||
|
} from "../lib/property-status";
|
||||||
|
import type { Step } from "../types";
|
||||||
|
|
||||||
|
// Bug class: RunDetail and ViolationsPanel once carried two copies of this
|
||||||
|
// status logic; if they drift, the same property shows a different verdict in
|
||||||
|
// the timeline vs the violations list. Both panels now share statusFor, so its
|
||||||
|
// precedence and the violated-first ordering must stay pinned.
|
||||||
|
describe("statusFor", () => {
|
||||||
|
it("ranks violated over holds and defaults missing residuals to pending", () => {
|
||||||
|
const violations = new Set(["v"]);
|
||||||
|
expect(statusFor("v", violations, { v: { op: "true" } })).toBe("violated");
|
||||||
|
expect(statusFor("h", violations, { h: { op: "true" } })).toBe("holds");
|
||||||
|
expect(statusFor("p", violations, { p: { op: "false" } })).toBe("pending");
|
||||||
|
expect(statusFor("x", violations, undefined)).toBe("pending");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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",
|
||||||
|
violations: ["v"],
|
||||||
|
residuals: { v: { op: "true" }, h: { op: "true" } },
|
||||||
|
};
|
||||||
|
expect(statusForStep("v", step)).toBe("violated");
|
||||||
|
expect(statusForStep("h", step)).toBe("holds");
|
||||||
|
expect(statusForStep("v", null)).toBe("pending");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("STATUS_ORDER", () => {
|
||||||
|
it("sorts violated before pending before holds", () => {
|
||||||
|
const sorted = ["holds", "violated", "pending"].sort(
|
||||||
|
(a, b) => STATUS_ORDER[a as never] - STATUS_ORDER[b as never],
|
||||||
|
);
|
||||||
|
expect(sorted).toEqual(["violated", "pending", "holds"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user