Files
coolify/tests/Feature/TablePaginationLoadingTest.php
T
Andras BacsaiandClaude Opus 5.5 a79ee909c6 chore: remove unused components and markup-only tests
- Delete Blade components, component classes, Livewire components and
  views that nothing uses after the redesign.
- Delete tests that only compare Blade/CSS source text; keep the source
  checks for authorization gates, stable wire:key values and escaping.
- Update stale tests to the current UI and behaviour.
- Update DESIGN.md to the current navigation and layout.
- Add a lesson: test behaviour, not source markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 00:18:16 +02:00

71 lines
2.3 KiB
PHP
Raw Permalink 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…');
});