Add the task calendar, holidays, workflow templates and customer removal
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]>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Application\DTOs\WorkflowStepData;
|
||||
use App\Modules\Catalog\Application\DTOs\WorkflowTemplateData;
|
||||
use App\Modules\Catalog\Application\UseCases\AddWorkflowTemplate;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ProductModel;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\VatRateModel;
|
||||
@@ -20,6 +23,10 @@ it('has no accessibility issues on the catalog pages', function (string $page, s
|
||||
$workType->update(['hourly_rate_cents' => 9500]);
|
||||
$product = ProductModel::factory()->consumer()->create(['name' => 'Passikuvat', 'auto_hours' => 0.25, 'work_type_id' => WorkTypeModel::query()->where('name', 'passikuvat')->sole()->id]);
|
||||
ProductModel::factory()->inactive()->create(['name' => 'Vanha tuloste']);
|
||||
$templateId = app(AddWorkflowTemplate::class)->execute(new WorkflowTemplateData('Lyhyt video', $workType->id, [
|
||||
new WorkflowStepData('Suunnittelu', null, WorkTypeModel::query()->where('name', 'suunnittelu')->sole()->id),
|
||||
new WorkflowStepData('Kuvaus', 'Kuvauspäivä asiakkaalla'),
|
||||
]));
|
||||
|
||||
$url = match ($page) {
|
||||
'catalog' => route('catalog.index'),
|
||||
@@ -31,6 +38,9 @@ it('has no accessibility issues on the catalog pages', function (string $page, s
|
||||
'edit product' => route('catalog.products.edit', $product->id),
|
||||
'edit VAT rate' => route('catalog.vat-rates.edit', VatRateModel::query()->where('is_default', true)->value('id')),
|
||||
'read-only price list' => route('catalog.price-list'),
|
||||
'workflow templates' => route('catalog.workflow-templates'),
|
||||
'new workflow template' => route('catalog.workflow-templates.create'),
|
||||
'edit workflow template' => route('catalog.workflow-templates.edit', $templateId),
|
||||
};
|
||||
|
||||
$visit = visit($url);
|
||||
@@ -39,7 +49,7 @@ it('has no accessibility issues on the catalog pages', function (string $page, s
|
||||
|
||||
$visit->assertNoJavaScriptErrors()
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with(['catalog', 'new service unit', 'new service', 'edit work type', 'price list', 'new product', 'edit product', 'edit VAT rate', 'read-only price list'])->with([
|
||||
})->with(['catalog', 'new service unit', 'new service', 'edit work type', 'price list', 'new product', 'edit product', 'edit VAT rate', 'read-only price list', 'workflow templates', 'new workflow template', 'edit workflow template'])->with([
|
||||
'desktop, light' => ['desktop', 'light'],
|
||||
'desktop, dark' => ['desktop', 'dark'],
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
@@ -96,3 +106,17 @@ it('has no accessibility issues on the price list of an employee without the pri
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
'mobile, dark' => ['mobile', 'dark'],
|
||||
]);
|
||||
|
||||
it('adds and moves workflow steps with the keyboard, keeping focus and announcing it', function () {
|
||||
visit(route('catalog.workflow-templates.create'))
|
||||
->type('#step-1-title', 'Kuvaus')
|
||||
->keys('#add-step', 'Enter')
|
||||
->assertSee('Vaihe 2 lisätty.')
|
||||
->assertScript('document.activeElement.id', 'step-2-title')
|
||||
->type('#step-2-title', 'Suunnittelu')
|
||||
->keys('#step-2-up', 'Enter')
|
||||
->assertSee('Vaihe 2 siirretty kohtaan 1.')
|
||||
->assertScript('document.activeElement.id', 'step-2-up')
|
||||
->assertScript('document.querySelector("ol input").value', 'Suunnittelu')
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
});
|
||||
|
||||
@@ -137,6 +137,30 @@ it('removes a contact with the keyboard, in a dialog that keeps and returns focu
|
||||
->assertSee('Pekka');
|
||||
})->with(['light', 'dark']);
|
||||
|
||||
it('removes a customer with nothing linked to it with the keyboard, and offers no removal for one with a contact', function (string $colorScheme) {
|
||||
$empty = CustomerModel::factory()->create(['name' => 'Turha Oy']);
|
||||
$linked = CustomerModel::factory()->create(['name' => 'Mainos Oy']);
|
||||
CustomerContactModel::factory()->create(['customer_id' => $linked->id, 'name' => 'Maija']);
|
||||
|
||||
$removeCustomer = '[wire\:click^="confirmRemoval(\'customer\'"]';
|
||||
|
||||
visit(route('customers.show', $linked->id))
|
||||
->assertSee('Maija')
|
||||
->assertDontSee('Poista asiakas');
|
||||
|
||||
$page = visit(route('customers.show', $empty->id));
|
||||
$page = $colorScheme === 'dark' ? $page->inDarkMode() : $page->inLightMode();
|
||||
|
||||
// Removed: the dialog takes focus, then the list shows a status message.
|
||||
$page->keys($removeCustomer, 'Enter')
|
||||
->assertSee('Poistetaanko asiakas Turha Oy?')
|
||||
->assertScript('document.getElementById("remove-dialog").contains(document.activeElement)', true)
|
||||
->assertNoAccessibilityIssues(level: 2)
|
||||
->click('#remove-dialog [wire\:click="remove"]')
|
||||
->assertSee('Asiakas Turha Oy poistettu.')
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with(['light', 'dark']);
|
||||
|
||||
it('has no accessibility issues with a consumer\'s personal identity code', function (string $page, string $device, string $colorScheme) {
|
||||
$this->actingAs(User::factory()->management()->create());
|
||||
$consumer = CustomerModel::factory()->consumer()->create([
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Application\DTOs\WorkflowStepData;
|
||||
use App\Modules\Catalog\Application\DTOs\WorkflowTemplateData;
|
||||
use App\Modules\Catalog\Application\UseCases\AddWorkflowTemplate;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
|
||||
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||
@@ -229,3 +232,34 @@ it('adds, checks, renames, moves and removes checklist items with the keyboard',
|
||||
->assertScript('document.activeElement.id', 'checklist-new-'.$task->id)
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
});
|
||||
|
||||
it('adds tasks from a workflow template with the keyboard, without accessibility issues', function (string $device, string $colorScheme) {
|
||||
$this->job->update(['status' => 'order']);
|
||||
$workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole();
|
||||
$templateId = app(AddWorkflowTemplate::class)->execute(new WorkflowTemplateData('Lyhyt video', $workType->id, [
|
||||
new WorkflowStepData('Suunnittelu', null, WorkTypeModel::query()->where('name', 'suunnittelu')->sole()->id),
|
||||
new WorkflowStepData('Kuvaus'),
|
||||
]));
|
||||
|
||||
$visit = visit(route('jobs.tasks.from-template', $this->job->id));
|
||||
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||
|
||||
$visit->assertNoJavaScriptErrors()
|
||||
->assertNoAccessibilityIssues(level: 2)
|
||||
->keys('[value="'.$templateId.'"]', 'Space')
|
||||
->assertSee('Pohjan Lyhyt video tehtävät')
|
||||
->assertNoAccessibilityIssues(level: 2)
|
||||
->type('#row-1-hours', '2,5')
|
||||
->keys('main form button[type="submit"]', 'Enter')
|
||||
->assertSee('Lisättiin 2 tehtävää pohjasta Lyhyt video (videokuvaus).')
|
||||
->assertSee('Suunnittelu')
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
|
||||
expect(TaskModel::query()->where('customer_job_id', $this->job->id)->orderBy('id')->pluck('estimated_hours')->map(fn ($hours) => $hours === null ? null : (float) $hours)->all())->toBe([null, 2.5]);
|
||||
})->with([
|
||||
'desktop, light' => ['desktop', 'light'],
|
||||
'desktop, dark' => ['desktop', 'dark'],
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
'mobile, dark' => ['mobile', 'dark'],
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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']);
|
||||
Reference in New Issue
Block a user