Files
fusion/packages/dashboard/app/utils/__tests__/taskTiming.test.ts
Fusion 3648d1e1df feat(FN-4595): implement cumulative execution timing semantics
Fusion-Task-Id: FN-4595
Fusion-Task-Lineage: 73a3d0ad-5c10-4560-aec5-f9d138deeefd
2026-05-15 07:50:34 -07:00

44 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { getActiveRuntimeMs, getWallClockSinceFirstExecutionMs } from "../taskTiming";
describe("taskTiming helpers", () => {
it("returns persisted plus live segment for in-progress tasks", () => {
const nowMs = Date.parse("2026-05-15T13:16:00.000Z");
const runtime = getActiveRuntimeMs(
{
column: "in-progress",
cumulativeActiveMs: 240_000,
executionStartedAt: "2026-05-15T13:15:00.000Z",
columnMovedAt: "2026-05-15T13:15:00.000Z",
},
nowMs,
);
expect(runtime).toBe(300_000);
});
it("returns null when there is no active-runtime signal", () => {
const runtime = getActiveRuntimeMs(
{
column: "todo",
cumulativeActiveMs: undefined,
executionStartedAt: undefined,
columnMovedAt: undefined,
},
Date.now(),
);
expect(runtime).toBeNull();
});
it("returns wall-clock runtime since first execution", () => {
const wallClock = getWallClockSinceFirstExecutionMs(
"2026-05-15T08:42:00.000Z",
"2026-05-15T13:17:00.000Z",
Date.parse("2026-05-15T13:20:00.000Z"),
);
expect(wallClock).toBe(16_500_000);
});
});