TenantAtlas/tests/Feature/Filament/ReviewRegisterDerivedStateMemoizationTest.php
2026-03-28 15:57:45 +01:00

42 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\Reviews\ReviewRegister;
use App\Models\TenantReview;
use App\Support\Ui\DerivedState\DerivedStateFamily;
use App\Support\Ui\DerivedState\RequestScopedDerivedStateStore;
use App\Support\Ui\GovernanceArtifactTruth\ArtifactTruthPresenter;
use App\Support\Workspaces\WorkspaceContext;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
it('reuses one artifact-truth resolution per row on the canonical review register', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$review = composeTenantReviewForTest($tenant, $user);
setAdminPanelContext();
$this->actingAs($user);
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
Livewire::actingAs($user)
->test(ReviewRegister::class)
->assertCanSeeTableRecords([$review])
->assertSee('Artifact truth')
->assertSee('Next step');
$truth = app(ArtifactTruthPresenter::class)->forTenantReview($review->fresh());
$store = app(RequestScopedDerivedStateStore::class);
expect($store->countStored(
DerivedStateFamily::ArtifactTruth,
TenantReview::class,
(string) $review->getKey(),
'tenant_review',
))->toBe(1)
->and($truth->primaryLabel)->not->toBe('')
->and($truth->nextStepText())->not->toBe('');
});