Skip to content

Documentation

Store Test Coverage

Comprehensive test coverage documentation for SveltyCMS store management

6/17/2026
4 min read Edit on GitHub

Executive Summary

| Total Suite: 1,100+ unit tests (consolidated) Total Store Tests: 95 tests across 11 core files Coverage: 100% Logic Coverage (Svelte 5 Runes) Status: ✅ All tests passing Framework: Vitest + Svelte 5 Runes


Test Coverage by Store {#content-store-coverage}

1. Content Registry (tests/unit/stores/content-registry.test.ts)

Tests: 16 | Status: ✅ Passing

Audit Integration

  • Zero-Latency Sync: Verified refreshContent({ mode: "schemas" }) logic for benchmark stability.
  • HMR Optimization: Verified hash-based change detection (15ms reconciliation).
  • Multi-Tenant Safety: Atomic node isolation per tenantId.

2. System Store (tests/unit/stores/system.test.ts)

This document provides comprehensive test coverage information for SveltyCMS state management stores, focusing on fine-grained reactivity and Fail-Closed state integrity.


Why Test Stores?

SveltyCMS leverages Svelte 5 runes ($state, $derived, $effect) for deep reactivity. Testing ensures:

  • System health monitoring - Track service status and performance
  • Loading states - Prevent UI flashes with intelligent loading tracking
  • Screen responsiveness - Detect breakpoints and device types
  • Setup wizard - Multi-step configuration flow
  • Notification integrity - Toast delivery and auto-removal validation
  • Fail-Closed State: Ensures that any invalid state transition results in a secure, stable system posture.

Test Coverage by Store {#test-coverage-by-store-2}

1. Content Registry (tests/unit/stores/content-registry.test.ts) {#content-registry-2}

Tests: 16 | Status: ✅ Passing

Audit Integration {#audit-integration-2}

  • Zero-Latency Sync: Verified refreshContent({ mode: "schemas" }) logic for benchmark stability.
  • HMR Optimization: Verified hash-based change detection (15ms reconciliation).
  • Multi-Tenant Safety: Atomic node isolation per tenantId.

2. System Store (tests/unit/stores/system.test.ts) {#system-store-2}

Tests: 17 | Status: ✅ Passing

Service Health Management {#service-health-2}

  • ✅ Initializes with default state (IDLE)
  • ✅ Updates service health status (database, auth, cache)
  • ✅ Transitions to READY when all services healthy
  • ✅ Transitions to FAILED when critical services down

3. Loading Store (tests/unit/stores/loading-store.test.ts)

Tests: 22 | Status: ✅ Passing

Key Operations

  • ✅ Starts loading operation with specific reasons
  • ✅ Handles multiple concurrent operations
  • ✅ Automatic timeout protection (30s default)
  • ✅ Context isolation (Multi-tenant safe)

4. Screen Size Store (tests/unit/stores/screen-size.test.ts)

Tests: 26 | Status: ✅ Passing

Size Detection

  • ✅ Tailwind CSS Breakpoint Alignment (XS, SM, MD, LG, XL, 2XL)
  • ✅ Device-specific mock testing (iPhone, iPad, MacBook, 4K)
  • ✅ Zero-width and boundary condition handling

5. Setup Store (tests/unit/stores/setup-store.test.ts)

Tests: 5 | Status: ✅ Passing

Configuration Flow

  • ✅ Multi-step wizard initialization
  • ✅ Database configuration validation (MongoDB, SQL)
  • ✅ Admin user creation validation
  • ✅ Password matching and strength checks

6. Toast Store (tests/unit/stores/toast.test.ts)

Tests: 9 | Status: ✅ Passing

Notification Lifecycle

  • ✅ Flash message persistence across sessions
  • ✅ Auto-removal after duration timeout
  • ✅ Maximum toast limit enforcement (non-persistent removal)
  • ✅ Manual close and pause/resume logic

7. Additional Store Files

Store File Focus Area
tests/unit/stores/collection-store-reactive.test.ts Reactive collection state
tests/unit/stores/filter-worker.test.ts Off-thread filtering operations
tests/unit/stores/image-editor-store.test.ts Image editor UI state
tests/unit/stores/mode-transition-guard.test.ts Svelte 5 mode guard transitions
tests/unit/stores/ui-store.test.ts General UI state management

Running Store Tests

Run Commands

# Run all store tests
bun run test:unit -- tests/unit/stores

# Run specific store tests
bun run test:unit -- tests/unit/stores/system
bun run test:unit -- tests/unit/stores/loading-store
```

---

## Store Architecture Patterns (Svelte 5)

All stores use Svelte 5 runes to enable fine-grained reactivity and remove legacy store overhead:

```
// Svelte 5 State Rune (Single Source of Truth)
export const systemState = $state({
  overallState: "IDLE" as SystemState,
  services: {} as Record<string, ServiceStatus>,
});

// Svelte 5 Derived Rune (Reactive Computation)
export const isSystemReady = $derived(systemState.overallState === "READY");

// Svelte 5 Export Pattern
export const systemStore = {
  get state() {
    return systemState;
  },
  set state(val) {
    /* controlled updates */
  },
};
```

---

## Integration Strategy

### Unit Tests (Vitest)

Verifies pure logic, state transitions, and reactive computations without a full browser environment.

### Component Tests (Vitest + Browser)

Verifies how components react to store changes in a real browser environment using Playwright/Vitest Browser.

### E2E Tests (Playwright)

Verifies state persistence and UI reflections in real user workflows across multiple tenants.

---

## Related Documentation

- [Test Status Overview](/docs/tests/test-status)
- [System State Architecture](/docs/reference/architecture/state-management)
- [Security Architecture](/docs/reference/security/index)
testingstoresstate-managementsvelte-5vitest
Was this page helpful?