FilamentF
Filament9mo ago
Batman

Test for current route (or query params)

I have a tab in ListUsers::class that only a Super Admin can see. If an Admin tries to view the route by directly putting it into the url, it correctly returns the first tab. This seems to be default behavior of Filament and is what I desire. Since it is not a redirect, and is the same component, I am having a hard time finding out how to correctly test that the url actually returned is ListUsers::class [activeTab=all] or admin/users?activeTab=all.

Getting the current URL or Route returns a Livewire Testing Endpoint.

Any help is appreciated.

it('disallows admins from viewing tab for deleted users', function () {
    asAdmin();

    livewire(ListUsers::class, ['activeTab=deleted']);
    // assert that the current route is actually equal to: 
    // ListUsers::class, ['activeTab=all']
});
Was this page helpful?