Filament testing breaks down as soon as i use a policy
So let's say i have a simple test:
THis works fine if there is no dataset policy, as soon as there is one i get this error:
FAILED Tests\Feature\DatasetTest > it can delete Error
Call to a member function getAction() on null at vendor/filament/actions/src/Testing/TestsActions.php:141 137▕ / @var array<string> $name */ 138▕ / @phpstan-ignore-next-line */ 139▕ $name = $this->parseNestedActionName($name); 140▕ ➜ 141▕ $action = $this->instance()->getAction($name); 142▕ 143▕ $livewireClass = $this->instance()::class; 144▕ $prettyName = implode(' > ', $name); 145▕ +9 vendor frames 10 tests/Feature/DatasetTest.php:84 The policy returns true for all functions.. does anybody have a clue what's going on?
Call to a member function getAction() on null at vendor/filament/actions/src/Testing/TestsActions.php:141 137▕ / @var array<string> $name */ 138▕ / @phpstan-ignore-next-line */ 139▕ $name = $this->parseNestedActionName($name); 140▕ ➜ 141▕ $action = $this->instance()->getAction($name); 142▕ 143▕ $livewireClass = $this->instance()::class; 144▕ $prettyName = implode(' > ', $name); 145▕ +9 vendor frames 10 tests/Feature/DatasetTest.php:84 The policy returns true for all functions.. does anybody have a clue what's going on?
6 Replies
bump
You don’t have a logged in user, right?
correct, the livewire component wont mount as it is not authorised to
Ohhhh
Your right
interesting
then i propably also know the fix
i have this in my test case:
so i can use that in http calls
like so:
so i have to figure out how to use that in the livewire tests also
its the same
actingAs()
you dont need to chain it
just call it somewhere before in the test
ahh okay
thanks!