test: add unit test coverage for RequireAuth component with 100% coverage
Description:
This MR adds unit test coverage for the RequireAuth.tsx component to validate authentication guard behavior. The tests cover loading state, unauthenticated redirects, and authenticated access to protected routes. This improves reliability of route protection and prevents regressions without modifying any production source code.
Type of Change:
-
Bug Fix -
Feature Development -
Documentation
Testing:
-
Tested on desktop -
Tested on mobile -
Tested in different browsers
Checklist:
-
Code follows project style guidelines -
Self-review completed -
No console errors -
TypeScript types are correct -
ESLint checks pass -
Prettier formatting applied -
All tests passing (3/3) -
100% test coverage achieved for RequireAuth.tsx -
No source code modifications (tests only)
Test Coverage Summary:
RequireAuth Component (tests/src/components/RequireAuth.test.tsx)
Covered scenarios:
- Loading state when authentication is not ready
- Redirect unauthenticated users to /login
- Render protected children for authenticated users
Coverage Achieved:
- Statements: 100%
- Branches: 100%
- Functions: 100%
- Lines: 100%
Commands Used to Verify:
npm run test:coverage -- tests/src/components/RequireAuth.test.tsx
npm run lint
npm run type-check
npm run ci-local
Notes:
This MR is limited to adding unit tests only. No changes were made to application logic or UI behavior. Closes #287 (closed)
