str_pad($i, 4, '0', STR_PAD_LEFT)]); } $component = Livewire::actingAs($operator)->test(Queue::class); expect($component->instance()->filteredTickets)->toHaveCount(50) ->and($component->instance()->filteredTickets->total())->toBe(55); $component->call('gotoPage', 2); expect($component->instance()->filteredTickets)->toHaveCount(5); }); test('changing the queue search resets the operator to page 1', function () { seedStatusesAndPriorities(); $operator = operatorUser('queue-page-reset@example.com'); foreach (range(1, 55) as $i) { makeTicket(['number' => str_pad($i, 4, '0', STR_PAD_LEFT), 'subject' => 'Zgłoszenie']); } makeTicket(['number' => '9999', 'subject' => 'Unikalny temat']); $component = Livewire::actingAs($operator)->test(Queue::class)->call('gotoPage', 2); expect($component->instance()->filteredTickets->currentPage())->toBe(2); $component->set('search', 'Unikalny'); expect($component->instance()->filteredTickets->currentPage())->toBe(1) ->and($component->instance()->filteredTickets)->toHaveCount(1); }); test('the client dashboard paginates current/archive tickets separately', function () { seedStatusesAndPriorities(); $client = User::query()->create(['name' => 'Client', 'email' => 'dash-page@example.com', 'roles' => ['client']]); foreach (range(1, 25) as $i) { makeTicket(['number' => str_pad($i, 4, '0', STR_PAD_LEFT), 'customer_id' => $client->id, 'email' => $client->email, 'name' => $client->name, 'status_key' => 'new']); } foreach (range(1, 3) as $i) { makeTicket(['number' => '90'.$i, 'customer_id' => $client->id, 'email' => $client->email, 'name' => $client->name, 'status_key' => 'closed']); } $component = Livewire::actingAs($client)->test(Dashboard::class); expect($component->instance()->currentTickets)->toHaveCount(20) ->and($component->instance()->currentTickets->total())->toBe(25) ->and($component->instance()->archiveTickets)->toHaveCount(3); }); test('"Inne Twoje zgłoszenia" shows only a handful until "Pokaż wszystkie" is clicked', function () { seedStatusesAndPriorities(); $client = User::query()->create(['name' => 'Client', 'email' => 'other-tickets@example.com', 'roles' => ['client']]); $viewed = makeTicket(['number' => '5000', 'customer_id' => $client->id, 'email' => $client->email, 'name' => $client->name]); foreach (range(1, 8) as $i) { makeTicket(['number' => '60'.$i, 'customer_id' => $client->id, 'email' => $client->email, 'name' => $client->name]); } $component = Livewire::actingAs($client)->test(TicketShow::class, ['ticket' => $viewed]); expect($component->instance()->otherTickets)->toHaveCount(5) ->and($component->instance()->otherTicketsCount)->toBe(8); $component->call('revealAllOtherTickets'); expect($component->instance()->otherTickets)->toHaveCount(8); });