fix(worker): show paused time in history; reset to stopwatch on logout

This commit is contained in:
Bas van Rossem
2026-06-17 21:10:01 +02:00
parent ce396ecf2d
commit 1765f4036c
4 changed files with 74 additions and 1 deletions

View File

@@ -31,6 +31,8 @@ function session(overrides: Partial<WorkSession> = {}): WorkSession {
start_time: '2026-01-02T08:30:00.000Z',
end_time: '2026-01-02T09:31:01.000Z',
duration_seconds: 3661,
paused_seconds: 0,
paused_at: null,
status: 'completed',
source: 'app',
notes: null,
@@ -44,7 +46,7 @@ function renderHistory() {
return render(
<QueryClientProvider client={queryClient}>
<History />
</QueryClientProvider>,
</QueryClientProvider>
);
}
@@ -94,6 +96,23 @@ describe('History', () => {
expect(card.textContent).not.toContain('1 inlegzolen');
});
it('renders a Pauze line when paused_seconds > 0', async () => {
mockedApiFetch.mockResolvedValue([session({ paused_seconds: 125 })]);
renderHistory();
const card = (await screen.findByText('Frezen')).closest('.session-card') as HTMLElement;
// 125s -> "2m 5s".
expect(card.textContent).toContain('Pauze 2m 5s');
});
it('does not render a Pauze line when paused_seconds is 0', async () => {
mockedApiFetch.mockResolvedValue([session({ paused_seconds: 0 })]);
renderHistory();
const card = (await screen.findByText('Frezen')).closest('.session-card') as HTMLElement;
expect(card.textContent).not.toContain('Pauze');
});
it('triggers the CSV download on Exporteer CSV', async () => {
const user = userEvent.setup();
renderHistory();