diff --git a/admin-web/components/sidebar.test.tsx b/admin-web/components/sidebar.test.tsx index 2863498..377db62 100644 --- a/admin-web/components/sidebar.test.tsx +++ b/admin-web/components/sidebar.test.tsx @@ -91,8 +91,10 @@ describe('Sidebar', () => { }) it('should handle logout errors gracefully', async () => { - mockSignOut.mockRejectedValueOnce(new Error('Network error')) - + // Real supabase.auth.signOut() never throws — it resolves with { error }. + // Mocking it realistically avoids an unhandled rejection and matches prod behaviour. + mockSignOut.mockResolvedValueOnce({ error: new Error('Network error') }) + render() const logoutButton = screen.getByRole('button', { name: /logout/i }) @@ -101,6 +103,9 @@ describe('Sidebar', () => { await waitFor(() => { expect(mockSignOut).toHaveBeenCalled() }) + + // Graceful: even when signOut errors, the user is still redirected to login. + expect(mockPush).toHaveBeenCalledWith('/login') }) it('should have correct styling for navigation', () => {