TenantAtlas/apps/platform/tests/Browser/Spec284ArtifactSourceTaxonomySmokeTest.php
ahmido b159dacd36 feat: clean up legacy tenant environment context (#372)
## Summary
- remove legacy tenant-scoped routing and middleware paths in favor of the current environment/workspace context flow
- update Filament pages and resources to use the cleaned-up admin surface and environment filter context
- add the related spec 317 artifacts and targeted tests for environment filter state and legacy context cleanup

## Testing
- not run as part of this commit/push/PR workflow

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #372
2026-05-16 18:25:36 +00:00

85 lines
3.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\EnvironmentReviewResource;
use App\Filament\Resources\EvidenceSnapshotResource;
use App\Filament\Resources\FindingResource;
use App\Filament\Resources\InventoryItemResource;
use App\Filament\Resources\StoredReportResource;
use App\Models\Finding;
use App\Models\InventoryItem;
use App\Models\StoredReport;
use App\Support\Workspaces\WorkspaceContext;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
pest()->browser()->timeout(30_000);
it('smokes descriptor-first artifact source surfaces in the Filament shell', function (): void {
[$user, $tenant] = createUserWithTenant(ensureDefaultMicrosoftProviderConnection: true);
$finding = Finding::factory()->create([
'managed_environment_id' => (int) $tenant->getKey(),
'workspace_id' => (int) $tenant->workspace_id,
'subject_external_id' => 'spec-284-policy',
'evidence_jsonb' => ['policy_type' => 'deviceCompliancePolicy'],
]);
$inventory = InventoryItem::factory()->create([
'managed_environment_id' => (int) $tenant->getKey(),
'workspace_id' => (int) $tenant->workspace_id,
'policy_type' => 'deviceCompliancePolicy',
'display_name' => 'Spec 284 Compliance Inventory',
]);
$report = StoredReport::factory()->permissionPosture()->create([
'managed_environment_id' => (int) $tenant->getKey(),
'workspace_id' => (int) $tenant->workspace_id,
]);
$snapshot = seedEnvironmentReviewEvidence($tenant, findingCount: 1, driftCount: 1);
$review = composeEnvironmentReviewForTest($tenant, $user, $snapshot);
$this->actingAs($user)->withSession([
WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id,
WorkspaceContext::LAST_ENVIRONMENT_IDS_SESSION_KEY => [
(string) $tenant->workspace_id => (int) $tenant->getKey(),
],
]);
visit(FindingResource::getUrl('view', ['record' => $finding], tenant: $tenant))
->waitForText('Artifact source')
->assertSee('Source family')
->assertSee('Provider finding type')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
visit(InventoryItemResource::getUrl('view', ['record' => $inventory], tenant: $tenant))
->waitForText('Artifact source')
->assertSee('Canonical type')
->assertSee('Provider display type')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
visit(StoredReportResource::getUrl('view', ['record' => $report], tenant: $tenant))
->waitForText('Artifact source')
->assertSee('Provider report type')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
visit(EvidenceSnapshotResource::getUrl('view', ['record' => $snapshot], tenant: $tenant))
->waitForText('Evidence dimensions')
->assertSee('Source family')
->assertSee('Provider source detail')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
visit(EnvironmentReviewResource::getUrl('view', ['record' => $review], tenant: $tenant))
->waitForText('Sections')
->click('Details')
->waitForText('Artifact source')
->assertSee('Artifact source')
->assertSee('Source family')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
});