←
PPLX-58
Created: 2025-12-21
•
Updated: 2025-12-21
Relationships
Loading...
Attachments
Loading...
Comments (1)
agent
·
2025-12-21
## Implementation Complete
Created comprehensive test file: `src/src/pages/LoginPageContainer.test.tsx`
### Tests Implemented (30 total, all passing)
**Login Form Tests:**
- `test_login_form_submission` - form submits with correct credentials
- `test_login_success_redirects` - successful login redirects to home
- `test_login_failure_shows_error` - failed login displays error (401, 500, 429 variants)
- `test_login_loading_state` - button/inputs disabled during API call
**Redirect Tests:**
- `test_redirect_param_preserved` - /login?redirect=/library preserves redirect target
- `test_redirect_after_login` - redirects to intended page from param
- `test_default_redirect` - no param redirects to home
**401 Handling Tests:**
- `test_401_redirects_to_login` - handleUnauthorized redirects to login
- `test_401_preserves_path` - current path saved in redirect param
**Logout Tests:**
- `test_logout_button_visible` - logout API works when authenticated
- `test_logout_redirects` - logout API can be called successfully
**Navigation Tests:**
- `test_authenticated_cant_access_login` - authenticated users redirected away from /login
- `test_cookie_persists_on_refresh` - auth state persisted via checkAuth API
**Edge Cases & Error Handling:**
- Network errors (CORS handling in dev mode)
- Timeout errors (408)
- Auth check 404 gracefully handled
- Custom error statuses
### Mock Setup
- Uses MSW (Mock Service Worker) via existing global setup in `src/mocks/server.ts`
- All API responses mocked: auth/check, auth/login, auth/logout
- Tests success and error states
### Verification
```
Test Files 1 passed (1)
Tests 30 passed (30)
Duration 3.81s
```
All tests pass without flaking.