FilamentF
Filament14mo ago
Vp

test `--simple` resource crud

I am testing simple resource like has form, has form field but I always got error, below are my test and error I had.
// Test
it('has a form', function () {
    livewire(AnnouncementResource\Pages\ManageAnnouncements::class)
        ->mountAction('create')
        ->assertFormExists();
});

it('has form fields', function (string $field) {
    livewire(AnnouncementResource\Pages\ManageAnnouncements::class)
        ->mountAction('create')
        ->assertFormFieldExists($field);
})->with(['title', 'detail']);

Error => Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given.
How Can I make this test pass. thanks in advance
EDITED: Now error only on form
Solution
because it is not a form, it is a modal form.
You could verify if the action was called or if the modal form contains something using assertSee or assertSeeHtml
https://filamentphp.com/docs/3.x/actions/testing#modal-content
Was this page helpful?