add break time entries and simplified time tracker ui

This commit is contained in:
Gregor Vostrak
2026-07-21 16:48:37 +02:00
parent c07c62bfab
commit 64ca1e9115
128 changed files with 6252 additions and 437 deletions

View File

@@ -0,0 +1,39 @@
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import { describe, expect, it } from 'vitest';
import type { TimeEntry } from '@/packages/api/src';
import { getLastWorkTimeEntry } from './useCurrentTimeEntry';
dayjs.extend(utc);
function timeEntry(id: string, start: string, type: 'work' | 'break'): TimeEntry {
return {
id,
start,
end: null,
duration: null,
description: '',
project_id: null,
task_id: null,
organization_id: 'organization-1',
user_id: 'user-1',
tags: [],
billable: false,
type,
} as TimeEntry;
}
describe('getLastWorkTimeEntry', () => {
it('returns the newest work entry that is not in the future', () => {
const entries = [
timeEntry('future-work', '2026-07-14T14:00:00Z', 'work'),
timeEntry('break', '2026-07-14T12:00:00Z', 'break'),
timeEntry('last-work', '2026-07-14T11:00:00Z', 'work'),
timeEntry('older-work', '2026-07-14T10:00:00Z', 'work'),
];
expect(getLastWorkTimeEntry(entries, dayjs.utc('2026-07-14T13:00:00Z'))?.id).toBe(
'last-work'
);
});
});