This PR introduces the Operation Run Actionability System. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #439
98 lines
3.7 KiB
PHP
98 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Monitoring\Operations;
|
|
use App\Filament\Widgets\Dashboard\NeedsAttention;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\OperationRun;
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\OperationRunOutcome;
|
|
use App\Support\OperationRunStatus;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Livewire\Livewire;
|
|
|
|
it('hides resolved provider blockers from the current terminal follow-up Operations tab in Spec367', function (): void {
|
|
bindFailHardGraphClient();
|
|
|
|
$tenant = ManagedEnvironment::factory()->create();
|
|
[$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',
|
|
]);
|
|
|
|
$resolvedProviderBlocker = OperationRun::factory()->forTenant($tenant)->create([
|
|
'type' => 'provider.connection.check',
|
|
'status' => OperationRunStatus::Completed->value,
|
|
'outcome' => OperationRunOutcome::Blocked->value,
|
|
'initiator_name' => 'Resolved provider blocker',
|
|
'completed_at' => now()->subHour(),
|
|
'context' => [
|
|
'provider' => 'microsoft',
|
|
'provider_connection_id' => (int) $connection->getKey(),
|
|
],
|
|
]);
|
|
|
|
$currentPolicyFailure = OperationRun::factory()->forTenant($tenant)->create([
|
|
'type' => 'policy.sync',
|
|
'status' => OperationRunStatus::Completed->value,
|
|
'outcome' => OperationRunOutcome::Failed->value,
|
|
'initiator_name' => 'Current policy failure',
|
|
'completed_at' => now()->subMinutes(30),
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
setAdminPanelContext($tenant);
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(Operations::class)
|
|
->filterTable('managed_environment_id', (string) $tenant->getKey())
|
|
->set('activeTab', OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP)
|
|
->assertCanSeeTableRecords([$currentPolicyFailure])
|
|
->assertCanNotSeeTableRecords([$resolvedProviderBlocker]);
|
|
});
|
|
|
|
it('shows dashboard operation attention only for current actionability in Spec367', function (): void {
|
|
$tenant = ManagedEnvironment::factory()->create();
|
|
[$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,
|
|
'completed_at' => now()->subHour(),
|
|
'context' => [
|
|
'provider' => 'microsoft',
|
|
'provider_connection_id' => (int) $connection->getKey(),
|
|
],
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
setAdminPanelContext($tenant);
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(NeedsAttention::class)
|
|
->assertDontSee('Operations need current follow-up');
|
|
|
|
OperationRun::factory()->forTenant($tenant)->create([
|
|
'type' => 'policy.sync',
|
|
'status' => OperationRunStatus::Completed->value,
|
|
'outcome' => OperationRunOutcome::Failed->value,
|
|
'completed_at' => now()->subMinutes(30),
|
|
]);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(NeedsAttention::class)
|
|
->assertSee('Operations need current follow-up')
|
|
->assertSee('Open current follow-up');
|
|
});
|