testing panels in pest?
I have 2 panels with admin as the default panel.
now, when I want to write tests for the App Panel, then im facing problems.
1. the routes are not correct SomeResource::getUrl() returns an admin route and not a App route.
2. If I use a route() instead, then the $tenant url parameter is missing.
Is there any nice way to test the non default panel in filament without writing tons of pest setup code?
4 Replies
You need to pass the panel id to the getUrl method
In the argument list for getUrl just do panel: 'panel_id_here'
Hi Connor,
I do:
$this->get(TenantResource::getUrl(name:'index', panel:'app'))
But it still returns the admin route which is a "route not defined" exception.
wait.. it works. Thanks very much!
But wait.. this still is not the solution, as the livewire helper is not working as expected:
livewire(SomeResource\Pages\ListTextEntries::class)
->assertCanSeeTableRecords($textEntries);
This still gets the wrong route.
Hello, I'm writing my tests for both the Admin and App panels using a LoginHelper. The LoginHelper contains a login function for both the Admin and App panels. In each test file, I utilize the LoginHelper with the appropriate function based on the nature of the test (admin or app). Example below:
LoginHelper.php:
TestFile:
Thank you @tim_vdv the below did the trick
\Filament\Facades\Filament::setCurrentPanel(\Filament\Facades\Filament::getPanel('app'));
\Filament\Facades\Filament::setTenant($organization);