Files
coolify/tests/Feature/TopUserMenuTest.php
T
BASIM NASSER A ALDAWOODandClaude Sonnet 5 b1d7cc11b8 fix(ui): resolve "Could not find Livewire component in DOM tree" on What's New click
The account-menu dropdown wrapped its panel, including the
settings-dropdown Livewire component, in <template x-if="open">.
The "What's New" button carries both wire:click and @click="open =
false" on the same element, so closing the menu tore the Livewire
component out of the DOM while its request was still in flight,
leaving Livewire unable to find the component to morph the response
into.

Switch back to x-show/x-cloak so the component stays mounted (just
hidden via CSS) and survives the menu-close click.

Fixes #11219

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 17:25:03 +03:00

56 lines
2.5 KiB
PHP

<?php
it('renders the same compact profile trigger on all breakpoints', function () {
$menu = file_get_contents(resource_path('views/components/top-user-menu.blade.php'));
expect($menu)
->toContain('{{ $userInitial }}')
->toContain('aria-label="Account menu for {{ $userName }}"')
->not->toContain('sm:hidden')
->not->toContain('hidden sm:block max-w-[9rem]')
->not->toContain('sm:px-3');
});
it('still shows the user name and email inside the dropdown panel', function () {
$menu = file_get_contents(resource_path('views/components/top-user-menu.blade.php'));
expect($menu)
->toContain('truncate text-[13px] font-semibold text-black dark:text-fg">{{ $userName }}</div>')
->toContain('{{ $userEmail }}');
});
it('animates the dropdown panel when the user menu opens', function () {
$menu = file_get_contents(resource_path('views/components/top-user-menu.blade.php'));
$stylesheet = file_get_contents(resource_path('css/app.css'));
expect($menu)
->toContain('animate-in fade-in zoom-in-95 duration-150')
->toContain("'origin-bottom-left' => \$sidebar")
->toContain("'origin-top-right' => ! \$sidebar");
expect($stylesheet)->toContain('@import "tw-animate-css";');
});
it('changes appearance from a submenu instead of navigating to a separate page', function () {
$menu = file_get_contents(resource_path('views/components/top-user-menu.blade.php'));
expect($menu)
->toContain('appearanceOpen: false')
->toContain('@click.outside="open = false; appearanceOpen = false"')
->toContain("theme: localStorage.getItem('theme') === 'purple' ? 'custom' : (localStorage.getItem('theme') || 'dark')")
->toContain('setTheme(type, closeMenu = true)')
->toContain("this.setTheme('custom', false)")
->not->toContain('@change="appearanceOpen = false; open = false"')
->toContain('this.appearanceOpen = false;')
->toContain('this.open = false;')
->toContain('<div x-show="open" x-cloak @class([')
->not->toContain('<template x-if="open">')
->not->toContain('x-show.important="open"')
->not->toContain('<div x-show="open" x-cloak x-transition.opacity.duration.120ms')
->toContain("['value' => 'light', 'label' => 'Light'")
->toContain("['value' => 'system', 'label' => 'System'")
->toContain("['value' => 'dark', 'label' => 'Dark'")
->toContain('hover:bg-neutral-200 hover:text-neutral-950')
->not->toContain("route('profile.appearance')");
});