Kanban / timesheet update
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Modules\Jobs\Domain\Exceptions\TaskHasTimeEntries;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||||
use App\Modules\TimeTracking\Infrastructure\Persistence\Eloquent\TimeEntryModel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Features\SupportLockedProperties\CannotUpdateLockedPropertyException;
|
||||
use Livewire\Livewire;
|
||||
|
||||
@@ -23,7 +24,7 @@ it('saves and clears a cell of the weekly view', function () {
|
||||
|
||||
Livewire::test('time::week')
|
||||
->call('saveCell', $this->task->id, $this->monday, '2,5')
|
||||
->assertSee('2,5 h.')
|
||||
->assertSee('2:30.')
|
||||
->call('saveCell', $this->task->id, $this->monday, '1,1')
|
||||
->assertHasErrors(["cells.{$this->task->id}.{$this->monday}"]);
|
||||
|
||||
@@ -34,6 +35,100 @@ it('saves and clears a cell of the weekly view', function () {
|
||||
expect(TimeEntryModel::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
it('takes hours and minutes, minutes and 15 minute steps in a cell', function () {
|
||||
$week = Livewire::test('time::week')
|
||||
->call('saveCell', $this->task->id, $this->monday, '1:30')
|
||||
->call('adjustCell', $this->task->id, $this->monday, 1);
|
||||
|
||||
expect((float) TimeEntryModel::query()->sole()->hours)->toBe(1.75);
|
||||
|
||||
$week->call('saveCell', $this->task->id, $this->monday, '90');
|
||||
expect((float) TimeEntryModel::query()->sole()->hours)->toBe(1.5);
|
||||
|
||||
$week->call('saveCell', $this->task->id, $this->monday, '1:10')
|
||||
->assertHasErrors(["cells.{$this->task->id}.{$this->monday}"]);
|
||||
|
||||
foreach (range(1, 6) as $step) {
|
||||
$week->call('adjustCell', $this->task->id, $this->monday, -1);
|
||||
}
|
||||
|
||||
expect(TimeEntryModel::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
it('stores the billing basis, billing note and internal comment of an entry', function () {
|
||||
Livewire::test('time::week')
|
||||
->call('saveCell', $this->task->id, $this->monday, '2')
|
||||
->call('openEntry', $this->task->id, $this->monday)
|
||||
->assertSet('entryBillingModel', 'hourly')
|
||||
->set('entryBillingModel', 'non_billable')
|
||||
->set('entryNote', 'Kuvien rajaus')
|
||||
->set('entryComment', 'Asiakas toivoi kiirettä')
|
||||
->call('saveEntry')
|
||||
->assertSee('Kirjaus tallennettu');
|
||||
|
||||
$entry = TimeEntryModel::query()->sole();
|
||||
|
||||
expect($entry->note)->toBe('Kuvien rajaus')
|
||||
->and($entry->internal_comment)->toBe('Asiakas toivoi kiirettä')
|
||||
->and($entry->billing_model)->toBe('non_billable');
|
||||
});
|
||||
|
||||
it('blocks approving a week without billing notes and lists the entries', function () {
|
||||
Livewire::test('time::week')
|
||||
->call('saveCell', $this->task->id, $this->monday, '2')
|
||||
->assertSee('1 selite puuttuu')
|
||||
->call('approveWeek')
|
||||
->assertSee('Viikkoa ei voi vielä hyväksyä');
|
||||
|
||||
expect(TimeEntryModel::query()->sole()->approved_at)->toBeNull();
|
||||
});
|
||||
|
||||
it('pins tasks to the pinned part, keeps them on later weeks and unpins them', function () {
|
||||
$other = TaskModel::factory()->create(['title' => 'Kehitystyöt']);
|
||||
|
||||
$week = Livewire::test('time::week')
|
||||
->call('pinTasks', [$other->id])
|
||||
->assertSee('Tehtävä Kehitystyöt kiinnitetty');
|
||||
|
||||
expect($week->instance()->sheet->row($other->id)?->pinned)->toBeTrue()
|
||||
->and($week->instance()->sheet->pinnedTaskCount())->toBe(1);
|
||||
|
||||
$week->call('showWeek', 'next');
|
||||
expect($week->instance()->sheet->pinnedTaskCount())->toBe(1);
|
||||
|
||||
$week->call('unpinTask', $other->id);
|
||||
expect($week->instance()->sheet->pinnedTaskCount())->toBe(0);
|
||||
|
||||
$week->call('pinTasks', [$other->id])->call('clearPins')->assertSee('1 kiinnitys poistettu.');
|
||||
});
|
||||
|
||||
it('lets a pin lapse after the job is done, except on weeks with hours', function () {
|
||||
$week = Livewire::test('time::week')
|
||||
->call('pinTasks', [$this->task->id])
|
||||
->call('saveCell', $this->task->id, $this->monday, '1');
|
||||
|
||||
DB::table('customer_jobs')->where('id', $this->task->customer_job_id)->update(['status' => 'done']);
|
||||
|
||||
$week->call('showWeek', 'this');
|
||||
expect($week->instance()->sheet->pinnedTaskCount())->toBe(1);
|
||||
|
||||
$week->call('showWeek', 'next');
|
||||
expect($week->instance()->sheet->pinnedTaskCount())->toBe(0)
|
||||
->and($week->instance()->sheet->scheduledTaskCount())->toBe(0);
|
||||
});
|
||||
|
||||
it('saves the timer time rounded to quarter hours on today', function () {
|
||||
Livewire::test('time::week')
|
||||
->call('saveTimer', $this->task->id, 50 * 60, 'Ottelun striimaus')
|
||||
->assertSee('0:45 kirjattu tehtävälle Mainoskuvat');
|
||||
|
||||
$entry = TimeEntryModel::query()->sole();
|
||||
|
||||
expect((float) $entry->hours)->toBe(0.75)
|
||||
->and($entry->worked_on->toDateString())->toBe(now()->toDateString())
|
||||
->and($entry->note)->toBe('Ottelun striimaus');
|
||||
});
|
||||
|
||||
it('takes the week only from the URL and the week buttons', function () {
|
||||
$this->get(route('time.week', ['viikko' => "abc'); alert(1); ('"]))->assertOk()->assertSee('Mainoskuvat');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user