FilamentF
Filamentβ€’2y ago
ModestasV

Testing Filament Relation Manager

Hey,

Currently, I have an issue with Relation Manager testing. Here's the two problems I have:

  1. RelationManager::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given,
    • this comes from the code below
  2. I have no idea which method actually submits the form πŸ™‚
Does anyone have any experience or examples how to test relation managers?

So far, I have this:

 livewire(FieldsRelationManager::class, [
        'ownerRecord' => $crud,
        'pageClass' => EditCrud::class,
    ])
        ->fillForm([
            'type' => CrudFieldTypes::TEXT,
            'validation' => CrudFieldValidation::REQUIRED,
            'label' => 'Test Field',
            'tooltip' => 'Test Tooltip',
            'in_create' => true,
            'in_edit' => true,
            'in_list' => true,
        ])
        ->assertSuccessful();


And it successfully loads the relation manager as long as I don't have a form, but as soon as I do - it crashes. It might be that I am incorrectly setting the parameters, but I'm unsure.

I have tried looking at the documentation, but I'm probably blind and could not find anything related. I took a look at google search and most of the same issue were on custom Livewire pages.

Reference:
https://filamentphp.com/docs/3.x/tables/testing
https://laracasts.com/discuss/channels/laravel/testing-filamentphp-error-filamentinfolistsinfolist-given
https://github.com/filamentphp/filament/discussions/8962

Ideas are welcome much appreciated!
Laracasts
GitHub
Hello all, I made filament custom page with a form and some logic. Please find the code of the page below. The form is working properly. However, when I set some test (code below), I have an error ...
Was this page helpful?