TenantAtlas/apps/platform/tests/Feature/OpsUx/ProgressWidgetOverflowTest.php
ahmido e64bae9cfc feat: cut over tenant core to managed environments (#335)
## 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
2026-05-07 06:38:14 +00:00

49 lines
1.9 KiB
PHP

<?php
use App\Livewire\BulkOperationProgress;
use App\Models\OperationRun;
use App\Support\OpsUx\OperationRunUrl;
use Filament\Facades\Filament;
use Livewire\Livewire;
test('progress widget limits visible active runs to three and exposes overflow count', function () {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
Filament::setTenant($tenant, true);
OperationRun::factory()->count(2)->create([
'managed_environment_id' => $tenant->id,
'workspace_id' => (int) $tenant->workspace_id,
'type' => 'inventory_sync',
'status' => 'queued',
'outcome' => 'pending',
'created_at' => now(),
]);
OperationRun::factory()->count(2)->create([
'managed_environment_id' => $tenant->id,
'workspace_id' => (int) $tenant->workspace_id,
'type' => 'inventory_sync',
'status' => 'queued',
'outcome' => 'pending',
'created_at' => now()->subHour(),
]);
$component = Livewire::actingAs($user)
->test(BulkOperationProgress::class)
->call('refreshRuns');
$html = html_entity_decode($component->html(), ENT_QUOTES | ENT_HTML5);
$pageText = preg_replace('/\s+/', ' ', strip_tags($html));
expect($component->get('runs'))->toHaveCount(3);
expect($component->get('overflowCount'))->toBe(1);
expect($component->get('runs')->map(fn (OperationRun $run): string => $run->freshnessState()->value)->unique()->values()->all())
->toEqualCanonicalizing(['fresh_active', 'likely_stale']);
expect($html)->toContain('Review operations')
->and($html)->not->toContain('View operation')
->and($html)->toContain('data-testid="ops-ux-activity-feedback-overflow-link"')
->and($html)->toContain(OperationRunUrl::index($tenant));
expect($pageText)->toContain('1 more operation update available in Operations.');
})->group('ops-ux');