Files
coolify/tests/Feature/StableNestedLivewireKeysTest.php
T
Andras Bacsai 1f4006ac49 test: remove tests that do not exercise app code
Remove tests that copy app logic into the test, grep PHP source as
text, only check literals, constants, class_exists or PHP built-ins,
duplicate other tests, or are always skipped. Keep source checks that
guard security and authorization rules.

Rename a duplicate Pest helper so the full suite loads, drop the
missing v5/Browser path, and remove the CLAUDE.md symlink in favor of
AGENTS.md. Correct AGENTS.md: Dusk is not installed and the upgrade
script is scripts/upgrade.sh.
2026-09-28 11:55:56 +02:00

48 lines
2.1 KiB
PHP

<?php
it('does not key nested Livewire components by mutable list positions', function () {
$postgresView = file_get_contents(resource_path('views/livewire/project/database/postgresql/general.blade.php'));
$proxyView = file_get_contents(resource_path('views/livewire/server/proxy/dynamic-configurations.blade.php'));
expect($postgresView)
->toContain(':wire:key="\'init-script-\'.md5($script[\'filename\'])"')
->not->toContain(':wire:key="$script[\'index\']"');
expect($proxyView)
->toContain('wire:key="proxy-navbar-{{ $fileName }}"')
->not->toContain('wire:key="{{ $fileName }}-{{ $loop->index }}"');
});
it('keeps editable and refreshed list row keys independent of their positions', function () {
$applicationDomains = file_get_contents(resource_path('views/livewire/project/application/partials/domain-row.blade.php'));
$serviceDomains = file_get_contents(resource_path('views/livewire/project/service/partials/domain-table.blade.php'));
expect($applicationDomains)
->not->toContain('wire:key="domain-row-{{ $index }}-')
->toContain('wire:key="domain-row-{{ md5(');
expect($serviceDomains)
->not->toContain('-{{ $index }}-')
->toContain('wire:key="svc-domain-{{ $row[\'service_application_id\'] ?? \'x\' }}-{{ md5(');
});
it('keys nested Livewire status components rendered inside navigation loops', function () {
$sidebar = file_get_contents(resource_path('views/components/application/configuration-sidebar.blade.php'));
expect($sidebar)
->toContain(':key="\'application-server-status-\'.$application->uuid"');
});
it('keys virtual log rows by stable line identity instead of list position', function () {
$view = file_get_contents(resource_path('views/livewire/project/shared/get-logs.blade.php'));
$script = file_get_contents(resource_path('js/runtime-logs.js'));
expect($view)
->toContain(':key="row.key"')
->not->toContain(':key="row.index"');
expect($script)
->toContain('getItemKey: (index) => filtered[index]?.id ?? index')
->toContain('id: nextId()');
});