Everyone sees their open tasks on an agenda, their open jobs, this week's hours and quick links. Admin and management also get a lazily loaded management panel: things to do, the month so far against the previous month, jobs and late work, and everyone's workload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
42 lines
2.0 KiB
PHP
42 lines
2.0 KiB
PHP
<?php
|
|
|
|
use App\Modules\Dashboard\Domain\Enums\AgendaBucket;
|
|
use App\Modules\Dashboard\Domain\ValueObjects\Change;
|
|
use App\Modules\Dashboard\Domain\ValueObjects\Workload;
|
|
|
|
it('puts open tasks on the agenda by their nearest date', function (?string $due, ?string $start, AgendaBucket $bucket) {
|
|
// Wednesday 25.11.2026: tomorrow is Thursday, the week ends on Sunday.
|
|
expect(AgendaBucket::of($due, $start, '2026-11-25', '2026-11-26', '2026-11-29'))->toBe($bucket);
|
|
})->with([
|
|
'due yesterday' => ['2026-11-24', null, AgendaBucket::Overdue],
|
|
'due yesterday, started earlier' => ['2026-11-24', '2026-11-01', AgendaBucket::Overdue],
|
|
'due today' => ['2026-11-25', null, AgendaBucket::Soon],
|
|
'under way since Monday' => ['2026-12-10', '2026-11-23', AgendaBucket::Soon],
|
|
'starts tomorrow' => [null, '2026-11-26', AgendaBucket::Soon],
|
|
'due on Sunday' => ['2026-11-29', null, AgendaBucket::ThisWeek],
|
|
'starts next week' => [null, '2026-11-30', AgendaBucket::Later],
|
|
'no dates' => [null, null, AgendaBucket::Later],
|
|
]);
|
|
|
|
it('counts working days without weekends and holidays', function () {
|
|
expect(Workload::workingDays('2026-12-21', '2026-12-27', ['2026-12-24', '2026-12-25', '2026-12-26']))->toBe(3)
|
|
->and(Workload::workingDays('2026-11-23', '2026-11-29', []))->toBe(5);
|
|
});
|
|
|
|
it('compares the workload with the capacity', function () {
|
|
$load = Workload::of(2700, 480, 5);
|
|
|
|
expect($load->capacityMinutes)->toBe(2400)
|
|
->and($load->ratio())->toBe(1.125)
|
|
->and($load->isOverloaded())->toBeTrue()
|
|
->and(Workload::of(0, 480, 0)->ratio())->toBeNull()
|
|
->and(Workload::of(2400, 480, 5)->isOverloaded())->toBeFalse();
|
|
});
|
|
|
|
it('gives the change from the earlier value, none from zero', function () {
|
|
expect((new Change(150, 100))->ratio())->toBe(0.5)
|
|
->and((new Change(50, 100))->ratio())->toBe(-0.5)
|
|
->and((new Change(-50, -100))->ratio())->toBe(0.5)
|
|
->and((new Change(10, 0))->ratio())->toBeNull();
|
|
});
|