Running tests
- Protocol
- Hub
- Frontend
Single test file
Watch mode
Test architecture
Protocol tests
nu_pos_sync_protocol/src/__tests__/validators.test.ts (55 tests)
- Round-trip validation for all terminal and hub message types
- Rejection of malformed messages (missing fields, wrong types)
parseTerminalMessage(),parseHubMessage(),parseProtocolMessage()helpers
Hub tests
Storage layer (41 tests)
All storage tests use in-memory SQLite (
:memory:) for speed and isolation.
Lease manager (25 tests)
- Acquire: new lease, re-entrant, denied (held by other), force override
- Release: by holder, by non-holder (rejected), with final snapshot
- Heartbeat: renewal, rejected for non-holder
- Tick: expired lease revocation, callback invocation
- Disconnect: grace period extension
Handlers (14 tests)
Server (25 tests)
Upstream (24 tests)
Frontend tests
Sync-specific (67 tests)
Transport infrastructure (31 tests)
Testing patterns
Hub: in-memory SQLite
Hub: mock WebSocket
Frontend: module mocking
Frontend: XState actor testing
What’s not tested
The following are intentionally untested (React components requiring DOM/render context):SyncStatusIndicator— Read-only badge, tested visuallyConflictDialog— Radix UI dialog, tested visuallySyncOverlay— Toast integration, tested visuallySyncUIProvider— Simple React context withuseStateRealtimeProvider— Tested indirectly through transport and machine tests