Files
coolify/tests/Feature/FormsButtonLoadingTest.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

55 lines
1.9 KiB
PHP

<?php
use Illuminate\Support\Facades\Blade;
it('disables the button and targets the wire click action while loading', function () {
$html = Blade::render(
'<x-forms.button wire:click.prevent="checkConnection"><x-reicon name="refresh" class="size-3.5" />Check connection</x-forms.button>'
);
expect($html)
->toContain('wire:loading.attr="disabled"')
->toContain('wire:loading.class="is-loading"')
->toContain('wire:target="checkConnection"')
->toContain('wire:loading')
->toContain('animate-spin')
->toContain('Check connection');
});
it('uses an explicit wire target for submit buttons without wire click', function () {
$html = Blade::render(
'<x-forms.button type="submit" wire:target="addToken">Validate and add</x-forms.button>'
);
expect($html)
->toContain('type="submit"')
->toContain('wire:loading.attr="disabled"')
->toContain('wire:loading.class="is-loading"')
->toContain('wire:target="addToken"')
->toContain('animate-spin')
->toContain('Validate and add');
});
it('keeps method arguments when deriving the loading target', function () {
$html = Blade::render(
'<x-forms.button wire:click="setPrivateKey(42)">Use this key</x-forms.button>'
);
expect($html)
->toContain('wire:target="setPrivateKey(42)"')
->toContain('wire:loading.attr="disabled"')
->toContain('wire:loading.class="is-loading"');
});
it('skips loading attributes when the loading indicator is disabled', function () {
$html = Blade::render(
'<x-forms.button wire:click="checkConnection" :showLoadingIndicator="false">Check connection</x-forms.button>'
);
expect($html)
->not->toContain('wire:loading.attr="disabled"')
->not->toContain('wire:loading.class="is-loading"')
->not->toContain('animate-spin')
->toContain('Check connection');
});