Files
coolify/tests/Feature/TablePaginationLoadingTest.php
T
Andras BacsaiandClaude Opus 5.5 32427a20f6 fix(ui): soften list separators and fix the page size control
- Row and section separators use a softer translucent divider token on all themes
- Page size trigger is an aligned bordered button ("10 / page")
- Pagination footer stays visible when a larger page size fits all rows
- Custom page size warns above the 100 maximum and the menu closes on select

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:04:43 +02:00

91 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Gate;
it('disables page size controls when the gate denies access', function () {
Gate::define('view-audit-log-test', fn (): bool => false);
$html = Blade::render(<<<'BLADE'
<x-page-size-select model="perPage" livewire
canGate="view-audit-log-test" :canResource="new stdClass" />
BLADE);
expect($html)->toMatch('/<button[^>]*aria-label="Items per page"[^>]*\sdisabled(?:[=\s>])/')
->toMatch('/<input[^>]*aria-label="Custom items per page"[^>]*\sdisabled(?:[=\s>])/');
});
it('renders loading indicators for livewire page navigation', function () {
$html = Blade::render(
'<x-table-pagination
:from="1"
:to="10"
:total="13"
:current-page="1"
:last-page="2"
wire-target="goToPage,previousPage,nextPage"
first-action="goToPage(1)"
previous-action="previousPage"
next-action="nextPage"
last-action="goToPage(2)"
/>'
);
expect($html)
->toContain('1–10')
->toContain('13')
->toContain('wire:target="goToPage,previousPage,nextPage"')
->toContain('wire:loading')
->toContain('wire:loading.attr="disabled"')
->toContain('wire:loading.inline-flex')
->toContain('animate-spin')
->toContain('Loading page…')
->toContain('wire:click="previousPage"')
->toContain('wire:click="nextPage"')
->toContain('aria-label="Next page"')
->not->toContain('aria-label="First page"')
->not->toContain('aria-label="Last page"');
// A single spinner appears next to the range while Livewire loads the next page.
expect(substr_count($html, 'animate-spin'))->toBe(1)
->and(substr_count($html, 'Loading page…'))->toBe(1);
});
it('omits livewire loading markup when no wire target is provided', function () {
$html = Blade::render(
'<x-table-pagination
:from="1"
:to="5"
:total="5"
:current-page="1"
:last-page="1"
/>'
);
expect($html)
->toContain('1–5')
->not->toContain('wire:loading')
->not->toContain('wire:target')
->not->toContain('Loading page…');
});
it('keeps the footer on one page while a larger page size is selected', function (int $total, bool $hidden) {
$html = Blade::render(
'<x-table-pagination :from="1" :to="$total" :total="$total" :current-page="1" :last-page="1">
<x-slot:pageSize><x-page-size-select model="perPage" livewire /></x-slot:pageSize>
</x-table-pagination>',
['total' => $total]
);
expect((bool) preg_match('/<footer[^>]*\shidden[\s>]/', $html))->toBe($hidden);
})->with([
'more rows than the smallest page size' => [15, false],
'all rows fit in the smallest page size' => [10, true],
]);
it('hides the footer on one page when there is no page size control', function () {
$html = Blade::render('<x-table-pagination :from="1" :to="15" :total="15" :current-page="1" :last-page="1" />');
expect($html)->toMatch('/<footer[^>]*\shidden[\s>]/');
});