Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 / primary-100 and TallStackUI's dark labels, hints and checkbox labels are lightened so everything stays at 4.5:1. - Shared HexColor picks white or black text by the higher WCAG contrast; a native-dialog colour picker and a large work dialog component. - Customers get a header colour (customers.header_color), set on the customer page. - New job status Jatkuvat / Kausi (ongoing): open, never late, billed monthly like running jobs. - Kanban model: board columns and views, urgent threshold, per-user board preferences (density, column colours and sort), card positions, tasks of continuing jobs pinned to the board, MoveBoardCard and board queries with logged hours from TimeTracking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -35,6 +35,11 @@ class FakeCustomerQueries implements CustomerQueries
|
||||
return array_intersect_key($this->customers, array_flip($ids));
|
||||
}
|
||||
|
||||
public function headerColorsByIds(array $ids): array
|
||||
{
|
||||
return array_fill_keys(array_keys(array_intersect_key($this->customers, array_flip($ids))), null);
|
||||
}
|
||||
|
||||
public function internalCustomerId(): ?int
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
||||
|
||||
class InMemoryBoardRepository implements BoardRepository
|
||||
{
|
||||
/** @var array<int, int> */
|
||||
public array $jobPositions = [];
|
||||
|
||||
/** @var array<int, int> */
|
||||
public array $taskPositions = [];
|
||||
|
||||
/** @var array<int, bool> */
|
||||
public array $pinnedTasks = [];
|
||||
|
||||
/** @var array<int, BoardPreferences> */
|
||||
public array $preferences = [];
|
||||
|
||||
public function setJobPositions(array $positions): void
|
||||
{
|
||||
$this->jobPositions = $positions + $this->jobPositions;
|
||||
}
|
||||
|
||||
public function setTaskPositions(array $positions): void
|
||||
{
|
||||
$this->taskPositions = $positions + $this->taskPositions;
|
||||
}
|
||||
|
||||
public function setTaskPinned(int $taskId, bool $pinned): void
|
||||
{
|
||||
$this->pinnedTasks[$taskId] = $pinned;
|
||||
}
|
||||
|
||||
public function preferencesOf(int $userId): BoardPreferences
|
||||
{
|
||||
return $this->preferences[$userId] ?? BoardPreferences::defaults();
|
||||
}
|
||||
|
||||
public function savePreferences(int $userId, BoardPreferences $preferences): void
|
||||
{
|
||||
$this->preferences[$userId] = $preferences;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class InMemoryCustomerRepository implements CustomerRepository
|
||||
public function save(Customer $customer): Customer
|
||||
{
|
||||
$id = $customer->id() ?? $this->nextId++;
|
||||
$stored = Customer::reconstitute($id, $customer->name(), $customer->type(), $customer->businessId(), $customer->personalIdentityCode(), $customer->isInternal());
|
||||
$stored = Customer::reconstitute($id, $customer->name(), $customer->type(), $customer->businessId(), $customer->personalIdentityCode(), $customer->isInternal(), $customer->headerColor());
|
||||
|
||||
$this->customers[$id] = $stored;
|
||||
|
||||
|
||||
@@ -287,6 +287,27 @@ it('bills every unbilled month of a monthly fee job on an invoice of its own and
|
||||
->toBe(['2026-09', '2026-10', '2026-11', '2026-12']);
|
||||
});
|
||||
|
||||
it('bills a monthly fee job in the ongoing status monthly and keeps it ongoing', function () {
|
||||
$this->travelTo(now()->setDate(2026, 11, 20)->setTime(12, 0));
|
||||
|
||||
$season = doneJob([
|
||||
'name' => 'Kausihuolto',
|
||||
'status' => JobStatus::Ongoing,
|
||||
'payment_basis' => 'monthly_fee',
|
||||
'monthly_fee_cents' => 12000,
|
||||
'starts_on' => '2026-10-01',
|
||||
]);
|
||||
|
||||
Livewire::test('billing::export', ['export' => openDraft()])
|
||||
->assertSee('Kausihuolto')
|
||||
->call('finalize')
|
||||
->assertSet('errorMessage', '');
|
||||
|
||||
expect(BillingLineModel::query()->where('customer_job_id', $season->id)->where('kind', LineKind::MonthlyFee)->pluck('period')->all())
|
||||
->toBe(['2026-10', '2026-11'])
|
||||
->and($season->refresh()->status)->toBe(JobStatus::Ongoing);
|
||||
});
|
||||
|
||||
it('does not bill a monthly fee job without a monthly fee', function () {
|
||||
$job = doneJob(['status' => JobStatus::InProduction, 'payment_basis' => 'monthly_fee']);
|
||||
|
||||
|
||||
@@ -101,3 +101,29 @@ it('keeps the customer its own business id when editing', function () {
|
||||
it('returns 404 for an unknown customer', function () {
|
||||
$this->get(route('customers.edit', 999))->assertNotFound();
|
||||
});
|
||||
|
||||
it('saves and resets the customer colour from the customer page', function () {
|
||||
$customer = CustomerModel::factory()->create(['name' => 'Värikäs Oy']);
|
||||
|
||||
Livewire::test('customers::show', ['customer' => $customer->id])
|
||||
->assertSee('Tunnusväri')
|
||||
->call('setHeaderColor', '#B91C1C')
|
||||
->assertSee('Asiakkaan tunnusväri tallennettu.');
|
||||
|
||||
expect($customer->fresh()->header_color)->toBe('#b91c1c');
|
||||
|
||||
Livewire::test('customers::show', ['customer' => $customer->id])
|
||||
->call('setHeaderColor', null);
|
||||
|
||||
expect($customer->fresh()->header_color)->toBeNull();
|
||||
});
|
||||
|
||||
it('refuses a colour that is not a hex colour', function () {
|
||||
$customer = CustomerModel::factory()->create();
|
||||
|
||||
Livewire::test('customers::show', ['customer' => $customer->id])
|
||||
->call('setHeaderColor', 'url(javascript:alert(1))')
|
||||
->assertSee('Väri ei kelpaa');
|
||||
|
||||
expect($customer->fresh()->header_color)->toBeNull();
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ it('shows the Kanban columns in order with my jobs, without archived ones', func
|
||||
->assertSee('Tilattu työ')
|
||||
->assertDontSee('Arkistoitu työ')
|
||||
->assertDontSee('Muiden työ')
|
||||
->assertSeeInOrder(['Prospekti', 'Alustava', 'Tarjouspyyntö', 'Tilaus', 'Tuotannossa', 'Keskeytetty', 'Valmis', 'Lasku luotu', 'Laskutettu'])
|
||||
->assertSeeInOrder(['Prospekti', 'Alustava', 'Tarjouspyyntö', 'Tilaus', 'Tuotannossa', 'Keskeytetty', 'Valmis', 'Lasku luotu', 'Laskutettu', 'Jatkuvat / Kausi'])
|
||||
->set('mine', false)
|
||||
->assertSee('Muiden työ');
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Customers\Application\UseCases\ChangeCustomerHeaderColor;
|
||||
use App\Modules\Customers\Domain\Entities\Customer;
|
||||
use App\Modules\Customers\Domain\Enums\CustomerType;
|
||||
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
|
||||
use App\Modules\Customers\Domain\ValueObjects\CustomerName;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
||||
use Tests\Fakes\FakeTransactionManager;
|
||||
use Tests\Fakes\InMemoryCustomerRepository;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->customers = new InMemoryCustomerRepository;
|
||||
$this->changeColor = new ChangeCustomerHeaderColor($this->customers, new FakeTransactionManager);
|
||||
$this->customerId = $this->customers->save(Customer::register(new CustomerName('Mainos Oy'), CustomerType::Company))->id();
|
||||
});
|
||||
|
||||
it('stores the customer colour in lower case', function () {
|
||||
$this->changeColor->execute($this->customerId, '#1D4ED8');
|
||||
|
||||
expect($this->customers->findById($this->customerId)?->headerColor()?->value)->toBe('#1d4ed8');
|
||||
});
|
||||
|
||||
it('returns to the default colour with null or an empty value', function (?string $empty) {
|
||||
$this->changeColor->execute($this->customerId, '#1d4ed8');
|
||||
$this->changeColor->execute($this->customerId, $empty);
|
||||
|
||||
expect($this->customers->findById($this->customerId)?->headerColor())->toBeNull();
|
||||
})->with([null, '']);
|
||||
|
||||
it('rejects a value that is not a colour', function () {
|
||||
$this->changeColor->execute($this->customerId, 'blue');
|
||||
})->throws(InvalidHexColor::class);
|
||||
|
||||
it('fails for an unknown customer', function () {
|
||||
$this->changeColor->execute(999, '#1d4ed8');
|
||||
})->throws(CustomerNotFound::class);
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Jobs\Application\DTOs\BoardCard;
|
||||
use App\Modules\Jobs\Application\DTOs\CustomerJobData;
|
||||
use App\Modules\Jobs\Application\DTOs\TaskData;
|
||||
use App\Modules\Jobs\Application\Services\BoardLayout;
|
||||
use App\Modules\Jobs\Application\Services\JobDetailsFactory;
|
||||
use App\Modules\Jobs\Application\Services\TaskPlanner;
|
||||
use App\Modules\Jobs\Application\Services\TaskReferenceChecker;
|
||||
use App\Modules\Jobs\Application\UseCases\AddTask;
|
||||
use App\Modules\Jobs\Application\UseCases\CreateCustomerJob;
|
||||
use App\Modules\Jobs\Application\UseCases\MoveBoardCard;
|
||||
use App\Modules\Jobs\Application\UseCases\PinTaskToBoard;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardColumn;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardView;
|
||||
use App\Modules\Jobs\Domain\Enums\ColumnSort;
|
||||
use App\Modules\Jobs\Domain\Enums\JobKind;
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\Priority;
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\UrgentThreshold;
|
||||
use App\Modules\Jobs\Domain\Events\TaskCompleted;
|
||||
use App\Modules\Jobs\Domain\Exceptions\CardCannotMoveThere;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TaskCannotBePinned;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
||||
use App\Modules\Shared\Application\UseCases\DailyCapacity;
|
||||
use App\Modules\Shared\Application\UseCases\HolidayCalendar;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
use Tests\Fakes\FakeCatalogQueries;
|
||||
use Tests\Fakes\FakeClock;
|
||||
use Tests\Fakes\FakeCustomerQueries;
|
||||
use Tests\Fakes\FakeEventDispatcher;
|
||||
use Tests\Fakes\FakeSettings;
|
||||
use Tests\Fakes\FakeTransactionManager;
|
||||
use Tests\Fakes\FakeUserAccountQueries;
|
||||
use Tests\Fakes\InMemoryBoardRepository;
|
||||
use Tests\Fakes\InMemoryCustomerJobRepository;
|
||||
use Tests\Fakes\InMemoryHolidayOverrides;
|
||||
use Tests\Fakes\InMemoryTaskBookingRepository;
|
||||
use Tests\Fakes\InMemoryTaskRepository;
|
||||
|
||||
function boardCard(int $jobId, JobStatus $status, Priority $priority = Priority::Normal, ?string $dueOn = null, int $position = 0, ?int $taskId = null, ?TaskStatus $taskStatus = null): BoardCard
|
||||
{
|
||||
return new BoardCard(
|
||||
jobId: $jobId, taskId: $taskId, number: '2026-'.$jobId, title: 'Työ '.$jobId, jobName: 'Työ '.$jobId,
|
||||
customerId: 1, customerName: 'Mainos Oy', customerHeaderColor: null, jobStatus: $status, taskStatus: $taskStatus,
|
||||
priority: $priority, kind: JobKind::OneOff, dueOn: $dueOn, isLate: false, responsibleName: 'Eero Esimerkki',
|
||||
serviceUnitName: null, estimatedHours: null, loggedQuarters: 0, boardPosition: $position, billerUserId: null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, list<BoardCard>> $columns
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
function boardKeys(array $columns): array
|
||||
{
|
||||
return array_map(fn (array $cards): array => array_map(fn (BoardCard $card): string => $card->key(), $cards), $columns);
|
||||
}
|
||||
|
||||
describe('board layout', function () {
|
||||
it('gathers the quote statuses in the daily view and keeps them apart in the sales view', function () {
|
||||
$cards = [boardCard(1, JobStatus::Prospect), boardCard(2, JobStatus::Tentative), boardCard(3, JobStatus::QuoteRequest), boardCard(4, JobStatus::Order)];
|
||||
$layout = new BoardLayout;
|
||||
|
||||
expect(boardKeys($layout->arrange($cards, BoardView::Production, BoardPreferences::defaults())))
|
||||
->toMatchArray(['quotes' => ['job-1', 'job-2', 'job-3'], 'order' => ['job-4']])
|
||||
->and(array_keys($layout->arrange($cards, BoardView::Sales, BoardPreferences::defaults())))->toBe(['prospect', 'tentative', 'quote_request'])
|
||||
->and(boardKeys($layout->arrange($cards, BoardView::Sales, BoardPreferences::defaults())))->toBe(['prospect' => ['job-1'], 'tentative' => ['job-2'], 'quote_request' => ['job-3']]);
|
||||
});
|
||||
|
||||
it('splits jobs in production by the user\'s urgent threshold', function (UrgentThreshold $threshold, array $urgent) {
|
||||
$cards = [
|
||||
boardCard(1, JobStatus::InProduction, Priority::Normal),
|
||||
boardCard(2, JobStatus::InProduction, Priority::First),
|
||||
boardCard(3, JobStatus::InProduction, Priority::Urgent),
|
||||
boardCard(4, JobStatus::InProduction, Priority::Immediate),
|
||||
];
|
||||
$columns = boardKeys((new BoardLayout)->arrange($cards, BoardView::Production, BoardPreferences::defaults()->withUrgentThreshold($threshold)));
|
||||
|
||||
expect($columns['in_production_urgent'])->toBe($urgent)
|
||||
->and([...$columns['in_production'], ...$columns['in_production_urgent']])->toHaveCount(4);
|
||||
})->with([
|
||||
'only immediate' => [UrgentThreshold::Immediate, ['job-4']],
|
||||
'urgent and immediate' => [UrgentThreshold::Urgent, ['job-3', 'job-4']],
|
||||
'first, urgent and immediate' => [UrgentThreshold::First, ['job-2', 'job-3', 'job-4']],
|
||||
]);
|
||||
|
||||
it('keeps continuing jobs in their own column and places pinned tasks by their status', function () {
|
||||
$cards = [
|
||||
boardCard(1, JobStatus::Ongoing, Priority::Urgent),
|
||||
boardCard(1, JobStatus::Ongoing, taskId: 10, taskStatus: TaskStatus::Waiting),
|
||||
boardCard(1, JobStatus::Ongoing, taskId: 11, taskStatus: TaskStatus::InReview),
|
||||
boardCard(1, JobStatus::Ongoing, taskId: 12, taskStatus: TaskStatus::Done),
|
||||
];
|
||||
|
||||
expect(boardKeys((new BoardLayout)->arrange($cards, BoardView::Production, BoardPreferences::defaults())))->toMatchArray([
|
||||
'ongoing' => ['job-1'],
|
||||
'order' => ['task-10'],
|
||||
'in_production' => ['task-11'],
|
||||
'in_production_urgent' => [],
|
||||
'done' => ['task-12'],
|
||||
]);
|
||||
});
|
||||
|
||||
it('orders a column by drag order or by due date with undated cards last', function () {
|
||||
$cards = [
|
||||
boardCard(1, JobStatus::Order, dueOn: '2026-12-10', position: 10),
|
||||
boardCard(2, JobStatus::Order, dueOn: null, position: 20),
|
||||
boardCard(3, JobStatus::Order, dueOn: '2026-12-01', position: 30),
|
||||
];
|
||||
$layout = new BoardLayout;
|
||||
$byDate = BoardPreferences::defaults()->withColumnSort(BoardColumn::Order, ColumnSort::DueDate);
|
||||
|
||||
expect(boardKeys($layout->arrange($cards, BoardView::Production, BoardPreferences::defaults()))['order'])->toBe(['job-1', 'job-2', 'job-3'])
|
||||
->and(boardKeys($layout->arrange($cards, BoardView::Production, $byDate))['order'])->toBe(['job-3', 'job-1', 'job-2']);
|
||||
});
|
||||
|
||||
it('gives each column the design colour until the user picks one', function () {
|
||||
$preferences = BoardPreferences::defaults()->withColumnColor(BoardColumn::Order, new HexColor('#B91C1C'));
|
||||
|
||||
expect($preferences->colorOf(BoardColumn::Order)->value)->toBe('#b91c1c')
|
||||
->and($preferences->colorOf(BoardColumn::Ongoing)->value)->toBe('#3b2d5e')
|
||||
->and($preferences->withColumnColor(BoardColumn::Order, null)->colorOf(BoardColumn::Order)->value)->toBe('#23476a');
|
||||
});
|
||||
|
||||
it('drops unknown columns and invalid values from stored settings', function () {
|
||||
$preferences = BoardPreferences::fromStored('huge', 'sometimes', ['order' => '#14532d', 'nope' => '#ffffff', 'done' => 'red'], ['order' => 'due_date', 'done' => 'random']);
|
||||
|
||||
expect($preferences->colorValues())->toBe(['order' => '#14532d'])
|
||||
->and($preferences->sortValues())->toBe(['order' => 'due_date'])
|
||||
->and($preferences->density->value)->toBe('normal')
|
||||
->and($preferences->urgentThreshold)->toBe(UrgentThreshold::Urgent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('moving cards', function () {
|
||||
beforeEach(function () {
|
||||
$this->jobs = new InMemoryCustomerJobRepository;
|
||||
$this->tasks = new InMemoryTaskRepository;
|
||||
$this->board = new InMemoryBoardRepository;
|
||||
$this->events = new FakeEventDispatcher;
|
||||
$customers = new FakeCustomerQueries;
|
||||
$catalog = new FakeCatalogQueries;
|
||||
$users = new FakeUserAccountQueries;
|
||||
$transactions = new FakeTransactionManager;
|
||||
$clock = new FakeClock(new DateTimeImmutable('2026-11-30'));
|
||||
|
||||
$customers->customers = [1 => 'Mainos Oy'];
|
||||
$catalog->addServiceUnit(1, 'Markkinointi');
|
||||
$catalog->addWorkType(11, 1, 'graafinen työ');
|
||||
$users->addUser(10, 'Eero');
|
||||
|
||||
$createJob = new CreateCustomerJob($this->jobs, $this->jobs, new JobDetailsFactory($customers, $catalog, $users), $transactions, $clock, $this->events);
|
||||
$this->create = fn (string $status, string $priority = 'normal'): int => $createJob->execute(new CustomerJobData('Kampanja', 1, [1], 10, 'one_off', $status, $priority), 10);
|
||||
$planner = new TaskPlanner(new InMemoryTaskBookingRepository($this->tasks), new HolidayCalendar(new InMemoryHolidayOverrides), new DailyCapacity(new FakeSettings));
|
||||
$this->addTask = new AddTask($this->jobs, $this->tasks, new TaskReferenceChecker($catalog, $users), $planner, $transactions, $this->events);
|
||||
$this->move = new MoveBoardCard($this->jobs, $this->tasks, $this->board, $transactions, $this->events, $clock);
|
||||
$this->pin = new PinTaskToBoard($this->jobs, $this->tasks, $this->board, $transactions);
|
||||
});
|
||||
|
||||
it('changes the status, records it and stores the dropped order', function () {
|
||||
$jobId = ($this->create)('order');
|
||||
$otherId = ($this->create)('in_production');
|
||||
|
||||
$this->move->execute($jobId, null, BoardColumn::InProduction, ["job-{$otherId}", "job-{$jobId}"], UrgentThreshold::Urgent, 10);
|
||||
|
||||
expect($this->jobs->findById($jobId)?->details()->status)->toBe(JobStatus::InProduction)
|
||||
->and($this->jobs->changes)->not->toBeEmpty()
|
||||
->and($this->board->jobPositions)->toBe([$otherId => 10, $jobId => 20]);
|
||||
});
|
||||
|
||||
it('raises the priority to the threshold in the urgent column and lowers it in the normal one', function () {
|
||||
$jobId = ($this->create)('in_production');
|
||||
|
||||
$this->move->execute($jobId, null, BoardColumn::InProductionUrgent, ["job-{$jobId}"], UrgentThreshold::First, 10);
|
||||
expect($this->jobs->findById($jobId)?->details()->priority)->toBe(Priority::First);
|
||||
|
||||
$this->move->execute($jobId, null, BoardColumn::InProduction, ["job-{$jobId}"], UrgentThreshold::First, 10);
|
||||
expect($this->jobs->findById($jobId)?->details()->priority)->toBe(Priority::Normal);
|
||||
});
|
||||
|
||||
it('keeps a higher priority when the card is already urgent enough', function () {
|
||||
$jobId = ($this->create)('in_production', 'immediate');
|
||||
|
||||
$changesBefore = count($this->jobs->changes);
|
||||
$this->move->execute($jobId, null, BoardColumn::InProductionUrgent, ["job-{$jobId}"], UrgentThreshold::Urgent, 10);
|
||||
|
||||
expect($this->jobs->findById($jobId)?->details()->priority)->toBe(Priority::Immediate)
|
||||
->and($this->jobs->changes)->toHaveCount($changesBefore);
|
||||
});
|
||||
|
||||
it('keeps a quote status when moved inside the quotes column', function () {
|
||||
$jobId = ($this->create)('tentative');
|
||||
|
||||
$this->move->execute($jobId, null, BoardColumn::Quotes, ["job-{$jobId}"], UrgentThreshold::Urgent, 10);
|
||||
expect($this->jobs->findById($jobId)?->details()->status)->toBe(JobStatus::Tentative);
|
||||
|
||||
$orderId = ($this->create)('order');
|
||||
$this->move->execute($orderId, null, BoardColumn::Quotes, ["job-{$orderId}"], UrgentThreshold::Urgent, 10);
|
||||
expect($this->jobs->findById($orderId)?->details()->status)->toBe(JobStatus::QuoteRequest);
|
||||
});
|
||||
|
||||
it('never moves continuing jobs out of their column or other jobs into it', function (string $status, BoardColumn $target) {
|
||||
$jobId = ($this->create)($status);
|
||||
|
||||
$this->move->execute($jobId, null, $target, [], UrgentThreshold::Urgent, 10);
|
||||
})->throws(CardCannotMoveThere::class)->with([
|
||||
'continuing out' => ['ongoing', BoardColumn::InProduction],
|
||||
'other in' => ['order', BoardColumn::Ongoing],
|
||||
]);
|
||||
|
||||
it('sets a pinned task\'s status by its new column and publishes its completion', function () {
|
||||
$jobId = ($this->create)('ongoing');
|
||||
$taskId = $this->addTask->execute($jobId, new TaskData('Ottelu 1', 11, 'waiting'), 10);
|
||||
$this->pin->execute($jobId, $taskId, true);
|
||||
|
||||
$this->move->execute($jobId, $taskId, BoardColumn::Done, ["task-{$taskId}"], UrgentThreshold::Urgent, 10);
|
||||
|
||||
expect($this->tasks->findForJob($jobId, $taskId)?->status())->toBe(TaskStatus::Done)
|
||||
->and($this->board->pinnedTasks)->toBe([$taskId => true])
|
||||
->and($this->board->taskPositions)->toBe([$taskId => 10])
|
||||
->and(array_filter($this->events->dispatched, fn (object $event): bool => $event instanceof TaskCompleted))->toHaveCount(1);
|
||||
});
|
||||
|
||||
it('keeps pinned tasks out of columns that are not task columns', function () {
|
||||
$jobId = ($this->create)('ongoing');
|
||||
$taskId = $this->addTask->execute($jobId, new TaskData('Ottelu 1', 11, 'waiting'), 10);
|
||||
|
||||
$this->move->execute($jobId, $taskId, BoardColumn::OnHold, [], UrgentThreshold::Urgent, 10);
|
||||
})->throws(CardCannotMoveThere::class);
|
||||
|
||||
it('pins only tasks of continuing jobs', function () {
|
||||
$jobId = ($this->create)('in_production');
|
||||
$taskId = $this->addTask->execute($jobId, new TaskData('Taitto', 11, 'waiting'), 10);
|
||||
|
||||
$this->pin->execute($jobId, $taskId, true);
|
||||
})->throws(TaskCannotBePinned::class);
|
||||
});
|
||||
@@ -99,6 +99,15 @@ it('returns only the fields that changed', function () {
|
||||
->and(JobStatus::kanbanStatuses())->not->toContain(JobStatus::Archived);
|
||||
});
|
||||
|
||||
it('keeps an ongoing job open with tasks and on the Kanban board', function () {
|
||||
expect(JobStatus::Ongoing->locksTime())->toBeFalse()
|
||||
->and(JobStatus::Ongoing->isOpen())->toBeTrue()
|
||||
->and(JobStatus::Ongoing->allowsTasks())->toBeTrue()
|
||||
->and(JobStatus::Ongoing->isBillingStatus())->toBeFalse()
|
||||
->and(JobStatus::kanbanStatuses())->toContain(JobStatus::Ongoing)
|
||||
->and(JobStatus::Billed->unlocksTo(JobStatus::Ongoing))->toBeTrue();
|
||||
});
|
||||
|
||||
it('compares the quoted amount for the history', function () {
|
||||
$job = CustomerJob::open(new JobNumber(2026, 1), jobDetails(), 10);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
|
||||
it('normalises hex colours to lower case #rrggbb', function (string $input, string $expected): void {
|
||||
expect((new HexColor($input))->value)->toBe($expected);
|
||||
})->with([
|
||||
'upper case' => ['#1D4ED8', '#1d4ed8'],
|
||||
'short form' => ['#fA0', '#ffaa00'],
|
||||
'spaces' => [' #23476a ', '#23476a'],
|
||||
]);
|
||||
|
||||
it('rejects values that are not hex colours', function (string $input): void {
|
||||
new HexColor($input);
|
||||
})->throws(InvalidHexColor::class)->with(['1d4ed8', '#1d4ed', '#gggggg', 'red', '']);
|
||||
|
||||
it('builds a colour from rgb channels and clamps them', function (): void {
|
||||
expect(HexColor::fromRgb(29, 78, 216)->value)->toBe('#1d4ed8')
|
||||
->and(HexColor::fromRgb(-5, 300, 0)->value)->toBe('#00ff00')
|
||||
->and((new HexColor('#1d4ed8'))->rgb())->toBe([29, 78, 216]);
|
||||
});
|
||||
|
||||
it('picks white text on dark colours and dark text on light ones', function (): void {
|
||||
expect((new HexColor('#1d4ed8'))->textColor())->toBe('#ffffff')
|
||||
->and((new HexColor('#fde68a'))->textColor())->toBe('#000000')
|
||||
->and((new HexColor('#ffffff'))->isLight())->toBeTrue()
|
||||
->and((new HexColor('#000000'))->isLight())->toBeFalse();
|
||||
});
|
||||
|
||||
it('gives the text colour at least 4.5:1 on any colour', function (string $hex): void {
|
||||
$color = new HexColor($hex);
|
||||
|
||||
expect($color->contrastWith(new HexColor($color->textColor())))->toBeGreaterThanOrEqual(4.5);
|
||||
})->with(['#767676', '#808080', '#8a5cf6', '#ef4444', '#22c55e', '#1d4ed8', '#23476a', '#0f5c63', '#14532d', '#047857', '#3b2d5e', '#7c2d2d', '#b91c1c', '#9a3412', '#78350f', '#b45309', '#374151', '#4338ca', '#6d28d9', '#065f46']);
|
||||
|
||||
it('mixes a share of the colour into a base colour', function (): void {
|
||||
$base = new HexColor('#16160e');
|
||||
|
||||
expect((new HexColor('#1d4ed8'))->mixedInto($base, 0.11)->value)->toBe('#171c24')
|
||||
->and((new HexColor('#1d4ed8'))->mixedInto($base, 0.0)->value)->toBe('#16160e')
|
||||
->and((new HexColor('#1d4ed8'))->mixedInto($base, 1.0)->value)->toBe('#1d4ed8');
|
||||
});
|
||||
Reference in New Issue
Block a user