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 114a32536d
commit cbcd1e51f6
128 changed files with 6252 additions and 437 deletions

View File

@@ -4,7 +4,11 @@ declare(strict_types=1);
namespace Tests\Unit\Service\Import\Importers;
use App\Enums\TimeEntryType;
use App\Models\Client;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Tag;
use App\Models\TimeEntry;
use App\Service\Import\Importers\ClockifyTimeEntriesImporter;
use App\Service\Import\Importers\DefaultImporter;
@@ -196,4 +200,35 @@ class ClockifyTimeEntriesImporterTest extends ImporterTestAbstract
}
$this->fail();
}
public function test_import_creates_break_time_entry_when_type_is_break(): void
{
// Arrange
// Clockify lets a break carry a project, task, tags and billable status, but those are
// meaningless for non-work time. The break must import stripped of all of them, and must
// NOT create the project/tag it referenced (which would be an orphan).
$organization = Organization::factory()->create();
$importer = new ClockifyTimeEntriesImporter;
$importer->init($organization);
$csv = <<<'CSV'
"Project","Client","Description","Task","User","Group","Email","Tags","Billable","Start Date","Start Time","End Date","End Time","Duration (h)","Duration (decimal)","Billable Rate (USD)","Billable Amount (USD)","Type"
"Break Project","Break Client","Lunch","Design","Peter Tester","","peter.test@email.test","Backend","Yes","03/04/2024","10:00:00 AM","03/04/2024","10:30:00 AM","00:30:00","0.50","0.00","0.00","Break"
CSV;
// Act
$importer->importData($csv, 'Europe/Vienna');
// Assert
$timeEntry = TimeEntry::query()->firstOrFail();
$this->assertSame(TimeEntryType::Break, $timeEntry->type);
$this->assertFalse($timeEntry->billable);
$this->assertNull($timeEntry->project_id);
$this->assertNull($timeEntry->task_id);
$this->assertNull($timeEntry->client_id);
$this->assertSame([], $timeEntry->tags);
// The break's project/tag/client must not have been created as orphans.
$this->assertSame(0, Project::query()->count());
$this->assertSame(0, Tag::query()->count());
$this->assertSame(0, Client::query()->count());
}
}