filtros de biblioteca e legislacao
This commit is contained in:
@@ -225,6 +225,51 @@ class PortalServicesTest extends TestCase
|
||||
$this->assertDatabaseCount('portal_resource_links', 20);
|
||||
}
|
||||
|
||||
public function test_public_document_lists_paginate_five_results_and_preserve_filters(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
$this->withoutMiddleware(\Illuminate\Routing\Middleware\ThrottleRequests::class);
|
||||
$manager = User::factory()->create();
|
||||
config(['portal.managers' => [$manager->email]]);
|
||||
$this->actingAs($manager);
|
||||
|
||||
for ($number = 1; $number <= 12; $number++) {
|
||||
$filename = sprintf('pagination-%02d.txt', $number);
|
||||
$this->post('/management/portal-services/upload', [
|
||||
'file' => UploadedFile::fake()->createWithContent($filename, 'pagination fixture '.$number),
|
||||
])->assertRedirect()->assertSessionHasNoErrors();
|
||||
$document = DB::table('documents')->where('file_name', $filename)->firstOrFail();
|
||||
$id = $this->registerDocumentResource($document->id, sprintf('Pagination QA %02d', $number), [
|
||||
'legislation' => true,
|
||||
]);
|
||||
if ($number <= 11) {
|
||||
// The transaction-wrapped test does not run the after-commit scan job.
|
||||
DB::table('documents')->where('id', $document->id)->update([
|
||||
'status' => 'active', 'data_classification' => 'public',
|
||||
'malware_scan_status' => 'clean', 'malware_scanned_sha256' => $document->sha256,
|
||||
]);
|
||||
$this->post('/management/portal-services/resources/'.$id, ['published' => true])->assertSessionHasNoErrors();
|
||||
}
|
||||
}
|
||||
|
||||
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]) {
|
||||
$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.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))));
|
||||
}
|
||||
$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'));
|
||||
$this->get('/'.$path.'?q=nao-existe')->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||
->has('resources.data', 0)->where('resources.total', 0));
|
||||
}
|
||||
}
|
||||
|
||||
public function test_legislation_with_an_identified_source_can_be_published_for_consultation_without_claiming_confirmation(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
|
||||
Reference in New Issue
Block a user