Plan step 19, containment.md C-24. `interpolate-size: allow-keywords` was set and nothing transitioned, so the content snapped open. A new resources/css/components/collapse.css transitions `block-size` on `::details-content` over the fast spatial spring, with `content-visibility` `allow-discrete` beside it so the section stays rendered while it closes. The `<details>` carries `data-collapse` for the rule to find. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
67 lines
2.6 KiB
PHP
67 lines
2.6 KiB
PHP
<?php
|
|
|
|
use Livewire\Component;
|
|
use Livewire\Livewire;
|
|
|
|
it('discloses on the native details element, kept open through a morph', function () {
|
|
$html = (string) $this->blade('<x-collapse title="How long do links last?" icon="schedule" open variant="filled">Until the expiry.</x-collapse>');
|
|
|
|
expect($html)
|
|
->toContain('<details')
|
|
->toContain('wire:ignore.self')
|
|
->toContain(' open ')
|
|
->toContain('rounded-corner-lg bg-surface-container')
|
|
->toContain('data-collapse')
|
|
->toContain('[interpolate-size:allow-keywords]')
|
|
->toContain('How long do links last?')
|
|
->toContain('Until the expiry.')
|
|
->toContain('group-open/collapse:rotate-180');
|
|
});
|
|
|
|
it('has no Alpine on it without a binding', function () {
|
|
$html = (string) $this->blade('<x-collapse title="Advanced" open>Body</x-collapse>');
|
|
|
|
expect($html)
|
|
->toMatch('/<details\s+wire:ignore.self\s+data-collapse\s+open\s+class="group\/collapse/')
|
|
->not->toContain('x-data')
|
|
->not->toContain('x-modelable')
|
|
->not->toContain('x-on:toggle')
|
|
->and((string) $this->blade('<x-collapse title="Advanced">Body</x-collapse>'))
|
|
->toMatch('/<details\s+wire:ignore.self\s+data-collapse\s+class="group\/collapse/');
|
|
});
|
|
|
|
it('binds its open state through x-model, drawing the open prop until Alpine starts', function () {
|
|
$html = (string) $this->blade('<x-collapse title="Advanced" x-model="advanced" open>Body</x-collapse>');
|
|
|
|
expect($html)
|
|
->toMatch('/x-data="{ collapseOpen:\s*true\s*}"/')
|
|
->toContain('x-modelable="collapseOpen"')
|
|
->toContain('x-model="advanced"')
|
|
->toContain('x-effect="$el.open = collapseOpen"')
|
|
->toContain('x-on:toggle="collapseOpen = $el.open"')
|
|
->toMatch('/\sopen\s/');
|
|
});
|
|
|
|
it('entangles its open state with a Livewire property and renders open as the property is', function (bool $fineTuning) {
|
|
Livewire::component('collapse-probe', new class extends Component
|
|
{
|
|
public bool $fineTuning = false;
|
|
|
|
public function render(): string
|
|
{
|
|
return '<div><x-collapse title="Fine-tuning" wire:model.live="fineTuning" :open="! $fineTuning">Body</x-collapse></div>';
|
|
}
|
|
});
|
|
|
|
$html = Livewire::test('collapse-probe', ['fineTuning' => $fineTuning])->html();
|
|
|
|
expect($html)
|
|
->toContain(".entangle('fineTuning').live")
|
|
->not->toContain('x-modelable')
|
|
->not->toContain('wire:model');
|
|
|
|
preg_match('/<details[^>]*>/', $html, $tag);
|
|
|
|
expect(preg_match('/\sopen\s/', $tag[0]) === 1)->toBe($fineTuning);
|
|
})->with(['open' => true, 'closed' => false]);
|