actingAs($platformUser, 'platform') ->get(SystemDirectoryLinks::tenantDetail($fixture['tenant']).'?window='.SystemConsoleWindow::LastWeek) ->assertSuccessful() ->assertSee('Customer health decision') ->assertSee('Overall health') ->assertSee('Reason') ->assertSee('Impact') ->assertSee('Recommended next action') ->assertSee('Top driver: Provider connection health') ->assertSee('Default provider consent or verification is blocking reliable tenant management.') ->assertSee('Review connectivity signals below and confirm the default provider consent and verification state.') ->assertSee('Last 7 days'); $html = $response->getContent(); $decisionPosition = strpos($html, 'Customer health decision'); $diagnosticsPosition = strpos($html, 'Connectivity signals'); expect($decisionPosition)->not->toBeFalse() ->and($diagnosticsPosition)->not->toBeFalse() ->and($decisionPosition)->toBeLessThan($diagnosticsPosition); }); it('renders a decision-first customer health card on the workspace detail page before tenant diagnostics', function (): void { $fixture = createCustomerHealthDecisionFixture('Workspace Decision Workspace'); $platformUser = createDirectoryPlatformUser(); $response = $this->actingAs($platformUser, 'platform') ->get(SystemDirectoryLinks::workspaceDetail($fixture['workspace']).'?window='.SystemConsoleWindow::LastWeek) ->assertSuccessful() ->assertSee('Customer health decision') ->assertSee('Overall health') ->assertSee('Reason') ->assertSee('Impact') ->assertSee('Recommended next action') ->assertSee('Top driver: Provider connection health') ->assertSee('Default provider consent or verification is blocking reliable tenant management.') ->assertSee('Open the affected tenant below and review the default provider connection state.') ->assertSee('Last 7 days'); $html = $response->getContent(); $decisionPosition = strpos($html, 'Customer health decision'); $diagnosticsPosition = strpos($html, 'Tenants summary'); expect($decisionPosition)->not->toBeFalse() ->and($diagnosticsPosition)->not->toBeFalse() ->and($decisionPosition)->toBeLessThan($diagnosticsPosition); }); function createDirectoryPlatformUser(): PlatformUser { return PlatformUser::factory()->create([ 'capabilities' => [ PlatformCapabilities::ACCESS_SYSTEM_PANEL, PlatformCapabilities::DIRECTORY_VIEW, ], 'is_active' => true, ]); } /** * @return array{workspace: Workspace, tenant: Tenant} */ function createCustomerHealthDecisionFixture(string $workspaceName): array { $workspace = Workspace::factory()->create(['name' => $workspaceName]); $tenant = Tenant::factory()->for($workspace)->create([ 'name' => $workspaceName.' Tenant', 'status' => Tenant::STATUS_ACTIVE, ]); ProviderConnection::factory() ->for($tenant) ->create([ 'workspace_id' => (int) $workspace->getKey(), 'is_default' => true, 'is_enabled' => true, 'consent_status' => ProviderConsentStatus::Granted->value, 'verification_status' => ProviderVerificationStatus::Blocked->value, ]); ReviewPack::factory() ->for($tenant) ->ready() ->create([ 'workspace_id' => (int) $workspace->getKey(), 'created_at' => now()->subDays(3), 'generated_at' => now()->subDays(3), 'expires_at' => now()->addDays(30), ]); ProductUsageEvent::factory() ->for($tenant) ->forEvent(ProductUsageEventCatalog::ONBOARDING_CHECKPOINT_COMPLETED) ->create([ 'workspace_id' => (int) $workspace->getKey(), 'occurred_at' => now()->subDays(3), ]); OperationRun::factory() ->forTenant($tenant) ->create([ 'workspace_id' => (int) $workspace->getKey(), 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, 'created_at' => now()->subDays(3), 'started_at' => now()->subDays(3)->subMinutes(5), 'completed_at' => now()->subDays(3), ]); Finding::factory() ->for($tenant) ->closed() ->create([ 'severity' => Finding::SEVERITY_LOW, ]); return [ 'workspace' => $workspace, 'tenant' => $tenant, ]; }