create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => null, 'type' => 'provider.connection.check', 'initiator_name' => 'Tenantless run', 'status' => 'queued', 'outcome' => 'pending', ]); OperationRun::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => (int) $tenant->getKey(), 'type' => 'policy.sync', 'initiator_name' => 'Tenant run', 'status' => 'queued', 'outcome' => 'pending', ]); Filament::setTenant(null, true); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]) ->get(route('admin.operations.index')) ->assertOk() ->assertSee('Tenantless run') ->assertSee('Tenant run'); } public function test_renders_workspace_operations_list_safely_with_tenant_context_and_tenantless_records_present(): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); OperationRun::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => null, 'type' => 'provider.connection.check', 'initiator_name' => 'Tenantless run', 'status' => 'queued', 'outcome' => 'pending', ]); OperationRun::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'tenant_id' => (int) $tenant->getKey(), 'type' => 'policy.sync', 'initiator_name' => 'Tenant run', 'status' => 'queued', 'outcome' => 'pending', ]); Filament::setTenant($tenant, true); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]) ->get(route('admin.operations.index')) ->assertOk() ->assertSee('Tenant run') ->assertDontSee('Tenantless run'); } }