actingAs($user); Filament::setTenant($tenant, true); $profile = BaselineProfile::factory()->active()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'name' => 'Security Baseline', ]); $snapshot = BaselineSnapshot::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'baseline_profile_id' => (int) $profile->getKey(), ]); $policy = Policy::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'display_name' => 'Windows Lockdown', ]); $version = PolicyVersion::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'policy_id' => (int) $policy->getKey(), 'version_number' => 3, ]); $run = OperationRun::factory()->for($tenant)->create([ 'workspace_id' => (int) $tenant->workspace_id, 'type' => 'baseline_compare', ]); $finding = Finding::factory()->for($tenant)->create([ 'current_operation_run_id' => (int) $run->getKey(), 'evidence_jsonb' => [ 'current' => [ 'policy_version_id' => (int) $version->getKey(), ], 'provenance' => [ 'baseline_profile_id' => (int) $profile->getKey(), 'baseline_snapshot_id' => (int) $snapshot->getKey(), 'compare_operation_run_id' => (int) $run->getKey(), ], ], ]); $relatedEntries = app(RelatedNavigationResolver::class) ->detailEntries(CrossResourceNavigationMatrix::SOURCE_FINDING, $finding); $primaryAction = app(RelatedNavigationResolver::class) ->primaryListAction(CrossResourceNavigationMatrix::SOURCE_FINDING, $finding); $this->get(FindingResource::getUrl('view', ['record' => $finding], tenant: $tenant)) ->assertOk() ->assertSee('Related context') ->assertSee('Snapshot') ->assertSee(BaselineSnapshotResource::getUrl('view', ['record' => $snapshot], panel: 'admin'), false) ->assertSee(e($relatedEntries[1]['targetUrl']), false); $this->get(FindingResource::getUrl('index', tenant: $tenant)) ->assertOk() ->assertSee($primaryAction?->actionLabel ?? '') ->assertSee($primaryAction?->targetUrl ?? '', false); });