F
Filamentβ€’2mo 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']);
// 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...
Jump to solution
3 Replies
Vp
VpOPβ€’2mo ago
I can make it pass validation and create.. but not the above
No description
Solution
LeandroFerreira
LeandroFerreiraβ€’5w ago
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
Vp
VpOPβ€’5w ago
πŸ˜‚ I fixed my other (previous) error using ->assertSee but forgot to apply here, assertSee is working fine.. thanks
Want results from more Discord servers?
Add your server