49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Filament\Pages\Tenancy\RegisterTenant;
|
|
use Filament\Facades\Filament;
|
|
use Livewire\Livewire;
|
|
|
|
describe('Register tenant page authorization', function () {
|
|
it('is not visible for readonly members', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'readonly');
|
|
|
|
$this->actingAs($user);
|
|
$tenant->makeCurrent();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('tenant'));
|
|
|
|
expect(RegisterTenant::canView())->toBeFalse();
|
|
|
|
Filament::setCurrentPanel(null);
|
|
});
|
|
|
|
it('is visible for owner members', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$this->actingAs($user);
|
|
$tenant->makeCurrent();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('tenant'));
|
|
|
|
expect(RegisterTenant::canView())->toBeTrue();
|
|
|
|
Filament::setCurrentPanel(null);
|
|
});
|
|
|
|
it('rejects readonly members when they try to mount the register-tenant page', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'readonly');
|
|
|
|
$this->actingAs($user);
|
|
$tenant->makeCurrent();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('tenant'));
|
|
|
|
Livewire::actingAs($user)
|
|
->test(RegisterTenant::class)
|
|
->assertNotFound();
|
|
|
|
Filament::setCurrentPanel(null);
|
|
});
|
|
});
|