Skip to content

[FE-67] Tests for the authentication flow #1167

Description

@yusuftomilola

Overview

app/(auth)/login/page.tsx, app/(auth)/register/page.tsx, store/auth.store.ts, lib/auth-api.ts, components/auth-initializer.tsx, and middleware.ts form the app's entire access boundary and have no tests.

Tasks

  • Test login and register form validation using the existing React Hook Form + Zod schemas.
  • Test submit states: loading disables the button, API error renders a visible message, success stores the token and redirects.
  • Test the Zustand auth store: set, clear, hydrate from storage, and persistence behaviour.
  • Test auth-initializer restores a session on mount and handles a missing or invalid token.
  • Test route protection in middleware.ts — unauthenticated access to a dashboard route redirects to login.

Acceptance Criteria

  • Both auth pages have happy-path and at least two failure-path tests.
  • Auth store transitions are fully covered.
  • A test proves protected routes redirect when unauthenticated.

Dependencies

Blocked by [FE-64] and [FE-66].

Notes for Contributors

Comment below to be assigned.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or requestfrontendtestingTests, QA, and quality assurance

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions