319-environment-owned-surface-routing-shell-context-contract #382
@ -2,14 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Filament\Pages\BaselineCompareLanding;
|
||||
use App\Models\BaselineProfile;
|
||||
use App\Models\BaselineSnapshot;
|
||||
use App\Models\BaselineTenantAssignment;
|
||||
use App\Support\Baselines\BaselineCompareStats;
|
||||
use App\Support\Ui\OperatorExplanation\ExplanationFamily;
|
||||
use Filament\Facades\Filament;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('shows an unavailable explanation before any baseline compare result exists', function (): void {
|
||||
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
||||
@ -43,8 +41,7 @@
|
||||
->and($explanation->family)->toBe(ExplanationFamily::Unavailable)
|
||||
->and($explanation->nextActionText)->toBe('Run the baseline compare to generate a result');
|
||||
|
||||
Livewire::actingAs($user)
|
||||
->test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant, user: $user)
|
||||
->assertSee($summary->headline)
|
||||
->assertSee($summary->nextActionLabel())
|
||||
->assertSee($explanation->coverageStatement ?? '');
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Filament\Pages\BaselineCompareLanding;
|
||||
use App\Filament\Resources\BaselineProfileResource\Pages\ViewBaselineProfile;
|
||||
use App\Support\Workspaces\WorkspaceContext;
|
||||
use Filament\Facades\Filament;
|
||||
@ -37,12 +36,10 @@
|
||||
$tenant->makeCurrent();
|
||||
Filament::setTenant($tenant, true);
|
||||
|
||||
Livewire::actingAs($readonlyUser)
|
||||
->test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant, user: $readonlyUser)
|
||||
->assertActionDisabled('compareNow');
|
||||
|
||||
Livewire::actingAs($ownerUser)
|
||||
->test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant, user: $ownerUser)
|
||||
->assertActionEnabled('compareNow');
|
||||
});
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Filament\Pages\BaselineCompareLanding;
|
||||
use App\Models\BaselineProfile;
|
||||
use App\Models\BaselineSnapshot;
|
||||
use App\Models\BaselineTenantAssignment;
|
||||
@ -12,7 +11,6 @@
|
||||
use App\Support\ReasonTranslation\ReasonPresenter;
|
||||
use App\Support\Ui\OperatorExplanation\ExplanationFamily;
|
||||
use Filament\Facades\Filament;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('renders suppressed baseline-compare results as explanation-first output instead of an implicit all-clear', function (): void {
|
||||
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
||||
@ -82,8 +80,7 @@
|
||||
expect($explanation->family)->toBe(ExplanationFamily::SuppressedOutput);
|
||||
expect($reasonSemantics)->not->toBeNull();
|
||||
|
||||
Livewire::actingAs($user)
|
||||
->test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant, user: $user)
|
||||
->assertSee($summary->headline)
|
||||
->assertSee($explanation->trustworthinessLabel())
|
||||
->assertSee($summary->nextActionLabel())
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Filament\Pages\BaselineCompareLanding;
|
||||
use App\Filament\Widgets\Dashboard\BaselineCompareNow;
|
||||
use App\Filament\Widgets\ManagedEnvironment\BaselineCompareCoverageBanner;
|
||||
use App\Models\BaselineProfile;
|
||||
@ -91,7 +90,7 @@ function createBaselineCompareSummaryConsistencyTenant(): array
|
||||
->assertSee('The last compare finished, but normal result output was suppressed.')
|
||||
->assertDontSee('Aligned');
|
||||
|
||||
Livewire::test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant)
|
||||
->assertSee('Needs review')
|
||||
->assertSee('The last compare finished, but normal result output was suppressed.')
|
||||
->assertSee('Limited confidence')
|
||||
@ -141,7 +140,7 @@ function createBaselineCompareSummaryConsistencyTenant(): array
|
||||
->assertSee('overdue finding')
|
||||
->assertSee('Open findings');
|
||||
|
||||
Livewire::test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant)
|
||||
->assertSee('Action required')
|
||||
->assertSee('overdue finding')
|
||||
->assertSee('Open findings');
|
||||
@ -174,7 +173,7 @@ function createBaselineCompareSummaryConsistencyTenant(): array
|
||||
->assertSee('Baseline compare is in progress.')
|
||||
->assertSee('Open operation');
|
||||
|
||||
Livewire::test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant)
|
||||
->assertSee('In progress')
|
||||
->assertSee('Baseline compare is in progress.')
|
||||
->assertSee('Open operation');
|
||||
|
||||
@ -123,7 +123,7 @@ function structuredGapSurfaceContext(): array
|
||||
'completed_at' => now(),
|
||||
]);
|
||||
|
||||
Livewire::test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant)
|
||||
->assertSee('Evidence gap details')
|
||||
->assertSee('Subject class')
|
||||
->assertSee('Outcome')
|
||||
|
||||
@ -2452,8 +2452,7 @@ function actionSurfaceSystemPanelContext(array $capabilities): PlatformUser
|
||||
'baseline_profile_id' => (int) $profile->getKey(),
|
||||
]);
|
||||
|
||||
Livewire::actingAs($approver)
|
||||
->test(BaselineCompareLanding::class)
|
||||
baselineCompareLandingLivewire($tenant, user: $approver)
|
||||
->assertActionExists('compareNow', function (Action $action): bool {
|
||||
return $action->isConfirmationRequired()
|
||||
&& $action->getModalDescription() === 'This will refresh content evidence on demand (redacted) before comparing the current tenant inventory against the assigned baseline snapshot.';
|
||||
|
||||
@ -818,12 +818,20 @@ function createUserWithTenant(
|
||||
return [$user, $tenant];
|
||||
}
|
||||
|
||||
function baselineCompareLandingLivewire(ManagedEnvironment $tenant, array $queryParams = []): mixed
|
||||
function baselineCompareLandingLivewire(
|
||||
ManagedEnvironment $tenant,
|
||||
array $queryParams = [],
|
||||
?\Illuminate\Contracts\Auth\Authenticatable $user = null,
|
||||
): mixed
|
||||
{
|
||||
$manager = \Livewire\Livewire::withHeaders([
|
||||
'Referer' => \App\Support\ManagedEnvironmentLinks::baselineCompareUrl($tenant),
|
||||
]);
|
||||
|
||||
if ($user instanceof \Illuminate\Contracts\Auth\Authenticatable) {
|
||||
$manager = $manager->actingAs($user);
|
||||
}
|
||||
|
||||
if ($queryParams !== []) {
|
||||
$manager = $manager->withQueryParams($queryParams);
|
||||
}
|
||||
|
||||
@ -172,3 +172,22 @@ ## Implementation Evidence
|
||||
- scoped Pint on touched PHP files.
|
||||
- `git diff --check`
|
||||
- Broader `./vendor/bin/sail artisan test --filter=DecisionRegister` surfaced an existing unrelated failure in `FindingExceptionDecisionRegisterNavigationTest` where the expected back URL still includes `managed_environment_id`; no Spec 319 files or Decision Register code were changed for that.
|
||||
|
||||
## Reopened Validation Note
|
||||
|
||||
Spec 322's broader no-drift regression split exposed five Baseline Compare tests that still mounted `BaselineCompareLanding` without route-owned Environment context. That direct Livewire mount contradicted the Spec 319 hard cutover even though the runtime route contract was already canonical.
|
||||
|
||||
Fix applied on the 319 session branch:
|
||||
|
||||
- Extended the existing `baselineCompareLandingLivewire()` test helper so tests can pass an explicit acting user while preserving the canonical Baseline Compare referer and `environment` mount parameter.
|
||||
- Updated Baseline Compare explanation, summary-consistency, authorization, gap-surface, and action-surface tests to mount through explicit Environment ownership instead of remembered/implicit panel tenant state.
|
||||
- Confirmed no direct `Livewire::test(BaselineCompareLanding::class)` Feature/Unit mount remains.
|
||||
|
||||
Validation after reopening:
|
||||
|
||||
- `./vendor/bin/sail artisan test tests/Feature/Baselines/BaselineCompareExplanationFallbackTest.php tests/Feature/Filament/BaselineCompareExplanationSurfaceTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php --compact`
|
||||
- Result: 5 passed, 42 assertions.
|
||||
- `./vendor/bin/sail artisan test tests/Feature/Filament/BaselineActionAuthorizationTest.php tests/Feature/Filament/BaselineGapSurfacesDbOnlyRenderTest.php tests/Feature/Guards/ActionSurfaceContractTest.php --filter='baseline|compareNow|full content' --compact`
|
||||
- Result: 20 passed, 199 assertions.
|
||||
- `./vendor/bin/sail artisan test tests/Unit tests/Feature --filter='WorkspaceHub|EnvironmentFilter|ClearFilter|LegacyTenant|BaselineCompare|WorkspaceOwnedAnalysis|AlertsAudit' --compact`
|
||||
- Result: 233 passed, 1826 assertions.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user