Skip to main content
The sync system has 575 tests across three packages, all using Vitest.

Running tests

Always run from the correct package directory. Running from the repo root picks up test files from all packages, causing path alias resolution failures.

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 visually
  • ConflictDialog — Radix UI dialog, tested visually
  • SyncOverlay — Toast integration, tested visually
  • SyncUIProvider — Simple React context with useState
  • RealtimeProvider — Tested indirectly through transport and machine tests