How to test permissions for the Delete action?
I've got tests which check my policies are setup correct - they basically create a user with a role, and check the HTTP response from accessing that page (view/edit etc) through filament.
I'm not sure how to test the Delete permissions, because it's only an action - can anyone offer any suggestions?
Here's an example of my Edit User test: (any feedback/suggestions on the tests also welcome :))
3 Replies
Hmm, I prefer using Livewire tests instead of $this->get like Laravel tests.
https://filamentphp.com/docs/4.x/testing/testing-actions
So,
livewire()->callAction()
would be probably appropriate here. Example from the docs:
Thanks @Povilas Korop - I'm also using Livewire tests in other places and I'll see if I can use it to call the action - have you got any examples of calling actions via it perchance?
I don't think I have a ready-made example but its code would probably be the same as in the docs, what different example do you need?