Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
88 lines
4.0 KiB
PHP
88 lines
4.0 KiB
PHP
<?php
|
||
|
||
use App\Models\User;
|
||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
|
||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
use Illuminate\Support\Facades\DB;
|
||
|
||
uses(RefreshDatabase::class);
|
||
|
||
beforeEach(function () {
|
||
$this->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']);
|