Add notifications: header bell, task start run and assignment notices

A new Notifications module shows a bell beside the profile menu with the
number of unseen notifications and a panel of the last 7 days; opening
it marks them seen, and each notification links to its job or task.

- A daily run at 14.00 (notifications:task-starts) tells the assignee
  and members of tasks that start by the next working day, skipping
  holidays and days off, done tasks and archived jobs.
- Jobs publishes PeopleAddedToTask and PeopleAddedToJob when someone
  else makes a user a task's assignee or member or gives them a role on
  a job; those users are notified at once. UpdateTask and ScheduleTask
  now take the acting user.
- A notification link to #task-<id> opens that task card on the job page.

Also: simplifying job fields per service unit (K31) moves to the end of
phase 4, and the workflow template browser test waits for Livewire's
progress bar before its last accessibility check.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-25 08:28:01 +02:00
co-authored by Claude Sonnet 5.5
parent ae8172898d
commit f906f9a43f
48 changed files with 1665 additions and 31 deletions
@@ -6,16 +6,19 @@ use App\Modules\Jobs\Application\UseCases\ChangeJobStatus;
use App\Modules\Jobs\Application\UseCases\CreateCustomerJob;
use App\Modules\Jobs\Application\UseCases\UpdateCustomerJob;
use App\Modules\Jobs\Domain\Enums\JobStatus;
use App\Modules\Jobs\Domain\Events\PeopleAddedToJob;
use App\Modules\Jobs\Domain\Exceptions\InvalidJobReference;
use App\Modules\Users\Domain\Enums\Role;
use Tests\Fakes\FakeCatalogQueries;
use Tests\Fakes\FakeClock;
use Tests\Fakes\FakeCustomerQueries;
use Tests\Fakes\FakeEventDispatcher;
use Tests\Fakes\FakeTransactionManager;
use Tests\Fakes\FakeUserAccountQueries;
use Tests\Fakes\InMemoryCustomerJobRepository;
beforeEach(function () {
$this->events = new FakeEventDispatcher;
$this->jobs = new InMemoryCustomerJobRepository;
$this->customers = new FakeCustomerQueries;
$this->catalog = new FakeCatalogQueries;
@@ -33,8 +36,8 @@ beforeEach(function () {
$this->users->addUser(12, 'Pois', active: false);
$factory = new JobDetailsFactory($this->customers, $this->catalog, $this->users);
$this->create = new CreateCustomerJob($this->jobs, $this->jobs, $factory, $transactions, $this->clock);
$this->update = new UpdateCustomerJob($this->jobs, $factory, $transactions, $this->clock);
$this->create = new CreateCustomerJob($this->jobs, $this->jobs, $factory, $transactions, $this->clock, $this->events);
$this->update = new UpdateCustomerJob($this->jobs, $factory, $transactions, $this->clock, $this->events);
$this->changeStatus = new ChangeJobStatus($this->jobs, $transactions, new FakeClock(new DateTimeImmutable('2026-05-01')));
});
@@ -104,3 +107,21 @@ it('records each changed field, and nothing when nothing changed', function () {
expect($this->jobs->changedFields($jobId))->toBe(['created', 'priority', 'customer_contact', 'tags', 'status']);
});
it('publishes the new roles people got on a job', function () {
$jobId = $this->create->execute(jobData(['memberUserIds' => [11]]), 10);
$added = end($this->events->dispatched);
expect($added)->toBeInstanceOf(PeopleAddedToJob::class)
->and($added->jobId)->toBe($jobId)
->and($added->jobName)->toBe('Messuvideo')
->and($added->newRoles)->toBe([10 => ['responsible'], 11 => ['member']])
->and($added->actorUserId)->toBe(10);
$count = count($this->events->dispatched);
$this->update->execute($jobId, jobData(['memberUserIds' => [11], 'name' => 'Messuvideo 2']), 10);
expect($this->events->dispatched)->toHaveCount($count);
$this->update->execute($jobId, jobData(['memberUserIds' => [11], 'contactUserId' => 11]), 10);
expect(end($this->events->dispatched)->newRoles)->toBe([11 => ['contact']]);
});