TenantAtlas/apps/platform/tests/Browser/Spec367OperationRunActionabilitySmokeTest.php
Ahmed Darrazi 0329cb5420
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 1m0s
feat: implement operation run actionability system
2026-06-08 15:19:55 +02:00

72 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\EnvironmentDashboard;
use App\Models\ManagedEnvironment;
use App\Models\OperationRun;
use App\Models\ProviderConnection;
use App\Support\OperationRunLinks;
use App\Support\OperationRunOutcome;
use App\Support\OperationRunStatus;
use App\Support\Workspaces\WorkspaceContext;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
pest()->browser()->timeout(20_000);
it('smokes current OperationRun actionability on dashboard and Operations surfaces in Spec367', function (): void {
$tenant = ManagedEnvironment::factory()->create(['name' => 'Spec367 Actionability Environment']);
[$user, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
$connection = ProviderConnection::factory()->verifiedHealthy()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => (int) $tenant->getKey(),
'provider' => 'microsoft',
]);
OperationRun::factory()->forTenant($tenant)->create([
'type' => 'provider.connection.check',
'status' => OperationRunStatus::Completed->value,
'outcome' => OperationRunOutcome::Blocked->value,
'initiator_name' => 'Resolved provider blocker hidden from current follow-up',
'completed_at' => now()->subHour(),
'context' => [
'provider' => 'microsoft',
'provider_connection_id' => (int) $connection->getKey(),
],
]);
OperationRun::factory()->forTenant($tenant)->create([
'type' => 'policy.sync',
'status' => OperationRunStatus::Completed->value,
'outcome' => OperationRunOutcome::Failed->value,
'initiator_name' => 'Current policy failure visible for follow-up',
'completed_at' => now()->subMinutes(20),
]);
$this->actingAs($user)->withSession([
WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id,
]);
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
visit(EnvironmentDashboard::getUrl(tenant: $tenant))
->waitForText('Operations needing attention')
->assertSee('1 operation needs follow-up')
->assertSee('Open operations hub')
->assertDontSee('Resolved provider blocker hidden from current follow-up')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
visit(OperationRunLinks::index(
tenant: $tenant,
activeTab: OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
problemClass: OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
))
->waitForText('Current policy failure visible for follow-up')
->assertSee('Current policy failure visible for follow-up')
->assertDontSee('Resolved provider blocker hidden from current follow-up')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
});