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

@@ -16,8 +16,10 @@ use App\Models\TimeEntry;
use App\Models\User;
use App\Service\Export\ExportService;
use Illuminate\Support\Facades\Storage;
use League\Csv\Reader;
use PHPUnit\Framework\Attributes\CoversClass;
use Tests\TestCaseWithDatabase;
use ZipArchive;
#[CoversClass(ExportService::class)]
class ExportServiceTest extends TestCaseWithDatabase
@@ -62,4 +64,32 @@ class ExportServiceTest extends TestCaseWithDatabase
// Assert
Storage::disk(config('filesystems.default'))->assertExists($zip);
}
public function test_export_includes_time_entry_type_in_time_entries_csv(): void
{
// Arrange
$this->mockPrivateStorage();
$user = User::factory()->create();
$organization = Organization::factory()->withOwner($user)->create();
$member = Member::factory()->forUser($user)->forOrganization($organization)->create();
$workEntry = TimeEntry::factory()->forMember($member)->create();
$breakEntry = TimeEntry::factory()->forMember($member)->isBreak()->create();
// Act
$exportService = app(ExportService::class);
$zip = $exportService->export($organization);
// Assert
$zipArchive = new ZipArchive;
$zipArchive->open(Storage::disk(config('filesystems.default'))->path($zip));
$timeEntriesCsv = $zipArchive->getFromName('time_entries.csv');
$zipArchive->close();
$this->assertNotFalse($timeEntriesCsv);
$reader = Reader::createFromString($timeEntriesCsv);
$reader->setHeaderOffset(0);
$this->assertContains('type', $reader->getHeader());
$typesById = collect($reader)->pluck('type', 'id');
$this->assertSame('work', $typesById[$workEntry->getKey()]);
$this->assertSame('break', $typesById[$breakEntry->getKey()]);
}
}