Some checks failed
Main Confidence / confidence (push) Failing after 49s
## Summary - unify provider-backed action starts behind the shared provider dispatch gate and shared start-result presenter - align tenant, onboarding, provider-connection, restore, directory, and monitoring surfaces with the same blocked, deduped, scope-busy, and accepted semantics - include the spec kit artifacts for spec 216 and the regression fixes that brought the full suite back to green ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/RestoreRunIdempotencyTest.php tests/Feature/ExecuteRestoreRunJobTest.php tests/Feature/Restore/RestoreRunProviderStartTest.php tests/Feature/Hardening/ExecuteRestoreRunJobGateTest.php tests/Feature/Hardening/BlockedWriteAuditLogTest.php tests/Feature/Onboarding/OnboardingDraftLifecycleTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Spec177InventoryCoverageTruthSmokeTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact` ## Notes - branch: `216-provider-dispatch-gate` - commit: `34230be7` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #255
114 lines
4.4 KiB
PHP
114 lines
4.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Operations\TenantlessOperationRunViewer;
|
|
use App\Models\OperationRun;
|
|
use App\Notifications\OperationRunCompleted;
|
|
use App\Support\Providers\ProviderReasonCodes;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
function makeProviderBlockedRun(): array
|
|
{
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$tenant->makeCurrent();
|
|
Filament::setTenant($tenant, true);
|
|
|
|
$run = OperationRun::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'user_id' => (int) $user->getKey(),
|
|
'initiator_name' => $user->name,
|
|
'type' => 'inventory_sync',
|
|
'status' => 'completed',
|
|
'outcome' => 'blocked',
|
|
'context' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'inventory',
|
|
'provider_connection_id' => 999999,
|
|
'reason_code' => ProviderReasonCodes::ProviderConnectionMissing,
|
|
'blocked_by' => 'provider_preflight',
|
|
'target_scope' => [
|
|
'entra_tenant_id' => $tenant->tenant_id,
|
|
],
|
|
],
|
|
]);
|
|
|
|
return [$user, $tenant, $run];
|
|
}
|
|
|
|
it('reuses translated provider-backed blocker language on the canonical run detail page', function (): void {
|
|
[$user, , $run] = makeProviderBlockedRun();
|
|
$this->actingAs($user);
|
|
|
|
$component = Livewire::actingAs($user)->test(TenantlessOperationRunViewer::class, ['run' => $run]);
|
|
$banner = $component->instance()->blockedExecutionBanner();
|
|
|
|
expect($banner)->not->toBeNull();
|
|
expect($banner['title'] ?? null)->toBe('Blocked by prerequisite');
|
|
expect($banner['body'] ?? null)->toContain('Provider connection required');
|
|
expect($banner['body'] ?? null)->toContain('usable provider connection');
|
|
});
|
|
|
|
it('keeps terminal notification reason translation aligned with the canonical provider-backed run detail', function (): void {
|
|
[$user, , $run] = makeProviderBlockedRun();
|
|
$this->actingAs($user);
|
|
|
|
$banner = Livewire::actingAs($user)
|
|
->test(TenantlessOperationRunViewer::class, ['run' => $run])
|
|
->instance()
|
|
->blockedExecutionBanner();
|
|
|
|
$payload = (new OperationRunCompleted($run))->toDatabase($user);
|
|
|
|
expect($payload['title'] ?? null)->toBe('Inventory sync blocked by prerequisite');
|
|
expect($payload['body'] ?? null)->toContain('Provider connection required');
|
|
expect($payload['body'] ?? null)->toContain('usable provider connection');
|
|
expect($payload['reason_translation']['operator_label'] ?? null)->toContain('Provider connection required');
|
|
expect($payload['reason_translation']['short_explanation'] ?? null)->toContain('usable provider connection');
|
|
expect($payload['diagnostic_reason_code'] ?? null)->toBe(ProviderReasonCodes::ProviderConnectionMissing);
|
|
expect($banner['body'] ?? '')->toContain('Provider connection required');
|
|
});
|
|
|
|
it('keeps the same blocked provider-backed vocabulary for system-initiated runs on canonical detail', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$tenant->makeCurrent();
|
|
Filament::setTenant($tenant, true);
|
|
|
|
$run = OperationRun::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'user_id' => null,
|
|
'initiator_name' => 'Scheduled automation',
|
|
'type' => 'inventory_sync',
|
|
'status' => 'completed',
|
|
'outcome' => 'blocked',
|
|
'context' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'inventory',
|
|
'provider_connection_id' => 999999,
|
|
'reason_code' => ProviderReasonCodes::ProviderConnectionMissing,
|
|
'blocked_by' => 'provider_preflight',
|
|
'target_scope' => [
|
|
'entra_tenant_id' => $tenant->tenant_id,
|
|
],
|
|
],
|
|
]);
|
|
|
|
$banner = Livewire::actingAs($user)
|
|
->test(TenantlessOperationRunViewer::class, ['run' => $run])
|
|
->instance()
|
|
->blockedExecutionBanner();
|
|
|
|
expect($banner)->not->toBeNull();
|
|
expect($banner['title'] ?? null)->toBe('Blocked by prerequisite');
|
|
expect($banner['body'] ?? null)->toContain('Provider connection required');
|
|
expect($banner['body'] ?? null)->toContain('usable provider connection');
|
|
});
|