Test: Route not defined
How should I approach this problem? I'm testing the admin panel, and it has a view route. However, when doing livewire(ListUsers::class), it throws this route not defined. I'm thinking Filament registers the route, but it's not yet registered in the tests
19 Replies
Filament does register the users, you shouldn't call the list class directly
It would be:
UsersResource::getUrl('index')
But, how would that looked like when
assertActionExists
?
Interested about this since I have a complex logic happening in this ListUsers and this logic happened in the actionfor insertAction I am unsure tbh, as my test use is limited.
But you can test inserting users with the create page?
UsersResource::getUrl('create')
UsersResource::getUrl('edit', $record)
etc
that is fine though
it's just that I put some logic in an Action, and now Im interested to know if it can be tested.... seems we need to use laravel's dusk?
Cool, I believe dusk is required. But I'll wait for someone else to help as I'm not familiar along those lines
mentioning dusk only results in 2 answers only? haha
No one tests properly haha
I got it now
I felt spoiled with filament haha
what's this?
See how it mentions ->callPageAction() with using pest π
Use that basis but with this docs for v3:
https://filamentphp.com/docs/3.x/panels/testing#deleting
Hopefully that helps π
I want to love that, but... the issue is still like this:
it can access users⦠ViewException
Route [filament.admin.resources.users.view] not defined I believe the page component renders fine, and also, I am testing in tenancy panel I think it's quite an issue https://discord.com/channels/883083792112300104/883083792653381695/940589107149701160
Route [filament.admin.resources.users.view] not defined I believe the page component renders fine, and also, I am testing in tenancy panel I think it's quite an issue https://discord.com/channels/883083792112300104/883083792653381695/940589107149701160
@ricardosawir I am experiencing a similar problem....if not the same.
I'm testing creating a resource in v3 with Tenancy....testing for a resource in a non-default panel.
I'm following the instructions here for creating a resource: https://filamentphp.com/docs/3.x/panels/testing#creating
The Create: Routing and render test (https://filamentphp.com/docs/3.x/panels/testing#routing--render-1) works...but I have to make sure I call
Filament::setTenant()
, otherwise it will fail.What is your exact error...? Mine appears to be something having to do with rendering the blade file. It's looking for the route for the right resource, but using the wrong tenant:
It must be a bug...or something's missing from the documentation....or both. π
Just to be clear...it's looking for this route:
filament.admin.resources.postings.index
But it should be looking for this route: filament.other-panel-name.resources.postings.index
It's weird because the first part of the test -- and other tests -- seem to work once I call Filament::setTenant()
.
I just drilled down a bit...inside Filament\Resources\Resource::getUrl()
, which is called when building the breadcrumbs, it has the right tenant, but the wrong panel.
It gets the panel right under some circumstances, but not this one, apparently. I'm not sure what I need to do, if anything. Again, I might be missing something or the docs are missing something....or there's a bug. π€
Seems like Filament::setCurrentPanel()
does the trick. π³oh nice @travis.elkins ! Your steps to get the error is almost identical to mine
i only tried setTenant, and didn't work. The same route error
Did you try
Filament::setCurrentPanel()
, too...?