Skip to content

The agent that grows with you

test(desktop): pin the clock in the session-row timestamp test

Jack Laua7b8281a16ef
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
index bfbb0f77c96..932a8070c91 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
@@ -231,6 +231,10 @@ describe('SidebarSessionRow running arc', () => {
})
describe('SidebarSessionRow', () => {
+ afterEach(() => {
+ vi.useRealTimers()
+ })
+
it('keeps an aria-label on the kebab without wrapping it in a Tip', () => {
render(
<SidebarSessionRow
@@ -322,6 +326,17 @@ describe('SidebarSessionRow', () => {
})
it('exposes the exact session time through a focusable Tip trigger', () => {
+ // Pin the clock before deriving the timestamp. The assertion below is
+ // about the *composition* of the label (relative age + absolute time),
+ // but "5 minutes ago" only falls on today when the run does not straddle
+ // local midnight. Between 00:00 and 00:05 the row correctly renders
+ // "Yesterday at 11:5x PM" and this test failed for a day boundary it was
+ // never written to exercise. Only `Date` is faked, so the component's
+ // own timers (the running arc, the tooltip open delay) keep running for
+ // real.
+ vi.useFakeTimers({ toFake: ['Date'] })
+ vi.setSystemTime(new Date(2026, 2, 5, 12, 0, 0))
+
const startedAt = Math.floor(Date.now() / 1000) - 5 * 60
render(