Test authentication with Pest
How could you best test the login of filament dashboard, since there is no POST option on the login route?
12 Replies
refer to the livewire docs for testing
That raises more questions for me than answers
what's not clear? filament uses livewire so you test livewire components
Laravel
Testing | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Yes, I understand that, but I only see examples for a
PostResource
and I specifically want to test the authentication. So logging in, registering and logging out.Livewire tests...
But I don't understand why do you want to test core features?
You have a good point there 😅
Filament is still quite new to me, but I have worked with Laravel before in the past. What I mainly miss are good guidelines on how you should/shouldn't set up tests (from A to Z).
Maybe you should first learn livewire and how to test components/actions. I think there should be some good tests in filament repo
I've now managed to make some specific tests with livewire 🙂
Is there a useful CI/CD workflow that I could use on Github, so that I can run the tests at each PR?
You can using github actions. Plenty tutorials
Still a question about testing authentication with pest
Given this function in the User model:
How could I test that a normal user with the role
user
does not have access to the panel?
In the filament repository I came across a test that would best suit this:
As a test it passes, but it does not ensure that I get code coverage on the return false;
🤔
I could of course also omit the return false
, but phpstan actually expects that there is a return value in any case