feat(admin): show paused sessions in live view; reset to live on logout
- Live cards freeze the worked timer at paused_at and show an amber "Gepauzeerd" badge plus a "Pauze H:MM:SS" total when paused. - AuthContext.signOut resets the path to / so the next admin login lands on Live rather than the tab it logged out from.
This commit is contained in:
@@ -92,4 +92,23 @@ describe('AuthContext admin gate', () => {
|
||||
expect(getToken()).toBeNull();
|
||||
expect(screen.getByTestId('authed')).toHaveTextContent('false');
|
||||
});
|
||||
|
||||
it('signOut resets the path to / so the next login lands on Live', async () => {
|
||||
mockedFetchMe.mockResolvedValue({
|
||||
user: { id: 'a1', email: 'admin@solelog.local', name: 'Admin', role: 'admin' },
|
||||
});
|
||||
window.history.replaceState(null, '', '/activities');
|
||||
expect(window.location.pathname).toBe('/activities');
|
||||
|
||||
const user = userEvent.setup();
|
||||
renderHarness();
|
||||
await user.click(screen.getByRole('button', { name: 'go' }));
|
||||
await waitFor(() => expect(screen.getByTestId('authed')).toHaveTextContent('true'));
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'uit' }));
|
||||
|
||||
await waitFor(() => expect(screen.getByTestId('authed')).toHaveTextContent('false'));
|
||||
expect(window.location.pathname).toBe('/');
|
||||
expect(getToken()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,6 +34,9 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
}, []);
|
||||
|
||||
const signOut = useCallback(() => {
|
||||
// Reset the path to / so the next authed mount lands on Live, not whatever tab
|
||||
// (e.g. Account/Activities) the admin happened to log out from.
|
||||
window.history.replaceState(null, '', '/');
|
||||
clearToken();
|
||||
setIsAuthed(false);
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user