actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); $component = Livewire::test(ListEntraGroupSyncRuns::class) ->assertActionVisible('sync_groups'); $user->tenants()->detach($tenant->getKey()); app(\App\Services\Auth\CapabilityResolver::class)->clearCache(); $component->assertActionHidden('sync_groups'); Queue::assertNothingPushed(); }); it('shows sync action as visible but disabled for readonly members', function () { [$user, $tenant] = createUserWithTenant(role: 'readonly'); $this->actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); Livewire::test(ListEntraGroupSyncRuns::class) ->assertActionVisible('sync_groups') ->assertActionDisabled('sync_groups'); Queue::assertNothingPushed(); }); it('allows owner members to execute sync action (dispatches job)', function () { [$user, $tenant] = createUserWithTenant(role: 'owner'); $this->actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); Livewire::test(ListEntraGroupSyncRuns::class) ->assertActionVisible('sync_groups') ->assertActionEnabled('sync_groups') ->mountAction('sync_groups') ->callMountedAction() ->assertHasNoActionErrors(); Queue::assertPushed(EntraGroupSyncJob::class); }); });