Public: anyone can read this; the crew can change it.
A feed item's age reads as '3h' and its exact time is in the title attribute and a machine-readable datetime #13551
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13539-a-feed-item-s-age-reads-as-3h-and-its-ex → main 1 commit fork 1 thread · 1 unresolved
1 file
changed +30
−0
test/feed-age.test.ts added +30
| @@ -0,0 +1,30 @@ | ||
| 1 | /** | |
| 2 | * A feed item's age reads short ("3h ago") from the request clock; the exact time stays on hover | |
| 3 | * (#13539). | |
| 4 | */ | |
| 5 | import { afterEach, describe, expect, setSystemTime, test } from "bun:test"; | |
| 6 | import type { FeedItem } from "../src/feed/rank.ts"; | |
| 7 | import { feedCard } from "../src/web/studio/feed.ts"; | |
| 8 | ||
| 9 | const at = "2026-03-04T05:06:07.000Z"; | |
| 10 | const item = { id: "e1", kind: "run", app: "alice/notes", actor: "scribe", at, what: "x", reason: "y", link: "/alice/notes/runs/r1" } as FeedItem; | |
| 11 | const hours = (n: number) => new Date(Date.parse(at) + n * 3_600_000 + 60_000); | |
| 12 | ||
| 13 | afterEach(() => setSystemTime()); | |
| 14 | ||
| 15 | describe("feed item age", () => { | |
| 16 | test("reads as a short relative age beside the exact time", () => { | |
| 17 | setSystemTime(hours(3)); | |
| 18 | const text = feedCard(item).text; | |
| 19 | expect(text).toMatch(/<time datetime="2026-03-04T05:06:07\.000Z"\s+title="2026-03-04 05:06 UTC"\s*>3h ago<\/time/); | |
| 20 | }); | |
| 21 | ||
| 22 | test("is rendered from the clock at render time, never frozen", () => { | |
| 23 | setSystemTime(hours(3)); | |
| 24 | expect(feedCard(item).text).toContain(">3h ago<"); | |
| 25 | setSystemTime(hours(30)); | |
| 26 | expect(feedCard(item).text).toContain(">1d ago<"); | |
| 27 | setSystemTime(new Date(Date.parse(at) + 5_000)); | |
| 28 | expect(feedCard(item).text).toContain(">just now<"); | |
| 29 | }); | |
| 30 | }); |
new above
offline
Same FeedItem fixture and time regex as test/feed-time-title.test.ts; share one helper so a wording change is made once.