I am trying to test my Laravel Filament (V3) app with Pest. Fairly new to Pest so i'm not sure what i'm doing wrong:
I have a User Factory:
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'created_at' => now()->subDays(3),
'updated_at' => now()->subDays(2),
'email_verified_at' => now()->subDay(),
'password' => Hash::make('password'),
'remember_token' => Str::random(10),
];
}
In my TestCase.php the setup method is implemented, as the docs say:
protected function setUp(): void
{
parent::setUp();
$this->actingAs(User::factory()->create());
}
My ClientTest.php contains the following test:
it('can render page', function () {
$this->get(ClientResource::getUrl('index'))->assertSuccessful();
});
When I run the test, I keep getting the following error:
Expected response status code [>=200, <300] but received 403.
I have figured it out, so to help others who might be experiencing the same:
I failed to implement the FilamentUser on my User model and give it the canAccessPanel() method, like: