F
Filament9mo ago
Hemith

Testing create form modal on ManageResource page.

it('can create author', function () {
livewire(ManageAuthors::class)
->callAction(CreateAction::class)
->fillForm([
'name' => 'New Author',
'email' => 'new@test.com'
])
->call('create');

dd(Author::all());
});
it('can create author', function () {
livewire(ManageAuthors::class)
->callAction(CreateAction::class)
->fillForm([
'name' => 'New Author',
'email' => 'new@test.com'
])
->call('create');

dd(Author::all());
});
Here is my code for testing the form. But nothing seems to be outputting.
2 Replies
Hemith
Hemith9mo ago
I managed to do it like this
it('can create author', function () {
expect(Author::count())->toBe(0);

livewire(ManageAuthors::class)
->callAction(CreateAction::class, [
'name' => 'New Name',
'email' => 'new@test.com'
])
->assertHasNoActionErrors();

$createdAuthor = Author::first();

expect($createdAuthor->name)->toBe('New Name');
expect($createdAuthor->email)->toBe('new@test.com');
expect(Author::count())->toBe(1);
});
it('can create author', function () {
expect(Author::count())->toBe(0);

livewire(ManageAuthors::class)
->callAction(CreateAction::class, [
'name' => 'New Name',
'email' => 'new@test.com'
])
->assertHasNoActionErrors();

$createdAuthor = Author::first();

expect($createdAuthor->name)->toBe('New Name');
expect($createdAuthor->email)->toBe('new@test.com');
expect(Author::count())->toBe(1);
});
bwurtz999
bwurtz9992w ago
I'm trying to follow along with your example
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => UploadedFile::fake(),
])
->assertHasNoActionErrors();
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => UploadedFile::fake(),
])
->assertHasNoActionErrors();
but I keep getting the error Property type not supported in Livewire for property: [{}]. I've tried searching on Google and in this Discord but I can't find anything to explain this. Do you have any ideas?