also looking at this
Harden AnalyticsHQ release and dashboard quality
#52
34 files
+1236
-340
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -0,0 +1,19 @@ | ||
| 1 | import { describe, expect, test } from 'bun:test' | |
| 2 | ||
| 3 | const NOW = '2026-09-12T12:00:00.000Z' | |
| 4 | ||
| 5 | export const productStates = { | |
| 6 | empty: { now: NOW, status: 'ready', sites: [], visitors: 0, views: 0 }, | |
| 7 | normal: { now: NOW, status: 'ready', sites: [{ id: 'site-demo', name: 'Northwind', visitors: 1842, views: 5291 }], visitors: 1842, views: 5291 }, | |
| 8 | loading: { now: NOW, status: 'loading', sites: [], visitors: null, views: null }, | |
| 9 | failure: { now: NOW, status: 'error', sites: [], error: 'Analytics query timed out' }, | |
| 10 | highVolume: { now: NOW, status: 'ready', sites: Array.from({ length: 250 }, (_, index) => ({ id: `site-${index + 1}`, name: `Site ${index + 1}`, visitors: 100_000 + index, views: 300_000 + index * 3 })) }, | |
| 11 | } as const | |
| 12 | ||
| 13 | describe('deterministic analytics product states', () => { | |
| 14 | test('covers every UI state', () => expect(Object.keys(productStates)).toEqual(['empty', 'normal', 'loading', 'failure', 'highVolume'])) | |
| 15 | test('keeps volume fixtures large and reproducible', () => { | |
| 16 | expect(productStates.highVolume.sites).toHaveLength(250) | |
| 17 | expect(JSON.stringify(productStates)).toBe(JSON.stringify(productStates)) | |
| 18 | }) | |
| 19 | }) | |