- A task now has one optional assignee (tasks.assignee_user_id), whose calendar row it is on and whose days its estimate books, and members (task_members) who see it among their own jobs and in the weekly sheet but get no bookings. A migration moves existing assignees over: the one with most booked time becomes the assignee, the others members. - Adding tasks from a workflow template asks for each step's assignee and, by default, schedules tasks with a due date to end on it, booking the estimate backwards from the due date (not before today); what does not fit runs past the due date and is reported as late. - The task calendar leaves quick sale tasks out of the unscheduled list, shows a bar's job details in a popover on hover and focus, and shows the day load on its own grid line. - The template table stacks its cells on narrow screens to reflow at 320 px. Co-Authored-By: Claude Opus 5.5 <[email protected]>
91 lines
4.5 KiB
PHP
91 lines
4.5 KiB
PHP
<?php
|
|
|
|
use App\Modules\Jobs\Application\Services\ChecklistItemFinder;
|
|
use App\Modules\Jobs\Application\UseCases\AddChecklistItem;
|
|
use App\Modules\Jobs\Application\UseCases\CheckChecklistItem;
|
|
use App\Modules\Jobs\Application\UseCases\MoveChecklistItem;
|
|
use App\Modules\Jobs\Application\UseCases\RemoveChecklistItem;
|
|
use App\Modules\Jobs\Application\UseCases\RenameChecklistItem;
|
|
use App\Modules\Jobs\Domain\Entities\Task;
|
|
use App\Modules\Jobs\Domain\Enums\MoveDirection;
|
|
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
|
use App\Modules\Jobs\Domain\Exceptions\ChecklistItemNotFound;
|
|
use App\Modules\Jobs\Domain\Exceptions\InvalidChecklistItemText;
|
|
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
|
use App\Modules\Jobs\Domain\ValueObjects\ChecklistItemText;
|
|
use App\Modules\Jobs\Domain\ValueObjects\TaskTitle;
|
|
use Tests\Fakes\FakeClock;
|
|
use Tests\Fakes\FakeTransactionManager;
|
|
use Tests\Fakes\InMemoryChecklistItemRepository;
|
|
use Tests\Fakes\InMemoryTaskRepository;
|
|
|
|
beforeEach(function () {
|
|
$tasks = new InMemoryTaskRepository;
|
|
$this->items = new InMemoryChecklistItemRepository;
|
|
$transactions = new FakeTransactionManager;
|
|
$finder = new ChecklistItemFinder($tasks, $this->items);
|
|
|
|
$this->jobId = 5;
|
|
$this->taskId = (int) $tasks->save(Task::reconstitute(1, $this->jobId, 11, new TaskTitle('Kuvaus'), null, TaskStatus::Waiting, null, null, null, [], 10))->id();
|
|
|
|
$this->add = new AddChecklistItem($finder, $this->items, $transactions);
|
|
$this->rename = new RenameChecklistItem($finder, $this->items, $transactions);
|
|
$this->check = new CheckChecklistItem($finder, $this->items, $transactions, new FakeClock(new DateTimeImmutable('2026-11-24')));
|
|
$this->move = new MoveChecklistItem($finder, $this->items, $transactions);
|
|
$this->remove = new RemoveChecklistItem($finder, $this->items, $transactions);
|
|
});
|
|
|
|
it('normalises checklist item text and rejects empty and too long text', function () {
|
|
expect((new ChecklistItemText(" Tarkista valot \n"))->value)->toBe('Tarkista valot')
|
|
->and(fn () => new ChecklistItemText(' '))->toThrow(InvalidChecklistItemText::class)
|
|
->and(fn () => new ChecklistItemText(str_repeat('a', 256)))->toThrow(InvalidChecklistItemText::class);
|
|
});
|
|
|
|
it('adds items to the end of the task checklist', function () {
|
|
$this->add->execute($this->jobId, $this->taskId, 'Valot');
|
|
$this->add->execute($this->jobId, $this->taskId, 'Mikit');
|
|
|
|
expect($this->items->textsOf($this->taskId))->toBe(['Valot', 'Mikit']);
|
|
});
|
|
|
|
it('does not touch the checklist of a task through another job', function () {
|
|
$itemId = $this->add->execute($this->jobId, $this->taskId, 'Valot');
|
|
|
|
expect(fn () => $this->add->execute(99, $this->taskId, 'Mikit'))->toThrow(TaskNotFound::class)
|
|
->and(fn () => $this->remove->execute(99, $this->taskId, $itemId))->toThrow(TaskNotFound::class)
|
|
->and(fn () => $this->remove->execute($this->jobId, $this->taskId, 404))->toThrow(ChecklistItemNotFound::class);
|
|
});
|
|
|
|
it('checks an item with who and when, keeps them on a second check and clears them on uncheck', function () {
|
|
$itemId = $this->add->execute($this->jobId, $this->taskId, 'Valot');
|
|
|
|
$this->check->execute($this->jobId, $this->taskId, $itemId, true, 10);
|
|
$this->check->execute($this->jobId, $this->taskId, $itemId, true, 12);
|
|
$item = $this->items->items[$itemId];
|
|
|
|
expect($item->isDone())->toBeTrue()
|
|
->and($item->doneBy())->toBe(10)
|
|
->and($item->doneAt()?->format('Y-m-d H:i'))->toBe('2026-11-24 12:00');
|
|
|
|
$this->check->execute($this->jobId, $this->taskId, $itemId, false, 10);
|
|
|
|
expect($this->items->items[$itemId]->isDone())->toBeFalse()
|
|
->and($this->items->items[$itemId]->doneBy())->toBeNull();
|
|
});
|
|
|
|
it('renames, moves and removes items', function () {
|
|
$first = $this->add->execute($this->jobId, $this->taskId, 'Valot');
|
|
$second = $this->add->execute($this->jobId, $this->taskId, 'Mikit');
|
|
|
|
$this->rename->execute($this->jobId, $this->taskId, $first, 'Valot ja jalustat');
|
|
|
|
expect($this->move->execute($this->jobId, $this->taskId, $first, MoveDirection::Up))->toBeFalse()
|
|
->and($this->move->execute($this->jobId, $this->taskId, $second, MoveDirection::Down))->toBeFalse()
|
|
->and($this->move->execute($this->jobId, $this->taskId, $first, MoveDirection::Down))->toBeTrue()
|
|
->and($this->items->textsOf($this->taskId))->toBe(['Mikit', 'Valot ja jalustat']);
|
|
|
|
$this->remove->execute($this->jobId, $this->taskId, $second);
|
|
|
|
expect($this->items->textsOf($this->taskId))->toBe(['Valot ja jalustat']);
|
|
});
|