getContent(); $html = preg_replace('/]*>.*?<\/script>/is', '', $html) ?? $html; $html = preg_replace('/]*>.*?<\/style>/is', '', $html) ?? $html; $html = preg_replace('/\s+wire:snapshot="[^"]*"/', '', $html) ?? $html; $html = preg_replace('/\s+wire:effects="[^"]*"/', '', $html) ?? $html; return trim((string) preg_replace('/\s+/', ' ', strip_tags($html))); } it('renders operation runs with summary content before counts and technical context', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); Filament::setTenant(null, true); $run = OperationRun::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => (int) $tenant->getKey(), 'type' => 'policy.sync', 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, 'initiator_name' => 'Alice Example', 'summary_counts' => [ 'total' => 10, 'processed' => 10, 'succeeded' => 10, ], 'context' => [ 'target_scope' => [ 'entra_tenant_name' => 'Contoso', 'entra_tenant_id' => '11111111-1111-1111-1111-111111111111', ], ], ]); $response = $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]) ->get(route('admin.operations.view', ['run' => (int) $run->getKey()])) ->assertOk() ->assertSee('Current state') ->assertSee('Timing') ->assertSee('Contoso'); $pageText = visiblePageText($response); $policySyncPosition = mb_strpos($pageText, 'Policy sync'); $runSummaryPosition = mb_strpos($pageText, 'Run summary'); $relatedContextPosition = mb_strpos($pageText, 'Related context'); $countsPosition = mb_strpos($pageText, 'Counts'); $identityHashPosition = mb_strpos($pageText, 'Identity hash'); expect($policySyncPosition)->not->toBeFalse() ->and($runSummaryPosition)->not->toBeFalse() ->and($relatedContextPosition)->not->toBeFalse() ->and($countsPosition)->not->toBeFalse() ->and($identityHashPosition)->not->toBeFalse() ->and($policySyncPosition)->toBeLessThan($runSummaryPosition) ->and($runSummaryPosition)->toBeLessThan($relatedContextPosition) ->and($relatedContextPosition)->toBeLessThan($countsPosition) ->and($countsPosition)->toBeLessThan($identityHashPosition); }); it('keeps header navigation and related context visible for tenant-bound operation runs', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); Filament::setTenant(null, true); $backupSet = BackupSet::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'name' => 'Nightly backup', ]); $run = OperationRun::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => (int) $tenant->getKey(), 'type' => 'backup_set.add_policies', 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, 'context' => [ 'backup_set_id' => (int) $backupSet->getKey(), 'target_scope' => [ 'entra_tenant_name' => 'Contoso', ], ], ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]) ->get(route('admin.operations.view', ['run' => (int) $run->getKey()])) ->assertOk() ->assertSee('Back to Operations') ->assertSee('Refresh') ->assertSee('Related context') ->assertSee('/admin/t/'.$tenant->external_id.'/backup-sets/'.$backupSet->getKey(), false); }); it('renders mismatch context above the enterprise detail content without blocking the page', function (): void { $runTenant = Tenant::factory()->create([ 'name' => 'Run Tenant', ]); [$user, $runTenant] = createUserWithTenant(tenant: $runTenant, role: 'owner'); $currentTenant = Tenant::factory()->create([ 'name' => 'Current Tenant', 'workspace_id' => (int) $runTenant->workspace_id, ]); createUserWithTenant(tenant: $currentTenant, user: $user, role: 'owner'); Filament::setTenant($currentTenant, true); $run = OperationRun::factory()->create([ 'workspace_id' => (int) $runTenant->workspace_id, 'tenant_id' => (int) $runTenant->getKey(), 'type' => 'policy.sync', 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, ]); $response = $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $runTenant->workspace_id]) ->get(route('admin.operations.view', ['run' => (int) $run->getKey()])) ->assertOk() ->assertSee('Current tenant context differs from this run') ->assertSee('Run summary') ->assertSee('Related context'); $pageText = visiblePageText($response); $bannerPosition = mb_strpos($pageText, 'Current tenant context differs from this run'); $summaryPosition = mb_strpos($pageText, 'Run summary'); expect($bannerPosition)->not->toBeFalse() ->and($summaryPosition)->not->toBeFalse() ->and($bannerPosition)->toBeLessThan($summaryPosition); }); it('renders explicit sparse-data fallbacks for operation runs', function (): void { $workspace = Workspace::factory()->create(); $user = User::factory()->create(); WorkspaceMembership::factory()->create([ 'workspace_id' => (int) $workspace->getKey(), 'user_id' => (int) $user->getKey(), 'role' => 'owner', ]); Filament::setTenant(null, true); $run = OperationRun::factory()->create([ 'workspace_id' => (int) $workspace->getKey(), 'tenant_id' => null, 'type' => 'provider.connection.check', 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Failed->value, 'summary_counts' => [], 'failure_summary' => [], 'context' => [], ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()]) ->get(route('admin.operations.view', ['run' => (int) $run->getKey()])) ->assertOk() ->assertSee('No target scope details were recorded for this run.') ->assertSee('Verification report') ->assertSee('Verification report unavailable') ->assertDontSee('Counts'); });