TenantAtlas/apps/platform/tests/Feature/078/OperationsListTenantlessSafetyTest.php
ahmido 38523814c2 fix: restore full-suite green signals across platform workflows (#351)
## Summary
- restore broad full-suite green-signal coverage across platform governance, operations, onboarding, dashboard/productization, and customer review flows
- align related platform tests and supporting behavior with the current expected state for this restoration pass
- update the spec-candidates queue as part of the same suite-restoration sweep

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Dashboard/TenantDashboardProductizationSmokeTest.php tests/Browser/Reviews/CustomerReviewWorkspaceSmokeTest.php tests/Browser/Spec194GovernanceFrictionSmokeTest.php tests/Browser/Spec265DecisionRegisterSmokeTest.php`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #351
2026-05-12 18:50:40 +00:00

79 lines
2.7 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\OperationRun;
use App\Support\Workspaces\WorkspaceContext;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
final class OperationsListTenantlessSafetyTest extends TestCase
{
use RefreshDatabase;
public function test_renders_workspace_operations_list_with_tenantless_runs_when_no_tenant_context_is_set(): void
{
[$user, $tenant] = createUserWithTenant(role: 'owner');
OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => null,
'type' => 'provider.connection.check',
'initiator_name' => 'Tenantless run',
'status' => 'queued',
'outcome' => 'pending',
]);
OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => (int) $tenant->getKey(),
'type' => 'policy.sync',
'initiator_name' => 'ManagedEnvironment run',
'status' => 'queued',
'outcome' => 'pending',
]);
Filament::setTenant(null, true);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(\App\Support\OperationRunLinks::index())
->assertOk()
->assertSee('Tenantless run')
->assertSee('ManagedEnvironment run');
}
public function test_renders_workspace_operations_list_workspace_wide_even_with_tenant_context_and_tenantless_records_present(): void
{
[$user, $tenant] = createUserWithTenant(role: 'owner');
OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => null,
'type' => 'provider.connection.check',
'initiator_name' => 'Tenantless run',
'status' => 'queued',
'outcome' => 'pending',
]);
OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => (int) $tenant->getKey(),
'type' => 'policy.sync',
'initiator_name' => 'ManagedEnvironment run',
'status' => 'queued',
'outcome' => 'pending',
]);
Filament::setTenant($tenant, true);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(\App\Support\OperationRunLinks::index())
->assertOk()
->assertSee('ManagedEnvironment run')
->assertSee('Tenantless run');
}
}