FilamentF
Filament15mo ago
Naseg

Testing form actions

Couldn't see this in the docs. Given that a livewire component is set up with a custom form and action as follows:

public function form(Form $form): Form
{
    return $form->schema([
        TextInput::make('name')
            ->required(),
        Actions::make([
            Action::make('action')
                ->action(/** doing something **/)
    ]);
}


With the following test (which fails) I can't find a way to pass the form to callAction order to test the action:

livewire(MyPage::class)
    ->fillForm([
        'name' => 'something'
    ])
    ->callAction('action');

This results in Failed asserting that an action with name [action] exists on the [App\Filament\Pages\MyPage] page. Does such functionality exist?

Here a component name should be provided but we don't have one.

livewire(MyPage::class)
    ->fillForm([
        'name' => 'something'
    ])
    ->assertFormComponentActionExists('component','action')
}

We need to solve this.
Was this page helpful?