How to write tests for create, edit and delete actions of Relation managers
This is what I am trying
it('can add contacts', function () {
$admin = Admin::factory()->create();
$contact = Contact::factory()->make();
livewire(AdminResource\RelationManagers\ContactsRelationManager::class, [
'ownerRecord' => $admin,
'pageClass' => EditAdmin::class,
])
->set('form', [
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => '[email protected]',
'mobile' => $contact->mobile,
'phone' => $contact->phone,
])
->call('create')
->assertSee('Contact created successfully');
});
and getting following error
Error: App\Filament\Resources\AdminResource\RelationManagers\ContactsRelationManager::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given, called in /Users/xxxx/myfila/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 54
Solution:Jump to solution
I have an example using attach action. Maybe it can help you
https://github.com/filamentphp/filament/discussions/9208#discussioncomment-7337715...
GitHub
I'm using AttachAction in a relationship, but I'm not sure how to w...
I couldn't find any information in the documentation at https://filamentphp.com/docs/3.x/panels/testing#relation-managers Is it possible to write tests to confirm that a record has been attache...
3 Replies
Solution
I have an example using attach action. Maybe it can help you
https://github.com/filamentphp/filament/discussions/9208#discussioncomment-7337715
GitHub
I'm using AttachAction in a relationship, but I'm not sure how to w...
I couldn't find any information in the documentation at https://filamentphp.com/docs/3.x/panels/testing#relation-managers Is it possible to write tests to confirm that a record has been attache...
@Leandro Ferreira Perfect. Thank you so much.
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:
I do get that similar error:
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.