Testing modal form fields.

Given an action with a modal, with a form schema, I'd like to test that the form has specific fields. How is that done?

Example action
Action::make('export')
    ->label('Export Records')
    ->form([
        Select::make('export_format')
            ->label('Export Format')
            ->options([
                'csv' => 'CSV',
            ])
            ->required(),
    ])
    ->modalWidth('lg')
    ->modalSubmitActionLabel('Export')
    ->icon('heroicon-o-cloud-arrow-down')
    ->color('gray')
    ->link();


Example test
/** @test */
public function export_action_modal_has_select_field_for_format()
{
    Livewire::test(DomainActions::class, ['record' => $this->domain])
        ->mountAction('export')
        ->assertFormExists('form') // works
        ->assertFormFieldExists('export_format') // fails;
}


Fails with Failed asserting that a field with the name [export_format] exists on the form with the name [form] on the [App\Filament\App\Resources\DomainResource\Widgets\DomainActions] component. Failed asserting that null is an instance of class Filament\Forms\Components\Field.
Was this page helpful?