actingAs($user); setAdminEnvironmentContext($tenant); bindFailHardGraphClient(); return [ $user, $tenant, Livewire::actingAs($user)->test(EnvironmentDashboard::class), ]; } /** * @return array */ function spec374DashboardHeaderActions(Testable $component): array { $instance = $component->instance(); if ($instance->getCachedHeaderActions() === []) { $instance->cacheInteractsWithHeaderActions(); } return $instance->getCachedHeaderActions(); } /** * @return list */ function spec374DashboardPrimaryActionNames(Testable $component): array { return collect(spec374DashboardHeaderActions($component)) ->reject(static fn ($action): bool => $action instanceof ActionGroup) ->map(static fn ($action): ?string => $action instanceof Action ? $action->getName() : null) ->filter() ->values() ->all(); } /** * @return list */ function spec374DashboardMoreActionNames(Testable $component): array { $moreGroup = collect(spec374DashboardHeaderActions($component)) ->first(static fn ($action): bool => $action instanceof ActionGroup && in_array($action->getLabel(), ['More', 'Mehr'], true)); return collect($moreGroup?->getActions() ?? []) ->map(static fn ($action): ?string => $action instanceof Action ? $action->getName() : null) ->filter() ->values() ->all(); } it('keeps support diagnostics as the dashboard quick diagnostics entrypoint', function (): void { [, $tenant, $component] = spec374DashboardComponent(); $component ->assertActionVisible('openSupportDiagnostics') ->assertActionEnabled('openSupportDiagnostics') ->assertActionExists('openSupportDiagnostics', fn (Action $action): bool => $action->getLabel() === 'Open support diagnostics') ->mountAction('openSupportDiagnostics') ->assertMountedActionModalSee('Support diagnostics') ->assertMountedActionModalSee('Quick support context') ->assertMountedActionModalSee('Recommended first check') ->assertMountedActionModalSee('Redacted support view') ->assertMountedActionModalSee('Environment context') ->assertMountedActionModalSee('Support scope') ->assertMountedActionModalDontSee('Boundary') ->assertMountedActionModalDontSee('Repair diagnostics'); expect(spec374DashboardPrimaryActionNames($component)) ->not->toContain('openSupportDiagnostics') ->not->toContain('openRepairDiagnostics') ->and(spec374DashboardMoreActionNames($component)) ->toContain('openSupportDiagnostics') ->not->toContain('openRepairDiagnostics') ->and(ManagedEnvironmentLinks::diagnosticsUrl($tenant))->toEndWith('/diagnostics'); }); it('frames the direct diagnostics route as repair-only in the no-action state', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner', workspaceRole: 'manager'); $this->actingAs($user); setAdminEnvironmentContext($tenant); bindFailHardGraphClient(); Livewire::test(EnvironmentDiagnostics::class) ->assertSee('Repair diagnostics') ->assertSee('Checks supported TenantPilot access and membership repair conditions only') ->assertSee('No repair diagnostics are active') ->assertSee('No supported access or membership repair is active') ->assertSee('not a generic environment health hub') ->assertSee('Use Open support diagnostics') ->assertActionVisible('openSupportDiagnostics') ->assertActionEnabled('openSupportDiagnostics') ->assertActionExists('openSupportDiagnostics', fn (Action $action): bool => $action->getLabel() === 'Open support diagnostics') ->assertDontSee('All good') ->assertDontSee('No known issues detected') ->assertDontSee('provider connection blocked') ->assertActionHidden('bootstrapOwner') ->assertActionHidden('mergeDuplicateMemberships') ->mountAction('openSupportDiagnostics') ->assertMountedActionModalSee('Support diagnostics') ->assertMountedActionModalSee('Recommended first check') ->assertMountedActionModalSee('Redacted support view') ->assertMountedActionModalSee('Support scope') ->assertMountedActionModalDontSee('Boundary') ->assertMountedActionModalDontSee('default-redacted'); }); it('keeps repair diagnostics action-surface metadata aligned with the rendered noun', function (): void { $surface = ActionSurfaceExemptions::spec193MonitoringSurface(EnvironmentDiagnostics::class); $declaration = EnvironmentDiagnostics::actionSurfaceDeclaration(); expect($surface['canonicalNoun'] ?? null)->toBe('Repair diagnostics') ->and($surface['exceptionReason'] ?? null)->toContain('membership/access repair surface') ->and((string) ($declaration->exemption(ActionSurfaceSlot::InspectAffordance)?->reason ?? '')) ->toContain('Repair diagnostics') ->toContain('singleton repair diagnostics surface'); });