## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Jobs\BulkPolicyUnignoreJob;
|
|
use App\Models\OperationRun;
|
|
use App\Models\Policy;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('bulk restore (unignore) clears ignored_at for selected policies', function () {
|
|
$tenant = ManagedEnvironment::factory()->create();
|
|
$user = User::factory()->create();
|
|
|
|
$policies = Policy::factory()
|
|
->count(5)
|
|
->create([
|
|
'managed_environment_id' => $tenant->id,
|
|
'ignored_at' => now(),
|
|
]);
|
|
|
|
$policyIds = $policies->pluck('id')->toArray();
|
|
|
|
$opRun = OperationRun::create([
|
|
'managed_environment_id' => $tenant->id,
|
|
'user_id' => $user->id,
|
|
'initiator_name' => $user->name,
|
|
'type' => 'policy.unignore',
|
|
'status' => 'queued',
|
|
'outcome' => 'pending',
|
|
'run_identity_hash' => 'policy-unignore-test',
|
|
'context' => [
|
|
'policy_ids' => $policyIds,
|
|
],
|
|
]);
|
|
|
|
BulkPolicyUnignoreJob::dispatchSync(
|
|
tenantId: (int) $tenant->getKey(),
|
|
userId: (int) $user->getKey(),
|
|
policyIds: $policyIds,
|
|
operationRun: $opRun,
|
|
);
|
|
|
|
$opRun->refresh();
|
|
|
|
expect($opRun->status)->toBe('completed');
|
|
|
|
$counts = is_array($opRun->summary_counts) ? $opRun->summary_counts : [];
|
|
expect((int) ($counts['processed'] ?? 0))->toBe(5);
|
|
expect((int) ($counts['succeeded'] ?? 0))->toBe(5);
|
|
expect((int) ($counts['failed'] ?? 0))->toBe(0);
|
|
|
|
$policies->each(function (Policy $policy): void {
|
|
expect($policy->refresh()->ignored_at)->toBeNull();
|
|
});
|
|
});
|