Test EditUser livewire class gives 403
What I am trying to do:
I am trying to setup tests for the EditUser class in my app. I use Pest. When I create the livewire instance and dump it I get the default 403 view. Please see the code below.
What I did:
I checked if my acting as user can update the other user with the UserPolicy. This method returns true. I checked if the canAccessPanel method of Filament in the User model gets called. It doesn't get called. I am not sure if it should be called during tests though. Also i checked the value of the record of the edit page. It's null. Please see the code below to check how I pass the id of the record to the class.
My issue/the error:
When I dump the livewire instance, I see the html of the default 403 page. However, I expect it to give the edit page.
Code:
Solution:Jump to solution
I solved this by checking if viewAny in the UserPolicy was returning true for my specific case. It returned false, that's why I was getting a 403 error on the edit page.
Edit: also, I use multi-tenancy so it's important to call in the setup of my tests....
1 Reply
Solution
I solved this by checking if viewAny in the UserPolicy was returning true for my specific case. It returned false, that's why I was getting a 403 error on the edit page.
Edit: also, I use multi-tenancy so it's important to call in the setup of my tests.
Marking this one as solved.