Skip to content

Add unit tests for Zustand stores (auth-store, course-store, error-store) #478

Description

@DeFiVC

What

Add unit tests for the three Zustand state stores: auth-store.ts, course-store.ts, and error-store.ts.

Why

Stores contain critical business logic (authentication flow, enrollment deduplication, progress tracking) that is currently untested. Bugs in store logic could cause data loss, broken auth flows, or incorrect progress tracking.

Scope

  • Create src/store/__tests__/auth-store.test.ts
  • Create src/store/__tests__/course-store.test.ts
  • Create src/store/__tests__/error-store.test.ts
  • No source code changes

Acceptance Criteria

  • auth-store tests: connect, disconnect, setJwt, applyRefreshedTokens, isTokenExpired, hydration, persistence
  • course-store tests: enroll (deduplication), updateProgress (percent calculation), setEnrollments, getProgress
  • error-store tests: setError, clearError, setRetry
  • Tests use useAuthStore.getState() / useCourseStore.getState() patterns
  • npm test passes

Technical Context

Files:

  • src/store/auth-store.ts — 158 lines, Zustand with persist middleware, handles wallet auth, JWT, token refresh
  • src/store/course-store.ts — 79 lines, Zustand with persist, handles courses, enrollments, progress
  • src/store/error-store.ts — 20 lines, Zustand (no persist), global error state

Labels: tests, react

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programmediumFunctionality impaired but workaround exists, edge case, partial featurereactReact frameworktestsTest additions or improvements

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions