TenantAtlas/apps/platform/tests/Browser/Spec174EvidenceFreshnessPublicationTrustSmokeTest.php
ahmido ce0615a9c1 Spec 182: relocate Laravel platform to apps/platform (#213)
## Summary
- move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling
- update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location
- add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation`
- integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404`

## Remaining Rollout Checks
- validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout
- confirm web, queue, and scheduler processes all start from the expected working directory in staging/production
- verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #213
2026-04-08 08:40:47 +00:00

195 lines
7.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\EvidenceSnapshotResource;
use App\Filament\Resources\ReviewPackResource;
use App\Filament\Resources\TenantReviewResource;
use App\Models\Tenant;
use App\Support\TenantReviewCompletenessState;
use App\Support\TenantReviewStatus;
use App\Support\Workspaces\WorkspaceContext;
use Tests\Feature\Concerns\BuildsGovernanceArtifactTruthFixtures;
uses(BuildsGovernanceArtifactTruthFixtures::class);
pest()->browser()->timeout(15_000);
it('smokes tenant-scoped evidence freshness and publication trust surfaces', function (): void {
$staleTenant = Tenant::factory()->create(['name' => 'Browser Smoke Stale Tenant']);
[$user, $staleTenant] = createUserWithTenant(tenant: $staleTenant, role: 'owner');
$partialTenant = Tenant::factory()->create([
'workspace_id' => (int) $staleTenant->workspace_id,
'name' => 'Browser Smoke Partial Tenant',
]);
createUserWithTenant(tenant: $partialTenant, user: $user, role: 'owner');
$staleSnapshot = seedStaleTenantReviewEvidence($staleTenant);
$partialSnapshot = seedPartialTenantReviewEvidence($partialTenant);
$partialReview = $this->makeArtifactTruthReview(
tenant: $partialTenant,
user: $user,
snapshot: $partialSnapshot,
reviewOverrides: [
'status' => TenantReviewStatus::Ready->value,
'completeness_state' => TenantReviewCompletenessState::Complete->value,
],
summaryOverrides: [
'publish_blockers' => [],
'section_state_counts' => [
'complete' => 6,
'partial' => 0,
'missing' => 0,
'stale' => 0,
],
],
);
$staleReview = $this->makeArtifactTruthReview(
tenant: $staleTenant,
user: $user,
snapshot: $staleSnapshot,
reviewOverrides: [
'status' => TenantReviewStatus::Published->value,
'published_at' => now(),
'published_by_user_id' => (int) $user->getKey(),
'completeness_state' => TenantReviewCompletenessState::Complete->value,
],
summaryOverrides: [
'publish_blockers' => [],
'section_state_counts' => [
'complete' => 6,
'partial' => 0,
'missing' => 0,
'stale' => 0,
],
],
);
$stalePack = $this->makeArtifactTruthReviewPack(
tenant: $staleTenant,
user: $user,
snapshot: $staleSnapshot,
review: $staleReview,
summaryOverrides: [
'review_status' => TenantReviewStatus::Published->value,
'review_completeness_state' => TenantReviewCompletenessState::Complete->value,
],
);
$this->actingAs($user)->withSession([
WorkspaceContext::SESSION_KEY => (int) $staleTenant->workspace_id,
]);
session()->put(WorkspaceContext::SESSION_KEY, (int) $staleTenant->workspace_id);
visit(EvidenceSnapshotResource::getUrl('view', ['record' => $staleSnapshot], tenant: $staleTenant))
->waitForText('Artifact truth')
->assertNoJavaScriptErrors()
->assertSee('Stale')
->assertSee('Refresh the stale evidence before relying on this snapshot');
visit(TenantReviewResource::tenantScopedUrl('view', ['record' => $partialReview], $partialTenant))
->waitForText('Artifact truth')
->assertNoJavaScriptErrors()
->assertSee('Internal only')
->assertSee('Complete the evidence basis before publishing this review');
visit(ReviewPackResource::getUrl('index', tenant: $staleTenant))
->waitForText('Artifact truth')
->assertNoJavaScriptErrors()
->assertSee('Internal only')
->assertSee('Refresh the source review before sharing this pack')
->assertSee('Download');
visit(ReviewPackResource::getUrl('view', ['record' => $stalePack], tenant: $staleTenant))
->waitForText('Artifact truth')
->assertNoJavaScriptErrors()
->assertSee('Internal only')
->assertSee('Refresh the source review before sharing this pack')
->assertSee('Download');
});
it('smokes canonical evidence and review trust surfaces', function (): void {
$staleTenant = Tenant::factory()->create(['name' => 'Browser Canonical Stale Tenant']);
[$user, $staleTenant] = createUserWithTenant(tenant: $staleTenant, role: 'owner');
$partialTenant = Tenant::factory()->create([
'workspace_id' => (int) $staleTenant->workspace_id,
'name' => 'Browser Canonical Partial Tenant',
]);
createUserWithTenant(tenant: $partialTenant, user: $user, role: 'owner');
$freshTenant = Tenant::factory()->create([
'workspace_id' => (int) $staleTenant->workspace_id,
'name' => 'Browser Canonical Fresh Tenant',
]);
createUserWithTenant(tenant: $freshTenant, user: $user, role: 'owner');
$staleSnapshot = $this->makeStaleArtifactTruthEvidenceSnapshot($staleTenant);
$freshSnapshot = $this->makeArtifactTruthEvidenceSnapshot($freshTenant);
$partialSnapshot = seedPartialTenantReviewEvidence($partialTenant);
$this->makeArtifactTruthReview(
tenant: $staleTenant,
user: $user,
snapshot: $staleSnapshot,
reviewOverrides: [
'status' => TenantReviewStatus::Published->value,
'published_at' => now(),
'published_by_user_id' => (int) $user->getKey(),
'completeness_state' => TenantReviewCompletenessState::Complete->value,
],
summaryOverrides: [
'publish_blockers' => [],
'section_state_counts' => [
'complete' => 6,
'partial' => 0,
'missing' => 0,
'stale' => 0,
],
],
);
$this->makeArtifactTruthReview(
tenant: $partialTenant,
user: $user,
snapshot: $partialSnapshot,
reviewOverrides: [
'status' => TenantReviewStatus::Ready->value,
'completeness_state' => TenantReviewCompletenessState::Complete->value,
],
summaryOverrides: [
'publish_blockers' => [],
'section_state_counts' => [
'complete' => 6,
'partial' => 0,
'missing' => 0,
'stale' => 0,
],
],
);
$this->actingAs($user)->withSession([
WorkspaceContext::SESSION_KEY => (int) $staleTenant->workspace_id,
]);
session()->put(WorkspaceContext::SESSION_KEY, (int) $staleTenant->workspace_id);
visit(route('admin.evidence.overview'))
->waitForText('Browser Canonical Stale Tenant')
->assertNoJavaScriptErrors()
->assertSee('Browser Canonical Fresh Tenant')
->assertSee('Refresh the stale evidence before relying on this snapshot')
->assertSee('Create a current review from this evidence snapshot');
visit('/admin/reviews')
->waitForText('Browser Canonical Stale Tenant')
->assertNoJavaScriptErrors()
->assertSee('Browser Canonical Partial Tenant')
->assertSee('Internal only')
->assertSee('Refresh the evidence basis before publishing this review')
->assertSee('Complete the evidence basis before publishing this review')
->assertDontSee('Publishable');
});