paginacao de 3 em 3

This commit is contained in:
2026-11-18 15:19:58 +02:00
parent bae996e10d
commit f1db53fdbf
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -225,7 +225,7 @@ class PortalServicesTest extends TestCase
$this->assertDatabaseCount('portal_resource_links', 20);
}
public function test_public_document_lists_paginate_five_results_and_preserve_filters(): void
public function test_public_document_lists_paginate_three_results_and_preserve_filters(): void
{
Storage::fake('local');
$this->withoutMiddleware(\Illuminate\Routing\Middleware\ThrottleRequests::class);
@@ -254,14 +254,14 @@ class PortalServicesTest extends TestCase
auth()->logout();
foreach (['documentos', 'legislacao'] as $path) {
foreach ([1 => [5, 1, 5], 2 => [5, 6, 10], 3 => [1, 11, 11]] as $number => [$count, $from, $to]) {
foreach ([1 => [3, 1, 3], 2 => [3, 4, 6], 3 => [3, 7, 9], 4 => [2, 10, 11]] as $number => [$count, $from, $to]) {
$this->get('/'.$path.'?topic=Investimento&page='.$number)->assertOk()->assertInertia(fn (Assert $page) => $page
->has('resources.data', $count)->where('resources.total', 11)
->where('resources.current_page', $number)->where('resources.last_page', 3)
->where('resources.current_page', $number)->where('resources.last_page', 4)
->where('resources.from', $from)->where('resources.to', $to)
->where('resources.data.0.title', sprintf('Pagination QA %02d', $from))
->where('resources.prev_page_url', fn ($url) => $number === 1 ? $url === null : str_contains($url, 'topic=Investimento') && str_contains($url, 'page='.($number - 1)))
->where('resources.next_page_url', fn ($url) => $number === 3 ? $url === null : str_contains($url, 'topic=Investimento') && str_contains($url, 'page='.($number + 1))));
->where('resources.next_page_url', fn ($url) => $number === 4 ? $url === null : str_contains($url, 'topic=Investimento') && str_contains($url, 'page='.($number + 1))));
}
$this->get('/'.$path.'?q=Pagination%20QA%2001')->assertOk()->assertInertia(fn (Assert $page) => $page
->has('resources.data', 1)->where('resources.total', 1)->where('resources.data.0.title', 'Pagination QA 01'));
@@ -349,7 +349,7 @@ class PortalServicesTest extends TestCase
'target_key' => 'fiscal.iva.lei_13_2016_rectification_2017', 'review_status' => 'pending', 'applicability' => 'evidence']);
$this->assertDatabaseHas('audit_events', ['source_system' => 'portal-services', 'entity_type' => 'portal_resources',
'actor_user_id' => $manager->id, 'action' => 'published_under_user_authorization']);
$this->get('/documentos')->assertInertia(fn (Assert $page) => $page->has('resources.data', 4));
$this->get('/documentos')->assertInertia(fn (Assert $page) => $page->has('resources.data', 3)->where('resources.total', 4));
$this->get('/documentos?q=22%2F2022')->assertInertia(fn (Assert $page) => $page
->has('resources.data', 1)->where('resources.data.0.id', $resourceIds[0]));
$this->get('/documentos?category=Guia&document_type=legislation')->assertInertia(fn (Assert $page) => $page