Rebuild the Kanban board after the prototype, with the job editor and quick intake dialog
- Toolbar: whose board (own, a person, a service line, all), pipeline views (daily, sales, full), urgent and late filters with a live count, normal and compact density, and the quick intake button. - Columns side by side with horizontal scrolling on desktop, stacked on phones; each user's own column colours and order, the urgent column's threshold menu, and the continuing jobs column. - Cards in customer colours: job cards with their tasks checked off inside the card (the status select is gone), continuing job cards with the next period, PIN and quick add, and pinned task cards. Dragging moves and orders cards; the keyboard opens the job editor from the card title. - Job editor dialog: every job detail, tasks with checklists and templates, quick hours (TimeTracking) and expenses (Expenses), history. - The quick intake form also adds a contact person, initial status and priority, and opens as a dialog on the board. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardColumn;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardDensity;
|
||||
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;
|
||||
use Livewire\Livewire;
|
||||
@@ -13,68 +17,237 @@ beforeEach(function () {
|
||||
$this->actingAs($this->employee);
|
||||
});
|
||||
|
||||
it('shows the Kanban columns in order with my jobs, without archived ones', function () {
|
||||
CustomerJobModel::factory()->create(['name' => 'Tilattu työ', 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
/**
|
||||
* @return array<string, list<string>> card keys by column
|
||||
*/
|
||||
function boardColumnKeys(mixed $board): array
|
||||
{
|
||||
return array_map(fn (array $cards): array => array_map(fn ($card): string => $card->key(), $cards), $board->instance()->columns);
|
||||
}
|
||||
|
||||
it('shows the daily pipeline columns in order with my jobs, without archived ones and the quick-sale job', function () {
|
||||
$mine = CustomerJobModel::factory()->create(['name' => 'Tilattu työ', 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
CustomerJobModel::factory()->create(['name' => 'Arkistoitu työ', 'status' => 'archived', 'responsible_user_id' => $this->employee->id]);
|
||||
CustomerJobModel::factory()->create(['name' => 'Pikamyynnit', 'status' => 'in_production', 'responsible_user_id' => $this->employee->id, 'quick_sale_year' => 2026]);
|
||||
CustomerJobModel::factory()->create(['name' => 'Muiden työ', 'status' => 'order']);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->assertSee('Tilattu työ')
|
||||
->assertDontSee('Arkistoitu työ')
|
||||
->assertDontSee('Pikamyynnit')
|
||||
->assertDontSee('Muiden työ')
|
||||
->assertSeeInOrder(['Prospekti', 'Alustava', 'Tarjouspyyntö', 'Tilaus', 'Tuotannossa', 'Keskeytetty', 'Valmis', 'Lasku luotu', 'Laskutettu', 'Jatkuvat / Kausi'])
|
||||
->set('mine', false)
|
||||
->assertSee('Muiden työ');
|
||||
->assertSeeInOrder(['Tarjoukset', 'Jonossa', 'Työn alla', 'Työn alla • Kiire', 'Odottaa asiakasta', 'Valmis • Laskuta', 'Jatkuvat & Kausi'], false)
|
||||
->assertDontSeeHtml('id="job-status-');
|
||||
|
||||
expect(array_keys($board->instance()->board))->not->toContain('archived')
|
||||
->and(array_map(fn ($job) => $job->name, $board->instance()->board['order']))->toContain('Tilattu työ', 'Muiden työ');
|
||||
expect(array_keys($board->instance()->columns))->toBe(['quotes', 'order', 'in_production', 'in_production_urgent', 'on_hold', 'done', 'ongoing'])
|
||||
->and(boardColumnKeys($board)['order'])->toBe(['job-'.$mine->id]);
|
||||
|
||||
$board->set('board', 'all')->assertSee('Muiden työ');
|
||||
|
||||
$this->get(route('jobs.board'))->assertOk()->assertSee('Kanban');
|
||||
});
|
||||
|
||||
it('moves a job with the select or by dropping it, and records the change', function () {
|
||||
it('shows the sales and full pipelines with their own columns', function () {
|
||||
$board = Livewire::test('jobs::board')->call('setView', 'sales');
|
||||
expect(array_keys($board->instance()->columns))->toBe(['prospect', 'tentative', 'quote_request']);
|
||||
|
||||
$board->call('setView', 'full');
|
||||
expect(array_keys($board->instance()->columns))->toContain('invoiced', 'billed', 'ongoing')->not->toContain('quotes');
|
||||
});
|
||||
|
||||
it('filters by person, service line, urgency and lateness', function () {
|
||||
$colleague = User::factory()->create(['name' => 'Anna Korhonen']);
|
||||
$urgent = CustomerJobModel::factory()->create(['name' => 'Kiiretyö', 'status' => 'in_production', 'priority' => 'urgent', 'responsible_user_id' => $colleague->id]);
|
||||
$late = CustomerJobModel::factory()->create(['name' => 'Myöhässä oleva', 'status' => 'order', 'due_on' => now()->subDays(3), 'responsible_user_id' => $colleague->id]);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->assertSee('Henkilö: Anna Korhonen')
|
||||
->set('board', 'person-'.$colleague->id)
|
||||
->assertSee('Kiiretyö')
|
||||
->assertSee('Myöhässä oleva')
|
||||
->toggle('onlyUrgent')
|
||||
->assertSee('Kiiretyö')
|
||||
->assertDontSee('Myöhässä oleva')
|
||||
->assertSee('Näytetään 1 kortti');
|
||||
|
||||
$board->toggle('onlyUrgent')->toggle('onlyLate')
|
||||
->assertSee('Myöhässä oleva')
|
||||
->assertDontSee('Kiiretyö');
|
||||
|
||||
expect($urgent->id)->not->toBe($late->id);
|
||||
});
|
||||
|
||||
it('moves a job to another column by dropping it, and records the change', function () {
|
||||
$job = CustomerJobModel::factory()->create(['name' => 'Messuvideo', 'status' => 'tentative', 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->call('moveJob', $job->id, 'order')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'order')
|
||||
->assertSee('Työ '.$job->number.' Messuvideo siirretty tilaan Tilaus.')
|
||||
->call('moveDropped', (string) $job->id, 0, 'in_production')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'in_production')
|
||||
->assertSee('siirretty tilaan Tuotannossa.');
|
||||
|
||||
expect($job->fresh()->status->value)->toBe('in_production')
|
||||
->and(DB::table('customer_job_changes')->where('customer_job_id', $job->id)->where('field', 'status')->count())->toBe(2);
|
||||
});
|
||||
|
||||
it('raises the priority when a job is dropped into the urgent column, by the user\'s threshold', function () {
|
||||
$job = CustomerJobModel::factory()->create(['name' => 'Juliste', 'status' => 'in_production', 'priority' => 'normal', 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->call('setUrgentThreshold', 'first')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'in_production_urgent')
|
||||
->assertSee('siirretty Kiire-listaan (prioriteetti nostettu: Ensin)');
|
||||
|
||||
expect($job->fresh()->priority->value)->toBe('first')
|
||||
->and(boardColumnKeys($board)['in_production_urgent'])->toBe(['job-'.$job->id]);
|
||||
|
||||
$board->call('moveDropped', 'job-'.$job->id, 0, 'in_production');
|
||||
expect($job->fresh()->priority->value)->toBe('normal');
|
||||
});
|
||||
|
||||
it('stores the drop order inside a column and switches a due-date column to own order', function () {
|
||||
$first = CustomerJobModel::factory()->create(['status' => 'order', 'due_on' => now()->addDays(2), 'responsible_user_id' => $this->employee->id]);
|
||||
$second = CustomerJobModel::factory()->create(['status' => 'order', 'due_on' => now()->addDay(), 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
$board = Livewire::test('jobs::board')->call('setColumnSort', 'order', 'due_date');
|
||||
expect(boardColumnKeys($board)['order'])->toBe(['job-'.$second->id, 'job-'.$first->id]);
|
||||
|
||||
$board->call('moveDropped', 'job-'.$second->id, 1, 'order')
|
||||
->assertSee('järjestys: oma järjestys');
|
||||
|
||||
expect(boardColumnKeys($board)['order'])->toBe(['job-'.$first->id, 'job-'.$second->id])
|
||||
->and(DB::table('job_board_preferences')->where('user_id', $this->employee->id)->value('column_sorts'))->toBe('{"order":"manual"}');
|
||||
});
|
||||
|
||||
it('lets only management and the biller move a job to a billing status', function () {
|
||||
$job = CustomerJobModel::factory()->create(['status' => 'done', 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->call('moveJob', $job->id, 'invoiced')
|
||||
->call('setView', 'full')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'invoiced')
|
||||
->assertSee('voi asettaa vain johto tai työn laskuttaja');
|
||||
expect($job->fresh()->status->value)->toBe('done');
|
||||
|
||||
$job->update(['biller_user_id' => $this->employee->id]);
|
||||
|
||||
Livewire::test('jobs::board')->call('moveJob', $job->id, 'invoiced');
|
||||
Livewire::test('jobs::board')->call('setView', 'full')->call('moveDropped', 'job-'.$job->id, 0, 'invoiced');
|
||||
expect($job->fresh()->status->value)->toBe('invoiced');
|
||||
});
|
||||
|
||||
it('ignores unknown statuses, archiving and jobs not on the board', function () {
|
||||
it('keeps continuing jobs in their own column', function () {
|
||||
$ongoing = CustomerJobModel::factory()->create(['name' => 'Futsal LIVE', 'status' => 'ongoing', 'responsible_user_id' => $this->employee->id]);
|
||||
$order = CustomerJobModel::factory()->create(['status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->call('moveDropped', 'job-'.$ongoing->id, 0, 'in_production')
|
||||
->assertSee('Korttia ei voi siirtää listaan Työn alla.')
|
||||
->call('moveDropped', 'job-'.$order->id, 0, 'ongoing')
|
||||
->assertSee('Korttia ei voi siirtää listaan Jatkuvat & Kausi.', false);
|
||||
|
||||
expect($ongoing->fresh()->status->value)->toBe('ongoing')
|
||||
->and($order->fresh()->status->value)->toBe('order')
|
||||
->and(boardColumnKeys($board)['ongoing'])->toBe(['job-'.$ongoing->id]);
|
||||
});
|
||||
|
||||
it('ignores unknown columns and cards not on the board', function () {
|
||||
$job = CustomerJobModel::factory()->create(['status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
$other = CustomerJobModel::factory()->create(['status' => 'order']);
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->call('moveJob', $job->id, 'nonsense')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'nonsense')
|
||||
->assertSee('Työtä ei siirretty.')
|
||||
->call('moveJob', $job->id, 'archived')
|
||||
->call('moveJob', $other->id, 'done')
|
||||
->call('moveJob', 999, 'done');
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'archived')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'invoiced')
|
||||
->call('moveDropped', 'job-'.$other->id, 0, 'done')
|
||||
->call('moveDropped', 'job-999', 0, 'done');
|
||||
|
||||
expect($job->fresh()->status->value)->toBe('order')
|
||||
->and($other->fresh()->status->value)->toBe('order');
|
||||
});
|
||||
|
||||
it('shows a subcontractor only their cards, without moving', function () {
|
||||
it('marks a task done from the card and opens it again', function () {
|
||||
$job = CustomerJobModel::factory()->create(['status' => 'in_production', 'responsible_user_id' => $this->employee->id]);
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $job->id, 'title' => 'Vedos asiakkaalle', 'status' => 'in_progress']);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->assertSee('Tehtävät (0/1)')
|
||||
->call('setTaskDone', $job->id, $task->id, true)
|
||||
->assertSee('Tehtävä Vedos asiakkaalle kuitattu valmiiksi.')
|
||||
->assertSee('Tehtävät (1/1)');
|
||||
|
||||
expect($task->fresh()->status->value)->toBe('done');
|
||||
|
||||
$board->call('setTaskDone', $job->id, $task->id, false);
|
||||
expect($task->fresh()->status->value)->toBe('in_progress');
|
||||
});
|
||||
|
||||
it('lifts a continuing job\'s task into the pipeline and releases it', function () {
|
||||
$job = CustomerJobModel::factory()->create(['name' => 'Somemarkkinointi', 'status' => 'ongoing', 'responsible_user_id' => $this->employee->id]);
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $job->id, 'title' => 'Joulukampanja', 'status' => 'waiting']);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->assertSee('Seuraava vuorossa:')
|
||||
->call('pinTask', $job->id, $task->id, true)
|
||||
->assertSee('Tehtävä Joulukampanja nostettu työputkeen.')
|
||||
->assertSee('Tehtävä • PIN');
|
||||
|
||||
expect(boardColumnKeys($board)['order'])->toBe(['task-'.$task->id]);
|
||||
|
||||
$board->call('moveDropped', 'task-'.$task->id, 0, 'in_production');
|
||||
expect($task->fresh()->status->value)->toBe('in_progress');
|
||||
|
||||
$board->call('pinTask', $job->id, $task->id, false);
|
||||
expect((bool) $task->fresh()->is_pinned_to_board)->toBeFalse();
|
||||
});
|
||||
|
||||
it('adds a task to a continuing job straight from its card', function () {
|
||||
$job = CustomerJobModel::factory()->create(['status' => 'ongoing', 'responsible_user_id' => $this->employee->id]);
|
||||
$unitId = DB::table('customer_job_service_unit')->where('customer_job_id', $job->id)->value('service_unit_id');
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->call('addTask', $job->id)
|
||||
->assertSee('Anna tehtävän nimi.')
|
||||
->set('newTaskTitles.'.$job->id, 'Ottelu 12.12.')
|
||||
->set('newTaskPins.'.$job->id, true)
|
||||
->call('addTask', $job->id)
|
||||
->assertSee('Tehtävä Ottelu 12.12. lisätty');
|
||||
|
||||
$task = TaskModel::query()->where('customer_job_id', $job->id)->sole();
|
||||
expect($task->title)->toBe('Ottelu 12.12.')
|
||||
->and((bool) $task->is_pinned_to_board)->toBeTrue()
|
||||
->and($task->assignee_user_id)->toBe($this->employee->id)
|
||||
->and($unitId)->not->toBeNull();
|
||||
});
|
||||
|
||||
it('keeps each user\'s column colours and density their own and saves the customer colour for everyone', function () {
|
||||
$customer = CustomerModel::factory()->create(['name' => 'Ässä KP Oy']);
|
||||
CustomerJobModel::factory()->create(['customer_id' => $customer->id, 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
|
||||
$board = Livewire::test('jobs::board')
|
||||
->call('setColumnColor', 'order', '#B91C1C')
|
||||
->assertSee('Listan Jonossa otsikkoväri tallennettu.')
|
||||
->call('setDensity', 'compact')
|
||||
->call('setCustomerColor', $customer->id, '#991b1b')
|
||||
->assertSee('Asiakkaan Ässä KP Oy väri tallennettu.')
|
||||
->assertSeeHtml('background-color: #991b1b; color: #ffffff')
|
||||
->call('setColumnColor', 'order', 'javascript:alert(1)')
|
||||
->assertSee('Väri ei kelpaa.');
|
||||
|
||||
expect($board->instance()->columnStyle(BoardColumn::Order)['header'])->toBe('#b91c1c')
|
||||
->and($board->instance()->preferences->density)->toBe(BoardDensity::Compact);
|
||||
|
||||
expect($customer->fresh()->header_color)->toBe('#991b1b');
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
$otherBoard = Livewire::test('jobs::board');
|
||||
expect($otherBoard->instance()->columnStyle(BoardColumn::Order)['header'])->toBe('#23476a')
|
||||
->and($otherBoard->instance()->preferences->density)->toBe(BoardDensity::Normal);
|
||||
|
||||
$this->actingAs($this->employee);
|
||||
Livewire::test('jobs::board')->call('setColumnColor', 'order', null)->assertSee('palautettu oletukseksi');
|
||||
});
|
||||
|
||||
it('shows a subcontractor only their cards, without moving or changing colours', function () {
|
||||
$subcontractor = User::factory()->subcontractor()->create();
|
||||
$theirs = CustomerJobModel::factory()->withMembers([$subcontractor->id])->create(['name' => 'Alihankintatyö', 'status' => 'order']);
|
||||
CustomerJobModel::factory()->create(['name' => 'Muu työ', 'status' => 'order']);
|
||||
@@ -85,8 +258,11 @@ it('shows a subcontractor only their cards, without moving', function () {
|
||||
->assertSee('Alihankintatyö')
|
||||
->assertDontSee('Muu työ')
|
||||
->assertDontSeeHtml('wire:sort=')
|
||||
->call('moveJob', $theirs->id, 'done')
|
||||
->assertDontSeeHtml('id="board-select"')
|
||||
->call('moveDropped', 'job-'.$theirs->id, 0, 'done')
|
||||
->assertForbidden();
|
||||
|
||||
Livewire::test('jobs::board')->call('setCustomerColor', $theirs->customer_id, '#000000')->assertForbidden();
|
||||
|
||||
expect($theirs->fresh()->status->value)->toBe('order');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
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;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->employee = User::factory()->create();
|
||||
$this->actingAs($this->employee);
|
||||
$this->job = CustomerJobModel::factory()->create(['name' => 'Kylkiteippaukset', 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
});
|
||||
|
||||
it('opens a job from the board and saves its details without leaving the board', function () {
|
||||
Livewire::test('jobs::board')
|
||||
->call('openJob', $this->job->id)
|
||||
->assertDispatched('open-job-editor', jobId: $this->job->id);
|
||||
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->assertSet('form.name', 'Kylkiteippaukset')
|
||||
->assertSee($this->job->number)
|
||||
->set('form.name', 'Pakettiauton kylkiteippaukset')
|
||||
->set('form.instructions', 'Asiakkaan logo vektorina')
|
||||
->call('save')
|
||||
->assertHasNoErrors()
|
||||
->assertDispatched('job-saved')
|
||||
->assertDispatched('job-editor-saved');
|
||||
|
||||
expect($this->job->fresh()->name)->toBe('Pakettiauton kylkiteippaukset')
|
||||
->and($this->job->fresh()->instructions)->toBe('Asiakkaan logo vektorina');
|
||||
});
|
||||
|
||||
it('changes the status and priority at once and records them', function () {
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->call('changeStatus', 'in_production')
|
||||
->assertSee('tila: Tuotannossa')
|
||||
->call('changePriority', 'urgent')
|
||||
->assertSee('prioriteetti: Kiire');
|
||||
|
||||
expect($this->job->fresh()->status->value)->toBe('in_production')
|
||||
->and($this->job->fresh()->priority->value)->toBe('urgent')
|
||||
->and(DB::table('customer_job_changes')->where('customer_job_id', $this->job->id)->whereIn('field', ['status', 'priority'])->count())->toBe(2);
|
||||
});
|
||||
|
||||
it('keeps an employee from billing statuses and from opening the lock', function () {
|
||||
$this->job->update(['status' => 'done']);
|
||||
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->assertSee('tunnit ja kulut on lukittu')
|
||||
->assertDontSee('Avaa lukitus (johto)')
|
||||
->call('changeStatus', 'invoiced')
|
||||
->assertHasErrors('form.status')
|
||||
->call('changeStatus', 'in_production')
|
||||
->assertHasErrors('form.status');
|
||||
|
||||
expect($this->job->fresh()->status->value)->toBe('done');
|
||||
|
||||
$this->actingAs(User::factory()->management()->create());
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->call('unlock');
|
||||
|
||||
expect($this->job->fresh()->status->value)->toBe('in_production');
|
||||
});
|
||||
|
||||
it('edits, adds and marks tasks done in the editor', function () {
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Vedos', 'status' => 'waiting']);
|
||||
|
||||
$editor = Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->call('updateTaskField', $task->id, 'title', 'Vedos asiakkaalle')
|
||||
->call('updateTaskField', $task->id, 'due_on', '2026-12-16')
|
||||
->call('setTaskDone', $task->id, true)
|
||||
->set('newTaskTitle', 'Asennus')
|
||||
->call('addTask')
|
||||
->assertHasNoErrors()
|
||||
->assertSee('Tehtävä Asennus lisätty.');
|
||||
|
||||
expect($task->fresh()->title)->toBe('Vedos asiakkaalle')
|
||||
->and($task->fresh()->due_on?->format('Y-m-d'))->toBe('2026-12-16')
|
||||
->and($task->fresh()->status->value)->toBe('done')
|
||||
->and(TaskModel::query()->where('customer_job_id', $this->job->id)->where('title', 'Asennus')->value('assignee_user_id'))->toBe($this->employee->id);
|
||||
|
||||
$editor->call('updateTaskField', $task->id, 'nonsense', 'x');
|
||||
expect($task->fresh()->title)->toBe('Vedos asiakkaalle');
|
||||
});
|
||||
|
||||
it('hides quote amounts without the quotes permission', function () {
|
||||
$this->job->update(['quoted_amount_cents' => 123400]);
|
||||
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->assertSee('Tarjous- ja laskutussummat on piilotettu')
|
||||
->assertDontSeeHtml('id="job-editor-quoted"');
|
||||
|
||||
$this->actingAs(User::factory()->management()->create());
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->assertSeeHtml('id="job-editor-quoted"');
|
||||
});
|
||||
|
||||
it('lets a subcontractor only look at their own job and tick its tasks', function () {
|
||||
$subcontractor = User::factory()->subcontractor()->create();
|
||||
$theirs = CustomerJobModel::factory()->withMembers([$subcontractor->id])->create(['status' => 'in_production']);
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $theirs->id, 'status' => 'in_progress']);
|
||||
|
||||
$this->actingAs($subcontractor);
|
||||
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||
->assertForbidden();
|
||||
|
||||
Livewire::test('jobs::job-editor')
|
||||
->dispatch('open-job-editor', jobId: $theirs->id)
|
||||
->assertSee('Voit kuitata tehtäviä')
|
||||
->call('setTaskDone', $task->id, true)
|
||||
->call('save')
|
||||
->assertForbidden();
|
||||
|
||||
expect($task->fresh()->status->value)->toBe('done');
|
||||
});
|
||||
@@ -78,17 +78,17 @@ it('shows the quoted amount to an employee with the quotes permission', function
|
||||
it('records when a job is done and clears it when management opens the lock', function () {
|
||||
$this->actingAs(User::factory()->management()->create());
|
||||
|
||||
Livewire::test('jobs::board')->set('mine', false)->call('moveJob', $this->job->id, 'done');
|
||||
Livewire::test('jobs::board')->set('board', 'all')->call('setView', 'full')->call('moveDropped', 'job-'.$this->job->id, 0, 'done');
|
||||
$completedAt = $this->job->refresh()->completed_at;
|
||||
|
||||
expect($completedAt)->not->toBeNull();
|
||||
|
||||
Livewire::test('jobs::board')->set('mine', false)->call('moveJob', $this->job->id, 'invoiced');
|
||||
Livewire::test('jobs::board')->set('board', 'all')->call('setView', 'full')->call('moveDropped', 'job-'.$this->job->id, 0, 'invoiced');
|
||||
expect($this->job->refresh()->completed_at?->equalTo($completedAt))->toBeTrue();
|
||||
|
||||
$this->get(route('jobs.show', $this->job->id))->assertSee('Valmistunut');
|
||||
|
||||
Livewire::test('jobs::board')->set('mine', false)->call('moveJob', $this->job->id, 'in_production');
|
||||
Livewire::test('jobs::board')->set('board', 'all')->call('setView', 'full')->call('moveDropped', 'job-'.$this->job->id, 0, 'in_production');
|
||||
expect($this->job->refresh()->completed_at)->toBeNull();
|
||||
});
|
||||
|
||||
|
||||
@@ -88,3 +88,40 @@ it('keeps subcontractors out and shows the menu link only to those who may open
|
||||
$this->get(route('jobs.quick'))->assertForbidden();
|
||||
$this->get(route('jobs.index'))->assertDontSee('Pikavastaanotto');
|
||||
});
|
||||
|
||||
it('opens a job from the board\'s dialog with a new contact person, status and priority', function () {
|
||||
Livewire::test('jobs::quick', ['inDialog' => true])
|
||||
->call('selectCustomer', $this->customer->id)
|
||||
->set('form.adding_contact', true)
|
||||
->set('form.name', 'Pakettiauton kylkiteippaukset')
|
||||
->set('form.service_unit_id', (string) $this->unit->id)
|
||||
->call('save')
|
||||
->assertHasErrors('form.new_contact_name')
|
||||
->set('form.new_contact_name', 'Ville Virtanen')
|
||||
->set('form.new_contact_phone', '040 123 4567')
|
||||
->set('form.status', 'in_production')
|
||||
->set('form.priority', 'urgent')
|
||||
->call('save')
|
||||
->assertHasNoErrors()
|
||||
->assertDispatched('quick-job-created', status: 'in_production')
|
||||
->assertDispatched('job-editor-saved');
|
||||
|
||||
$job = CustomerJobModel::query()->sole();
|
||||
$contactId = DB::table('customer_contacts')->where('customer_id', $this->customer->id)->where('name', 'Ville Virtanen')->value('id');
|
||||
|
||||
expect($job->status->value)->toBe('in_production')
|
||||
->and($job->priority->value)->toBe('urgent')
|
||||
->and($job->customer_contact_id)->toBe($contactId);
|
||||
});
|
||||
|
||||
it('refuses initial statuses past production', function () {
|
||||
Livewire::test('jobs::quick')
|
||||
->call('selectCustomer', $this->customer->id)
|
||||
->set('form.name', 'Valmis jo')
|
||||
->set('form.service_unit_id', (string) $this->unit->id)
|
||||
->set('form.status', 'done')
|
||||
->call('save')
|
||||
->assertHasErrors('form.status');
|
||||
|
||||
expect(CustomerJobModel::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
@@ -110,15 +110,15 @@ it('lets only management move a done job back, which opens its lock', function (
|
||||
$this->actingAs($this->employee);
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->set('mine', false)
|
||||
->call('moveJob', $job->id, 'in_production')
|
||||
->set('board', 'all')->call('setView', 'full')
|
||||
->call('moveDropped', 'job-'.$job->id, 0, 'in_production')
|
||||
->assertSet('statusMessage', fn (string $message) => str_contains($message, 'lukituksen voi avata vain johto'));
|
||||
|
||||
expect($job->refresh()->status)->toBe(JobStatus::Done);
|
||||
|
||||
$this->actingAs(User::factory()->management()->create());
|
||||
|
||||
Livewire::test('jobs::board')->set('mine', false)->call('moveJob', $job->id, 'in_production');
|
||||
Livewire::test('jobs::board')->set('board', 'all')->call('setView', 'full')->call('moveDropped', 'job-'.$job->id, 0, 'in_production');
|
||||
|
||||
expect($job->refresh()->status)->toBe(JobStatus::InProduction);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user