Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 56s
Automatisch erstellter PR: Implementiert Spec 257 — Governance decision convergence. Branch: 257-governance-decision-convergence Bitte Review und Merge gegen `platform-dev`. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #304
86 lines
3.5 KiB
PHP
86 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Governance\GovernanceInbox;
|
|
use App\Filament\Pages\Monitoring\FindingExceptionsQueue;
|
|
use App\Models\Finding;
|
|
use App\Models\FindingException;
|
|
use App\Models\Tenant;
|
|
use App\Support\Navigation\CanonicalNavigationContext;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Livewire\Livewire;
|
|
|
|
it('keeps the finding exceptions queue secondary when opened from the governance inbox', function (): void {
|
|
$tenant = Tenant::factory()->create([
|
|
'status' => 'active',
|
|
'name' => 'Alpha Tenant',
|
|
'external_id' => 'alpha-tenant',
|
|
]);
|
|
[$user, $tenant] = createUserWithTenant($tenant, role: 'owner', workspaceRole: 'manager');
|
|
|
|
$finding = Finding::factory()
|
|
->for($tenant)
|
|
->riskAccepted()
|
|
->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'subject_external_id' => 'exception-secondary-finding',
|
|
]);
|
|
|
|
$exception = FindingException::query()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'finding_id' => (int) $finding->getKey(),
|
|
'requested_by_user_id' => (int) $user->getKey(),
|
|
'owner_user_id' => (int) $user->getKey(),
|
|
'status' => FindingException::STATUS_PENDING,
|
|
'current_validity_state' => FindingException::VALIDITY_MISSING_SUPPORT,
|
|
'request_reason' => 'Exception queue return context',
|
|
'requested_at' => now()->subDay(),
|
|
'review_due_at' => now()->addDay(),
|
|
'evidence_summary' => ['reference_count' => 0],
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
Filament::setCurrentPanel('admin');
|
|
Filament::setTenant(null, true);
|
|
Filament::bootCurrentPanel();
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
$context = CanonicalNavigationContext::forGovernanceInbox(
|
|
canonicalRouteName: GovernanceInbox::getRouteName(Filament::getPanel('admin')),
|
|
tenantId: (int) $tenant->getKey(),
|
|
familyKey: 'finding_exceptions',
|
|
backLinkUrl: GovernanceInbox::getUrl(panel: 'admin', parameters: [
|
|
'tenant_id' => (string) $tenant->getKey(),
|
|
'family' => 'finding_exceptions',
|
|
]),
|
|
);
|
|
|
|
$component = Livewire::withQueryParams(array_replace($context->toQuery(), [
|
|
'tenant' => (string) $tenant->external_id,
|
|
'exception' => (int) $exception->getKey(),
|
|
]))
|
|
->actingAs($user)
|
|
->test(FindingExceptionsQueue::class)
|
|
->assertSet('tableFilters.tenant_id.value', (string) $tenant->getKey())
|
|
->assertSet('selectedFindingExceptionId', (int) $exception->getKey())
|
|
->assertActionVisible('return_to_governance_inbox')
|
|
->assertActionVisible('open_selected_exception')
|
|
->assertActionVisible('open_selected_finding')
|
|
->assertSee('Exception queue return context')
|
|
->assertSee('Focused review lane')
|
|
->assertDontSee('This workspace decision surface routes you');
|
|
|
|
expect($component->instance()->selectedExceptionUrl())
|
|
->toContain('nav%5Bsource_surface%5D=governance.inbox')
|
|
->toContain('nav%5Bfamily_key%5D=finding_exceptions')
|
|
->toContain('nav%5Btenant_id%5D='.(string) $tenant->getKey());
|
|
|
|
expect($component->instance()->selectedFindingUrl())
|
|
->toContain('nav%5Bsource_surface%5D=governance.inbox')
|
|
->toContain('nav%5Bfamily_key%5D=finding_exceptions')
|
|
->toContain('nav%5Btenant_id%5D='.(string) $tenant->getKey());
|
|
});
|