Fixed 3 critical code quality issues: 1. Act() warnings in tests (9 tests): - Wrapped all async state updates in act() blocks in usePhotoUpload.test.ts - Tests using waitFor() now properly await state updates within act() - All 21 tests pass with zero act() warnings 2. Missing toast cleanup on unmount: - Added toastIdRef to track pending toast IDs - Added cleanup useEffect that dismisses toasts on component unmount - Prevents memory leaks and orphaned toast notifications 3. Dual error reporting channels (lines 23-28): - Removed useEffect that synced hook error to local state AND called onError callback - Now syncs hook error to local state only (for display) - Parent components rely on hook error state, reducing dual-path confusion - Toast error calls are explicit in catch block Test Results: - Frontend: 312/312 tests passing (includes 21 photo upload tests) - Act() warnings: Eliminated - No regressions introduced
107 KiB
107 KiB