mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-25 20:27:18 +00:00
55 lines
2.3 KiB
PHP
55 lines
2.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
|
|
test('searchable listbox renders search field and filters options client-side', function () {
|
|
$html = Blade::render(<<<'BLADE'
|
|
<x-forms.searchable-listbox id="serverTimezone" label="Server timezone"
|
|
searchPlaceholder="Search timezones" emptyText="No matching timezone"
|
|
:options="[
|
|
['value' => 'UTC', 'label' => 'UTC'],
|
|
['value' => 'Europe/Berlin', 'label' => 'Europe/Berlin'],
|
|
['value' => 'America/New_York', 'label' => 'America/New_York'],
|
|
]" :wire="false" value="UTC" />
|
|
BLADE);
|
|
|
|
expect($html)
|
|
->toContain('Server timezone')
|
|
->toContain('Search timezones')
|
|
->toContain('No matching timezone')
|
|
->toContain('serverTimezone-trigger')
|
|
->toContain('x-ref="search"')
|
|
->toContain('get filtered()')
|
|
->toContain('searchable-listbox-panel')
|
|
->toContain('Berlin')
|
|
->toContain('New_York');
|
|
});
|
|
|
|
test('server timezone fields use the searchable listbox component', function () {
|
|
$localhost = file_get_contents(resource_path('views/livewire/server/partials/localhost-general.blade.php'));
|
|
$show = file_get_contents(resource_path('views/livewire/server/show.blade.php'));
|
|
|
|
expect($localhost)
|
|
->toContain('x-forms.searchable-listbox id="serverTimezone"')
|
|
->toContain('searchPlaceholder="Search timezones"')
|
|
->not->toContain('<x-forms.listbox id="serverTimezone"');
|
|
|
|
expect($show)
|
|
->toContain('x-forms.searchable-listbox id="serverTimezone"')
|
|
->toContain('searchPlaceholder="Search timezones"')
|
|
->not->toMatch('/<x-forms\.listbox id="serverTimezone"/');
|
|
});
|
|
|
|
test('searchable listbox keeps the helper outside the label association', function () {
|
|
$html = Blade::render(<<<'BLADE'
|
|
<x-forms.searchable-listbox id="tz" label="Timezone"
|
|
helper="Used for cron jobs." searchPlaceholder="Search"
|
|
:options="[['value' => 'UTC', 'label' => 'UTC']]" :wire="false" value="UTC" />
|
|
BLADE);
|
|
|
|
expect($html)
|
|
->toContain('Used for cron jobs.')
|
|
->toContain('aria-label="More information"')
|
|
->not->toMatch('/<label[^>]*for="tz-trigger"[^>]*>[\s\S]*aria-label="More information"[\s\S]*<\/label>/');
|
|
});
|