tanner
tanner
FFilament
Created by Akshay Bokade on 10/27/2023 in #❓┊help
How to write tests for create, edit and delete actions of Relation managers
I am trying to very similar where I have a Form, which has a RelationManger of many Fields. I am trying to test the Field record can be updated. I don't have any Attach action, as I am just using the default Edit action. My tests look similar as:
it('can show field relation manager form', function () {
$form = Form::factory()->has(Field::factory(1))->create();

livewire(FieldsRelationManager::class, [
'ownerRecord' => $form,
'pageClass' => EditForm::class,
])
->assertTableActionExists('edit')
->mountTableAction('edit', $form->fields->first()->id)
->assertFormSet([
'name' => $form->fields->first()->name,
'description' => $form->fields->first()->description,
'type' => $form->fields->first()->type,
]);
});
it('can show field relation manager form', function () {
$form = Form::factory()->has(Field::factory(1))->create();

livewire(FieldsRelationManager::class, [
'ownerRecord' => $form,
'pageClass' => EditForm::class,
])
->assertTableActionExists('edit')
->mountTableAction('edit', $form->fields->first()->id)
->assertFormSet([
'name' => $form->fields->first()->name,
'description' => $form->fields->first()->description,
'type' => $form->fields->first()->type,
]);
});
I do get that similar error:
Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given
Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given
I dont see how to test an InfoList as I dont see that section in the docs. So I am a bit confused here if this is supposed to be a Form or an InfoList.
5 replies