45 lines
1.7 KiB
PHP
45 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\BaselineProfileResource;
|
|
use App\Models\BaselineProfile;
|
|
use App\Support\Baselines\BaselineProfileStatus;
|
|
use Filament\Facades\Filament;
|
|
|
|
it('keeps baseline profiles workspace-owned while retired tenant navigation URLs stay unavailable', function (): void {
|
|
Filament::setCurrentPanel('admin');
|
|
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
expect(BaselineProfileResource::shouldRegisterNavigation())->toBeTrue();
|
|
|
|
$this->actingAs($user)
|
|
->withSession([\App\Support\Workspaces\WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
|
|
->get("/admin/t/{$tenant->external_id}")
|
|
->assertNotFound();
|
|
});
|
|
|
|
it('keeps baseline profile urls workspace-owned even when a tenant context exists', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$profile = BaselineProfile::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'status' => BaselineProfileStatus::Archived->value,
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->withSession([\App\Support\Workspaces\WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]);
|
|
|
|
$workspaceUrl = BaselineProfileResource::getUrl(panel: 'admin');
|
|
|
|
expect($workspaceUrl)->toContain('/admin/baseline-profiles');
|
|
expect($workspaceUrl)->not->toContain("/admin/t/{$tenant->external_id}/baseline-profiles");
|
|
|
|
$this->get($workspaceUrl)->assertOk();
|
|
$this->get(BaselineProfileResource::getUrl('view', ['record' => $profile], panel: 'admin'))->assertOk();
|
|
$this->get("/admin/t/{$tenant->external_id}/baseline-profiles")->assertNotFound();
|
|
|
|
expect($profile->fresh()->status)->toBe(BaselineProfileStatus::Archived);
|
|
});
|