Caz
Caz
FFilament
Created by Caz on 6/19/2024 in #❓┊help
Testing form data for a simple resource (Filament v3).
Gooday, I hope someone can help me. I am writing a test to check the form data is valid on a resource created with the --simple option. The following code is an example and works as expected:
php
livewire(CityResource\Pages\ManageCities::class)
->mountAction('create')
//Check that all fields are required
->setActionData([
'state'=>null,
'name' => null
])
->callMountedAction()
->assertHasActionErrors(['state' => ['required'], 'name' => ['required'])]);
php
livewire(CityResource\Pages\ManageCities::class)
->mountAction('create')
//Check that all fields are required
->setActionData([
'state'=>null,
'name' => null
])
->callMountedAction()
->assertHasActionErrors(['state' => ['required'], 'name' => ['required'])]);
In the modal form the name field is disabled until a state has been chosen. I want to extend this code to check that the name field is disabled. If I use ->assertFormFieldIsEnabled('name') I get an error: Filament\Resources\Pages\ListRecords::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given. This code above is merely an example and my actual form has more fields which I'd like to check using the built-in form testing functions but not sure how to get around this error. Your help is appreciated.
2 replies