On touch screens a tap on a task bar both showed its info popover and opened the schedule dialog. A tap now only opens the popover, which stays open until something else is tapped, and the popover's own "Open schedule" button opens the dialog. Mouse clicks and Enter still open the dialog directly. The popover is no longer a tooltip since it holds a button, and the bar's aria-describedby points only at the details. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
148 lines
6.6 KiB
PHP
148 lines
6.6 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) {
|
||
// A day over the daily capacity and a late task (Leikkaus ends after its due date) get warning colours.
|
||
DB::table('task_bookings')->insert([
|
||
['task_id' => $this->task->id, 'user_id' => $this->user->id, 'day' => now()->toDateString(), 'minutes' => 600],
|
||
['task_id' => $this->task->id, 'user_id' => $this->user->id, 'day' => now()->addDays(2)->toDateString(), 'minutes' => 60],
|
||
]);
|
||
|
||
$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')
|
||
->assertSee('Myöhässä');
|
||
|
||
// Phones show an agenda list without the daily load.
|
||
if ($device === 'desktop') {
|
||
$visit->assertSee('10 / 7,5 h');
|
||
}
|
||
|
||
$visit->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')
|
||
->assertValue('#task-schedule-due-on', now()->addDay()->format('j.n.Y'))
|
||
->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('shows the job details of a bar on hover and focus, and closes them with Escape', function (string $colorScheme) {
|
||
$key = $this->task->id.'-'.$this->user->id;
|
||
$open = "document.getElementById('bar-info-{$key}').matches(':popover-open')";
|
||
|
||
$visit = visit(route('jobs.calendar'))->on()->desktop();
|
||
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||
|
||
$visit->hover('#bar-'.$key)
|
||
->assertScript($open, true)
|
||
->assertSee('Messuvideo')
|
||
->assertSee('Johanna Johto')
|
||
->assertNoAccessibilityIssues(level: 2)
|
||
->hover('#bar-info-'.$key)
|
||
->assertScript($open, true)
|
||
->keys('#bar-'.$key, 'Escape')
|
||
->assertScript($open, false)
|
||
->keys('#bar-'.$key, 'Tab')
|
||
->keys('#bar-'.$key, 'Shift')
|
||
->assertScript($open, true)
|
||
->assertNoJavaScriptErrors();
|
||
})->with(['light', 'dark']);
|
||
|
||
it('opens only the popover on a tap, and the dialog from its button', function () {
|
||
$key = $this->task->id.'-'.$this->user->id;
|
||
$open = "document.getElementById('bar-info-{$key}').matches(':popover-open')";
|
||
$tap = <<<JS
|
||
(() => {
|
||
const bar = document.getElementById('bar-{$key}');
|
||
const options = { bubbles: true, pointerType: 'touch', isPrimary: true, button: 0 };
|
||
bar.dispatchEvent(new PointerEvent('pointerdown', options));
|
||
bar.dispatchEvent(new PointerEvent('pointerup', options));
|
||
bar.dispatchEvent(new MouseEvent('mouseenter'));
|
||
bar.click();
|
||
})()
|
||
JS;
|
||
|
||
$visit = visit(route('jobs.calendar'))->on()->desktop();
|
||
$visit->script($tap);
|
||
$visit->assertScript($open, true)
|
||
->assertScript("document.getElementById('task-schedule-dialog').open", false)
|
||
->click('#bar-info-'.$key.'-open')
|
||
->assertSee('Tehtävän aikataulu')
|
||
->assertScript("document.getElementById('task-schedule-dialog').open", true)
|
||
->assertScript($open, false);
|
||
});
|
||
|
||
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($this->task->assignee_user_id)->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']);
|