F
Filament2w ago
Caz

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.
0 Replies
No replies yetBe the first to reply to this messageJoin