user = User::factory()->management()->create(['name' => 'Johanna Johto']); $this->other = User::factory()->create(['name' => 'Aino Ahkera']); $this->actingAs($this->user); $job = CustomerJobModel::factory()->create(['name' => 'Messuvideo', 'status' => 'order', 'responsible_user_id' => $this->user->id]); $workType = WorkTypeModel::query()->where('name', 'graafinen työ')->sole(); $this->task = TaskModel::factory()->assignedTo([$this->user->id])->create([ 'customer_job_id' => $job->id, 'work_type_id' => $workType->id, 'title' => 'Leikkaus', 'estimated_hours' => 4, 'due_on' => now()->addDay()->toDateString(), 'planned_from' => now()->toDateString(), 'planned_to' => now()->addDays(2)->toDateString(), ]); TaskModel::factory()->assignedTo([$this->other->id])->create(['customer_job_id' => $job->id, 'work_type_id' => $workType->id, 'title' => 'Värimäärittely']); }); it('has no accessibility issues on the task calendar', function (string $device, string $colorScheme) { $visit = visit(route('jobs.calendar')); $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); $visit->assertNoJavaScriptErrors() ->assertSee('Leikkaus') ->assertSee('Värimäärittely') ->assertNoAccessibilityIssues(level: 2); })->with([ 'desktop, light' => ['desktop', 'light'], 'desktop, dark' => ['desktop', 'dark'], 'mobile, light' => ['mobile', 'light'], 'mobile, dark' => ['mobile', 'dark'], ]); it('reschedules a task with the keyboard and returns focus to its bar', function () { $key = $this->task->id.'-'.$this->user->id; visit(route('jobs.calendar')) ->on()->desktop() ->keys('#bar-'.$key, 'Enter') ->assertSee('Tehtävän aikataulu') ->assertNoAccessibilityIssues(level: 2) ->type('#task-schedule-dialog [wire\:model="plannedFrom"]', now()->addDay()->format('Y-m-d')) ->type('#task-schedule-dialog [wire\:model="plannedTo"]', now()->addDays(3)->format('Y-m-d')) ->press('#task-schedule-dialog [wire\:click="saveDialog"]') ->assertSee('Tehtävä Leikkaus: Johanna Johto '.now()->addDay()->format('j.n.Y').'–'.now()->addDays(3)->format('j.n.Y').'.') ->assertScript('document.activeElement.id', 'bar-'.$key); expect($this->task->refresh()->planned_from?->format('Y-m-d'))->toBe(now()->addDay()->toDateString()); }); it('moves a task to another person by dragging its bar', function () { // The bar (today – today + 2) is grabbed at its middle day, so dropping it // on today + 4 moves it three days later. $day = now()->addDays(4)->toDateString(); visit(route('jobs.calendar')) ->on()->desktop() ->drag('#bar-'.$this->task->id.'-'.$this->user->id, '[data-calendar-day="'.$day.'"][data-calendar-user="'.$this->other->id.'"]') ->assertSee('Tehtävä Leikkaus: Aino Ahkera'); expect($this->task->refresh()->planned_from?->format('Y-m-d'))->toBe(now()->addDays(3)->toDateString()) ->and(DB::table('task_assignees')->where('task_id', $this->task->id)->pluck('user_id')->all())->toBe([$this->other->id]); }); it('has no accessibility issues on the holidays page', function (string $colorScheme) { $this->actingAs(User::factory()->admin()->create()); $visit = visit(route('settings.holidays')); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); $visit->assertNoJavaScriptErrors() ->assertSee('Itsenäisyyspäivä') ->assertNoAccessibilityIssues(level: 2); })->with(['light', 'dark']);