TenantAtlas/tests/Feature/TenantReview/TenantReviewRegisterTest.php
ahmido a4f2629493 feat: add tenant review layer (#185)
## Summary
- add the tenant review domain with tenant-scoped review library, canonical workspace review register, lifecycle actions, and review-derived executive pack export
- extend review pack, operations, audit, capability, and badge infrastructure to support review composition, publication, export, and recurring review cycles
- add product backlog and audit documentation updates for tenant review and semantic-clarity follow-up candidates

## Testing
- `vendor/bin/sail bin pint --dirty --format agent`
- `vendor/bin/sail artisan test --compact --filter="TenantReview"`
- `CI=1 vendor/bin/sail artisan test --compact`

## Notes
- Livewire v4+ compliant via existing Filament v5 stack
- panel providers remain in `bootstrap/providers.php` via existing Laravel 12 structure; no provider registration moved to `bootstrap/app.php`
- `TenantReviewResource` is not globally searchable, so the Filament edit/view global-search constraint does not apply
- destructive review actions use action handlers with confirmation and policy enforcement

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #185
2026-03-21 22:03:01 +00:00

61 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\Reviews\ReviewRegister;
use App\Models\Tenant;
use App\Models\User;
use App\Support\Workspaces\WorkspaceContext;
use Livewire\Livewire;
it('lists only entitled tenant reviews in the canonical review register and filters by tenant', function (): void {
$tenantA = Tenant::factory()->create(['name' => 'Alpha Tenant']);
[$user, $tenantA] = createUserWithTenant(tenant: $tenantA, role: 'owner');
$tenantB = Tenant::factory()->create([
'workspace_id' => (int) $tenantA->workspace_id,
'name' => 'Beta Tenant',
]);
createUserWithTenant(tenant: $tenantB, user: $user, role: 'readonly');
$tenantC = Tenant::factory()->create([
'workspace_id' => (int) $tenantA->workspace_id,
'name' => 'Gamma Tenant',
]);
$foreignOwner = User::factory()->create();
createUserWithTenant(tenant: $tenantC, user: $foreignOwner, role: 'owner');
$reviewA = composeTenantReviewForTest($tenantA, $user);
$reviewB = composeTenantReviewForTest($tenantB, $user);
$reviewC = composeTenantReviewForTest($tenantC, $foreignOwner);
$this->actingAs($user);
setAdminPanelContext();
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenantA->workspace_id);
Livewire::actingAs($user)
->test(ReviewRegister::class)
->assertCanSeeTableRecords([$reviewA, $reviewB])
->assertCanNotSeeTableRecords([$reviewC])
->filterTable('tenant_id', (string) $tenantB->getKey())
->assertCanSeeTableRecords([$reviewB])
->assertCanNotSeeTableRecords([$reviewA, $reviewC]);
});
it('shows a single clear-filters empty-state action when no review rows match the current register view', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$review = composeTenantReviewForTest($tenant, $user);
$this->actingAs($user);
setAdminPanelContext();
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
Livewire::actingAs($user)
->test(ReviewRegister::class)
->searchTable('no-such-review-row')
->assertCanNotSeeTableRecords([$review])
->assertTableEmptyStateActionsExistInOrder(['clear_filters_empty'])
->assertSee('No review records match this view')
->assertSee('Clear filters');
});