FilamentF
Filament2y ago
Jo

Testing actions defined within extraModalFooterActions()

When using Pest for testing, is there a way to test the actions defined within extraModalFooterActions() ? I've tried the obvious things like mounting / calling the action which calls the modal first and even dot notation but nothing seems to be working.

Basic example:

Action::make('action1')
    ->requiresConfirmation()
    ->extraModalFooterActions(fn (Action $action): array => [
        $action->make('action2'),
    ]);


This test passes:

    livewire(ViewPost::class, [
        'record' => $this->record->getRouteKey(),
    ])
        ->mountInfolistAction('component', 'action1')
        ->assertInfolistActionExists('component', 'action1');


This fails:

    livewire(ViewPost::class, [
        'record' => $this->record->getRouteKey(),
    ])
        ->mountInfolistAction('component', 'action2')
        ->assertInfolistActionExists('component', 'action2');


Failed asserting that a infolist action with name [action2] is registered to [component] on the [App\Filament\Resources\PostResource\Pages\ViewPost] component.
Failed asserting that null is an instance of class Filament\Infolists\Components\Actions\Action.


I just want to be able to do a similar test for action2 as I can do for action1
Solution
mountInfolistAction after a mountInfolistAction is the issue.. not sure if it is a bug, but I think it isn't a big problem if you can use call()
Was this page helpful?