64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
|
|
it('shows only recent operations from the current users authorized tenant slice and does not enable polling', function (): void {
|
|
$tenantA = Tenant::factory()->create(['status' => 'active']);
|
|
[$user, $tenantA] = createUserWithTenant($tenantA, role: 'owner', workspaceRole: 'readonly');
|
|
|
|
$tenantB = Tenant::factory()->create([
|
|
'status' => 'active',
|
|
'workspace_id' => (int) $tenantA->workspace_id,
|
|
'name' => 'Forbidden Tenant',
|
|
]);
|
|
|
|
OperationRun::factory()->create([
|
|
'tenant_id' => (int) $tenantA->getKey(),
|
|
'workspace_id' => (int) $tenantA->workspace_id,
|
|
'type' => 'inventory_sync',
|
|
'initiator_name' => 'Accessible run',
|
|
]);
|
|
|
|
OperationRun::factory()->create([
|
|
'tenant_id' => (int) $tenantB->getKey(),
|
|
'workspace_id' => (int) $tenantB->workspace_id,
|
|
'type' => 'policy.sync',
|
|
'initiator_name' => 'Forbidden run',
|
|
]);
|
|
|
|
$response = $this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenantA->workspace_id])
|
|
->get('/admin')
|
|
->assertOk()
|
|
->assertSee('Inventory sync')
|
|
->assertDontSee('Forbidden Tenant')
|
|
->assertDontSee('Policy sync');
|
|
|
|
expect((string) $response->getContent())->not->toContain('wire:poll');
|
|
});
|
|
|
|
it('keeps recent operations diagnostic and separate from calm governance messaging', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
[$profile, $snapshot] = seedActiveBaselineForTenant($tenant);
|
|
seedBaselineCompareRun($tenant, $profile, $snapshot, workspaceOverviewCompareCoverage());
|
|
|
|
OperationRun::factory()->create([
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'type' => 'inventory_sync',
|
|
'status' => \App\Support\OperationRunStatus::Running->value,
|
|
'outcome' => \App\Support\OperationRunOutcome::Pending->value,
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
|
|
->get('/admin')
|
|
->assertOk()
|
|
->assertSee('Diagnostic recency across your visible workspace slice. This does not define governance health on its own.')
|
|
->assertDontSee('Visible governance, findings, compare posture, and activity currently look calm.');
|
|
});
|