F
Filament14mo ago
fasna

Filament Testing Forms in Modal

I'm getting the exact same error, tried removing Infolist in my resource page too, still the same error. https://github.com/filamentphp/filament/discussions/8962
GitHub
Testing FilamentPHP Error - Filament\Infolists\Infolist given · fil...
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 ...
2 Replies
LeandroFerreira
LeandroFerreira14mo ago
could you share the test?
fasna
fasnaOP14mo ago
Just a very simple test, I'm loading the from through Modal, using headerActions CreateAction
it('has the correct form loaded', function () {

livewire(ListUsers::class)
->mountAction('create')
->assertFormExists();

});
it('has the correct form loaded', function () {

livewire(ListUsers::class)
->mountAction('create')
->assertFormExists();

});
I can create users, and this test works perfectly, I need more tests on the form for validation and form loading
test('non-admin can create new user using the form', function () {
expect(User::count())->toBe(1);
livewire(ListUsers::class)
->mountAction('create')
->setActionData([
'first_name' => $firstName = fake()->firstName(),
'last_name' => $lastName = fake()->lastName(),
'username' => fake()->userName(),
'email' => fake()->userName() . '@domain.com',
])
->callMountedAction();
$createdUser = User::latest()->limit(1)->get()->first();
expect($createdUser->first_name)->toBe($firstName);
expect($createdUser->last_name)->toBe($lastName);
expect(User::count())->toBe(2);
});
test('non-admin can create new user using the form', function () {
expect(User::count())->toBe(1);
livewire(ListUsers::class)
->mountAction('create')
->setActionData([
'first_name' => $firstName = fake()->firstName(),
'last_name' => $lastName = fake()->lastName(),
'username' => fake()->userName(),
'email' => fake()->userName() . '@domain.com',
])
->callMountedAction();
$createdUser = User::latest()->limit(1)->get()->first();
expect($createdUser->first_name)->toBe($firstName);
expect($createdUser->last_name)->toBe($lastName);
expect(User::count())->toBe(2);
});
Want results from more Discord servers?
Add your server