diff --git a/frontend/package.json b/frontend/package.json index 0fb2626..2b0d12f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "tsc && vite build", "preview": "vite preview", - "test": "vitest", + "test": "vitest run", "test:all": "vitest run && npx playwright test", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0" }, diff --git a/frontend/src/utils/time.ts b/frontend/src/utils/time.ts index 73993e6..09c137d 100644 --- a/frontend/src/utils/time.ts +++ b/frontend/src/utils/time.ts @@ -110,3 +110,18 @@ export function timeToMinutes(timeStr: string): number { const [hours, minutes] = timeStr.split(":").map(Number); return hours * 60 + minutes; } + +/** + * Convert total minutes to a human-readable string (e.g., "1h 30m" or "45m") + * @param totalMinutes - Total number of minutes + * @returns Formatted string + */ +export function formatMinutes(totalMinutes: number): string { + const hours = Math.floor(totalMinutes / 60); + const mins = totalMinutes % 60; + + if (hours > 0) { + return `${hours}h ${mins}m`; + } + return `${mins}m`; +} diff --git a/frontend/tests/unit/time.test.ts b/frontend/tests/unit/time.test.ts index 17ab06d..0337a5f 100644 --- a/frontend/tests/unit/time.test.ts +++ b/frontend/tests/unit/time.test.ts @@ -82,7 +82,7 @@ describe('formatMinutes', () => { }); it('formats hours only', () => { - expect(formatMinutes(120)).toBe('2h'); + expect(formatMinutes(120)).toBe('2h 0m'); }); it('formats minutes only', () => {