Skip running time entries in solidtime import

Imported running time entries could give a user a second running time
entry, for example when an export is imported again while a timer runs.
This commit is contained in:
Constantin Graf
2026-10-13 18:04:11 +02:00
parent 332edcb047
commit 0bfeab156c
12 changed files with 63 additions and 12 deletions

View File

@@ -140,6 +140,31 @@ class SolidtimeImporterTest extends ImporterTestAbstract
$this->assertSame([], $breakEntry->tags);
}
public function test_import_skips_running_time_entries(): void
{
// Arrange
$zipPath = $this->createTestZip('solidtime_import_test_3');
$timezone = 'Europe/Vienna';
$organization = Organization::factory()->create();
$importer = new SolidtimeImporter;
$importer->init($organization);
$data = file_get_contents($zipPath);
Queue::fake([
RecalculateSpentTimeForProject::class,
RecalculateSpentTimeForTask::class,
]);
// Act
$importer->importData($data, $timezone);
$report = $importer->getReport();
// Assert
$this->assertSame(3, $report->timeEntriesCreated);
$this->assertSame(3, TimeEntry::query()->count());
$this->assertSame(0, TimeEntry::query()->whereNull('end')->count());
$this->assertNull(TimeEntry::query()->where('description', 'Still running')->first());
}
public function test_import_of_test_file_twice_succeeds(): void
{
// Arrange