mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-24 13:38:43 +02:00
- Fix useElapsedTimer to use completedAt instead of Date.now() for finished runs, preventing wildly inaccurate durations (e.g. 9802m) when reopening old sessions - Extract formatElapsedMs as a shared pure formatter; reuse in SubagentActivityCard - Standardize icon column alignment across all activity row types using consistent w-4 + h-[18px] icon containers - Redesign collapsed header: status dot with pulse animation, bolder status label, tabular-nums on elapsed time, cleaner hierarchy - Polish expanded stream: timeline spine connecting activity items, more prominent intent dividers with pill-style background, tightened vertical rhythm - Add unit tests for formatElapsedMs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
|
|
import { formatElapsedMs } from '@renderer/hooks/useElapsedTimer';
|
|
|
|
describe('formatElapsedMs', () => {
|
|
test('formats sub-second durations as 0s', () => {
|
|
expect(formatElapsedMs(0)).toBe('0s');
|
|
expect(formatElapsedMs(500)).toBe('0s');
|
|
expect(formatElapsedMs(999)).toBe('0s');
|
|
});
|
|
|
|
test('formats seconds under a minute', () => {
|
|
expect(formatElapsedMs(1000)).toBe('1s');
|
|
expect(formatElapsedMs(5_000)).toBe('5s');
|
|
expect(formatElapsedMs(59_000)).toBe('59s');
|
|
});
|
|
|
|
test('formats minutes with remaining seconds', () => {
|
|
expect(formatElapsedMs(60_000)).toBe('1m');
|
|
expect(formatElapsedMs(90_000)).toBe('1m 30s');
|
|
expect(formatElapsedMs(125_000)).toBe('2m 5s');
|
|
});
|
|
|
|
test('formats exact minutes without trailing seconds', () => {
|
|
expect(formatElapsedMs(120_000)).toBe('2m');
|
|
expect(formatElapsedMs(300_000)).toBe('5m');
|
|
});
|
|
|
|
test('clamps negative durations to 0s', () => {
|
|
expect(formatElapsedMs(-5000)).toBe('0s');
|
|
});
|
|
|
|
test('formats large durations correctly', () => {
|
|
// 2 hours, 30 minutes, 15 seconds = 9015s = 150m 15s
|
|
expect(formatElapsedMs(9_015_000)).toBe('150m 15s');
|
|
});
|
|
});
|