TenantAtlas/tests/Feature/OpsUx/BulkOperationProgressDbOnlyTest.php
ahmido a74ab12f04 feat: implement evidence domain foundation (#183)
## Summary
- add the Evidence Snapshot domain with immutable tenant-scoped snapshots, per-dimension items, queued generation, audit actions, badge mappings, and Filament list/detail surfaces
- add the workspace evidence overview, capability and policy wiring, Livewire update-path hardening, and review-pack integration through explicit evidence snapshot resolution
- add spec 153 artifacts, migrations, factories, and focused Pest coverage for evidence, review-pack reuse, authorization, action-surface regressions, and audit behavior

## Testing
- `vendor/bin/sail artisan test --compact --stop-on-failure`
- `CI=1 vendor/bin/sail artisan test --compact`
- `vendor/bin/sail bin pint --dirty --format agent`

## Notes
- branch: `153-evidence-domain-foundation`
- commit: `b7dfa279`
- spec: `specs/153-evidence-domain-foundation/`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #183
2026-03-19 13:32:52 +00:00

55 lines
1.7 KiB
PHP

<?php
use App\Livewire\BulkOperationProgress;
use App\Models\OperationRun;
use App\Models\Tenant;
use Filament\Facades\Filament;
use Livewire\Livewire;
it('keeps the Ops UX progress widget DB-only (no outbound HTTP) and tenant-scoped', function () {
$tenantA = Tenant::factory()->create();
$tenantB = Tenant::factory()->create();
[$user] = createUserWithTenant($tenantA, role: 'owner');
$user->tenants()->syncWithoutDetaching([
$tenantB->getKey() => ['role' => 'owner'],
]);
OperationRun::factory()->create([
'tenant_id' => $tenantA->getKey(),
'type' => 'policy.sync',
'status' => 'running',
'outcome' => 'pending',
'initiator_name' => 'TenantA',
]);
OperationRun::factory()->create([
'tenant_id' => $tenantB->getKey(),
'type' => 'inventory_sync',
'status' => 'running',
'outcome' => 'pending',
'initiator_name' => 'TenantB',
]);
$this->actingAs($user);
Filament::setTenant($tenantA, true);
assertNoOutboundHttp(function () {
Livewire::test(BulkOperationProgress::class)
->call('refreshRuns')
->assertSet('disabled', false)
->assertSee('Policy sync')
->assertDontSee('Inventory sync');
});
})->group('ops-ux');
it('registers Alpine cleanup for the Ops UX poller to avoid stale listeners across re-renders', function () {
$contents = file_get_contents(resource_path('views/livewire/bulk-operation-progress.blade.php'));
expect($contents)->toContain('new MutationObserver');
expect($contents)->toContain('teardownObserver');
expect($contents)->not->toContain('wire:poll.5s="refreshRuns"');
})->group('ops-ux');