## Summary - restore broad full-suite green-signal coverage across platform governance, operations, onboarding, dashboard/productization, and customer review flows - align related platform tests and supporting behavior with the current expected state for this restoration pass - update the spec-candidates queue as part of the same suite-restoration sweep ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Dashboard/TenantDashboardProductizationSmokeTest.php tests/Browser/Reviews/CustomerReviewWorkspaceSmokeTest.php tests/Browser/Spec194GovernanceFrictionSmokeTest.php tests/Browser/Spec265DecisionRegisterSmokeTest.php` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #351
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Support\Auth\Capabilities;
|
|
use App\Support\Rbac\UiEnforcement;
|
|
use Filament\Actions\Action;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('preflights bulk selections with a set-based managed_environment_memberships query (no N+1)', function () {
|
|
$firstTenant = ManagedEnvironment::factory()->create();
|
|
[$user, $firstTenant] = createUserWithTenant($firstTenant, role: 'owner');
|
|
$tenants = collect([$firstTenant])->merge(
|
|
ManagedEnvironment::factory()->count(24)->create([
|
|
'workspace_id' => (int) $firstTenant->workspace_id,
|
|
])
|
|
);
|
|
|
|
foreach ($tenants->slice(1) as $tenant) {
|
|
$user->tenants()->syncWithoutDetaching([
|
|
$tenant->getKey() => ['role' => 'owner'],
|
|
]);
|
|
}
|
|
|
|
$action = Action::make('test')->action(fn () => null);
|
|
|
|
$enforcement = UiEnforcement::forAction($action)
|
|
->requireCapability(Capabilities::TENANT_SYNC);
|
|
|
|
$membershipQueries = 0;
|
|
|
|
DB::listen(function ($query) use (&$membershipQueries): void {
|
|
if (str_contains($query->sql, 'managed_environment_memberships')) {
|
|
$membershipQueries++;
|
|
}
|
|
});
|
|
|
|
expect($enforcement->bulkSelectionIsAuthorized($user, $tenants))->toBeTrue();
|
|
expect($membershipQueries)->toBe(1);
|
|
});
|