test(FN-4595): cover legacy backfill and wall-clock timing display
Fusion-Task-Id: FN-4595 Fusion-Task-Lineage: 73a3d0ad-5c10-4560-aec5-f9d138deeefd
This commit is contained in:
@@ -161,7 +161,7 @@ function getInProgressElapsedMs(task: Task, nowMs: number): number | null {
|
|||||||
// inside instrumented code paths. Returns null on legacy tasks that completed
|
// inside instrumented code paths. Returns null on legacy tasks that completed
|
||||||
// before `executionStartedAt` was tracked, so callers can fall back.
|
// before `executionStartedAt` was tracked, so callers can fall back.
|
||||||
function getTaskEndToEndDurationMs(task: Task, nowMs: number): number | null {
|
function getTaskEndToEndDurationMs(task: Task, nowMs: number): number | null {
|
||||||
if (task.cumulativeActiveMs == null && task.firstExecutionAt == null) {
|
if (task.cumulativeActiveMs == null) {
|
||||||
return getEndToEndDurationMs(task.executionStartedAt, task.executionCompletedAt, nowMs);
|
return getEndToEndDurationMs(task.executionStartedAt, task.executionCompletedAt, nowMs);
|
||||||
}
|
}
|
||||||
return getActiveRuntimeMs(task, nowMs);
|
return getActiveRuntimeMs(task, nowMs);
|
||||||
|
|||||||
@@ -2348,6 +2348,26 @@ describe("TaskCard", () => {
|
|||||||
expect(timer?.getAttribute("title")).toBe("Execution time 6m");
|
expect(timer?.getAttribute("title")).toBe("Execution time 6m");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps legacy wall-clock timers after firstExecutionAt migration backfill", () => {
|
||||||
|
const { container } = render(
|
||||||
|
<TaskCard
|
||||||
|
task={makeTask({
|
||||||
|
column: "done",
|
||||||
|
executionStartedAt: "2026-04-25T12:00:00.000Z",
|
||||||
|
executionCompletedAt: "2026-04-25T12:30:00.000Z",
|
||||||
|
firstExecutionAt: "2026-04-25T12:00:00.000Z",
|
||||||
|
cumulativeActiveMs: undefined,
|
||||||
|
})}
|
||||||
|
onOpenDetail={noop}
|
||||||
|
addToast={noop}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const timer = container.querySelector(".card-time-indicator");
|
||||||
|
expect(timer).not.toBeNull();
|
||||||
|
expect(timer?.textContent).toContain("30m");
|
||||||
|
});
|
||||||
|
|
||||||
it.each(["merging", "merging-fix"] as const)("shows live merge elapsed in timer chip while task.status is %s", (status) => {
|
it.each(["merging", "merging-fix"] as const)("shows live merge elapsed in timer chip while task.status is %s", (status) => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
vi.setSystemTime(new Date("2026-04-25T13:45:00.000Z"));
|
vi.setSystemTime(new Date("2026-04-25T13:45:00.000Z"));
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ describe("TaskTokenStatsPanel", () => {
|
|||||||
|
|
||||||
const metric = screen.getByText("Total execution time").closest(".task-token-stats-panel__metric");
|
const metric = screen.getByText("Total execution time").closest(".task-token-stats-panel__metric");
|
||||||
expect(metric).toHaveTextContent("5m 0s");
|
expect(metric).toHaveTextContent("5m 0s");
|
||||||
|
expect(screen.getByText("Wall-clock since first execution")).toBeInTheDocument();
|
||||||
} finally {
|
} finally {
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user