Category: Testing - Enhancement
Priority: High
Estimated Time: 3 hours
Description:
components/session-provider.tsx is the most security-critical module in the frontend — it handles authentication, token storage, and the 401 expiry redirect — but it has zero tests. The money utility (lib/money.ts) is the only file with tests. A regression in signIn, the onUnauthorized handler, or the localStorage fallback path would be silent.
Tasks:
- Add
components/__tests__/session-provider.test.tsx
- Test
signIn success: session is persisted and context value updated
- Test
signIn failure: error propagates and session remains null
- Test
signOut: localStorage cleared and session set to null
- Test 401 handler:
signOut is called when onUnauthorized fires
- Test localStorage unavailable (mock
setItem to throw): session still works for the tab
- Test
ready flag: false before localStorage is read, true after
- Aim for 100% branch coverage on the provider
Category: Testing - Enhancement
Priority: High
Estimated Time: 3 hours
Description:
components/session-provider.tsxis the most security-critical module in the frontend — it handles authentication, token storage, and the 401 expiry redirect — but it has zero tests. The money utility (lib/money.ts) is the only file with tests. A regression insignIn, theonUnauthorizedhandler, or the localStorage fallback path would be silent.Tasks:
components/__tests__/session-provider.test.tsxsignInsuccess: session is persisted and context value updatedsignInfailure: error propagates and session remains nullsignOut: localStorage cleared and session set to nullsignOutis called whenonUnauthorizedfiressetItemto throw): session still works for the tabreadyflag: false before localStorage is read, true after