feat(web): richer active-job rows on The Floor (source/format/tracks, stage, elapsed, error)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { describeJob } from "./status";
|
||||
import { describeJob, timeAgo } from "./status";
|
||||
|
||||
describe("describeJob", () => {
|
||||
it("maps pipeline states to literal labels + severity kind", () => {
|
||||
@@ -22,3 +22,29 @@ describe("describeJob", () => {
|
||||
expect(describeJob("downloading", "???").step).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("timeAgo", () => {
|
||||
const now = new Date("2026-07-13T12:00:00Z").getTime();
|
||||
|
||||
it("returns 'just now' for deltas under 60s", () => {
|
||||
expect(timeAgo(new Date(now - 30_000).toISOString(), now)).toBe("just now");
|
||||
});
|
||||
|
||||
it("returns minutes for sub-hour deltas", () => {
|
||||
expect(timeAgo(new Date(now - 5 * 60_000).toISOString(), now)).toBe("5m");
|
||||
});
|
||||
|
||||
it("returns hours for sub-day deltas", () => {
|
||||
expect(timeAgo(new Date(now - 2 * 3600_000).toISOString(), now)).toBe("2h");
|
||||
});
|
||||
|
||||
it("returns days for multi-day deltas", () => {
|
||||
expect(timeAgo(new Date(now - 3 * 86_400_000).toISOString(), now)).toBe("3d");
|
||||
});
|
||||
|
||||
it("returns empty string for null/undefined/invalid input", () => {
|
||||
expect(timeAgo(null, now)).toBe("");
|
||||
expect(timeAgo(undefined, now)).toBe("");
|
||||
expect(timeAgo("not-a-date", now)).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user