From f4fbcaacff6a9deb58199d222e84cbae0251ac1d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 25 Sep 2026 23:52:01 +0200 Subject: [PATCH] fix(tests): repair tests that failed on main - ServerSetting: default is_traffic_analytics_enabled to false on the model, so a new instance does not show null before a refresh. - Update navbar, mobile menu, and proxy button tests to the current redesigned UI (split action menus, settings rail, neutral icons). - Traffic nudge test: set server_role to mark a build server, the same as the product code. Co-Authored-By: Claude Opus 5.5 --- app/Models/ServerSetting.php | 10 + tests/Feature/MobileResourceMenuTest.php | 305 +++++++----------- tests/Feature/Proxy/RestartProxyTest.php | 20 +- .../ResourceHeadingUnifiedNavbarTest.php | 11 +- .../Feature/ServerNavbarStatusLayoutTest.php | 32 +- .../TrafficAnalytics/TrafficNudgeTest.php | 2 + 6 files changed, 181 insertions(+), 199 deletions(-) diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php index 624458ef91..32afb2a2a7 100644 --- a/app/Models/ServerSetting.php +++ b/app/Models/ServerSetting.php @@ -135,6 +135,16 @@ class ServerSetting extends Model 'compose_version_checked_at', ]; + /** + * Model-level defaults that mirror database column defaults, so a freshly + * created instance exposes them without a refresh. + * + * @var array + */ + protected $attributes = [ + 'is_traffic_analytics_enabled' => false, + ]; + protected $casts = [ 'force_disabled' => 'boolean', 'force_docker_cleanup' => 'boolean', diff --git a/tests/Feature/MobileResourceMenuTest.php b/tests/Feature/MobileResourceMenuTest.php index d6f3177146..182d11f85f 100644 --- a/tests/Feature/MobileResourceMenuTest.php +++ b/tests/Feature/MobileResourceMenuTest.php @@ -1,6 +1,6 @@ toBeGreaterThanOrEqual(2); + + expect($heading) + ->not->toContain('name="play-circle" class="size-3.5 text-warning"') + ->not->toContain('name="play-circle" class="size-3.5 text-orange-500'); } }); -it('uses native mobile menus for databases and services', function () { - $applicationHeading = file_get_contents(resource_path('views/livewire/project/application/heading.blade.php')); - $databaseHeading = file_get_contents(resource_path('views/livewire/project/database/heading.blade.php')); - $serviceHeading = file_get_contents(resource_path('views/livewire/project/service/heading.blade.php')); - $applicationMobileActions = mobileActionsMarkup($applicationHeading, 'application-mobile-actions', 'application-mobile-section'); - $databaseMobileActions = mobileActionsMarkup($databaseHeading, 'database-mobile-actions', 'database-mobile-section'); - $serviceMobileActions = mobileActionsMarkup($serviceHeading, 'service-mobile-actions', 'service-mobile-section'); +it('uses full-width split action menus on mobile resource headings', function () { + $headings = [ + 'application' => file_get_contents(resource_path('views/livewire/project/application/heading.blade.php')), + 'database' => file_get_contents(resource_path('views/livewire/project/database/heading.blade.php')), + 'service' => file_get_contents(resource_path('views/livewire/project/service/heading.blade.php')), + ]; - expect(mobileActionsAreBeforeSelect($applicationHeading, 'application-mobile-actions', 'application-mobile-section'))->toBeTrue(); - expect(mobileActionsAreBeforeSelect($databaseHeading, 'database-mobile-actions', 'database-mobile-section'))->toBeTrue(); - expect(mobileActionsAreBeforeSelect($serviceHeading, 'service-mobile-actions', 'service-mobile-section'))->toBeTrue(); + foreach ($headings as $resource => $heading) { + expect(mobileActionsAreBeforeDesktopActions($heading, "{$resource}-mobile-actions", "{$resource}-desktop-actions"))->toBeTrue(); - expect($applicationHeading) - ->toContain('application-mobile-actions') - ->toContain("'route' => 'project.application.command'") - ->toContain("'navigate' => false") - ->toContain("value.startsWith('location|')") - ->toContain('window.location.href = url') - ->toContain('application-mobile-stop-trigger') - ->toContain('application-mobile-restart-trigger') + expect($heading) + ->toContain('
') + ->toContain("") + ->not->toContain("{$resource}-mobile-section") + ->not->toContain('not->toContain('not->toContain('@selected'); + + expect(mobileActionsMarkup($heading, "{$resource}-mobile-actions")) + ->toContain('toContain('listbox-option justify-start! gap-2.5!') + ->toContain('role="menuitem"') + ->toContain('name="play-circle" class="size-3.5"') + ->toContain('name="restart" class="size-3.5') + ->toContain('name="stop-circle" class="size-3.5 text-error"'); + } + + expect(mobileActionsMarkup($headings['application'], 'application-mobile-actions')) ->toContain('wire:click="deploy"') - ->toContain('wire:click="force_deploy_without_cache"') + ->toContain('wire:click="deploy(true)"') + ->toContain('force_deploy_without_cache') + ->toContain('Deploy (without cache)') + ->toContain("document.getElementById('application-mobile-stop-trigger')?.click()") + ->toContain("document.getElementById('application-mobile-restart-trigger')?.click()"); + + expect($headings['application']) + ->toContain('