|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { resolve } from "node:path"; |
| 4 | + |
| 5 | +const sidebarSrc = readFileSync( |
| 6 | + resolve(__dirname, "../../apps/desktop/src/app/shell/AppSidebar.tsx"), |
| 7 | + "utf-8", |
| 8 | +); |
| 9 | + |
| 10 | +describe("Chat sidebar – uniform timestamps", () => { |
| 11 | + // AC1 & AC2: All chat entries in "Today" and "Yesterday" groups show creation timestamps |
| 12 | + it("shows timestamps for recent entries (Today/Yesterday) regardless of duplicates", () => { |
| 13 | + // The timestamp assignment should include isRecent as a condition |
| 14 | + // so entries in Today/Yesterday always get a timestamp |
| 15 | + expect(sidebarSrc).toMatch(/isRecent\s*\|\|\s*duplicateLabels\.has/); |
| 16 | + }); |
| 17 | + |
| 18 | + // AC3: Entries in older date groups show timestamps only for duplicate labels |
| 19 | + it("preserves duplicate-only timestamp logic for older groups via duplicateLabels.has", () => { |
| 20 | + // duplicateLabels.has should still be present (not removed) |
| 21 | + expect(sidebarSrc).toContain("duplicateLabels.has(baseLabel(label))"); |
| 22 | + }); |
| 23 | + |
| 24 | + // AC4: Timestamps use the existing formatShortTime format |
| 25 | + it("uses formatShortTime for timestamp value", () => { |
| 26 | + // The timestamp value is derived from formatShortTime(session.createdAt) |
| 27 | + expect(sidebarSrc).toContain("formatShortTime(session.createdAt)"); |
| 28 | + }); |
| 29 | + |
| 30 | + // AC5: Timestamp styling uses the existing muted style |
| 31 | + it("renders timestamps with muted sidebar-foreground/40 styling", () => { |
| 32 | + expect(sidebarSrc).toContain("text-sidebar-foreground/40"); |
| 33 | + // timestamp rendering should include the dot separator |
| 34 | + expect(sidebarSrc).toMatch(/·\s*\{timestamp\}/); |
| 35 | + }); |
| 36 | + |
| 37 | + // AC6: isRecent is defined based on Today/Yesterday group labels |
| 38 | + it("defines isRecent from Today and Yesterday group labels", () => { |
| 39 | + expect(sidebarSrc).toMatch( |
| 40 | + /isRecent\s*=\s*group\.label\s*===\s*["']Today["']\s*\|\|\s*group\.label\s*===\s*["']Yesterday["']/, |
| 41 | + ); |
| 42 | + }); |
| 43 | +}); |
0 commit comments