mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-14 08:43:16 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user