F
Filamentβ€’2y ago
Oussama

Testing Creating a model via modal and File Upload

I'm trying to add tests that deal with creating/editing users /w avatars. Most testing examples in the docs related to having CreateRecord and EditRecord pages, not through modal actions.
it('can create a user', function () {
livewire(UserResource\Pages\ManageUsers::class)
->callPageAction('create', [
'name' => 'Saul Goodman',
'email' => '[email protected]',
'password' => 'some-password',
'avatar' => 'any.string.goes.here',
])
->assertHasNoPageActionErrors();
});
it('can create a user', function () {
livewire(UserResource\Pages\ManageUsers::class)
->callPageAction('create', [
'name' => 'Saul Goodman',
'email' => '[email protected]',
'password' => 'some-password',
'avatar' => 'any.string.goes.here',
])
->assertHasNoPageActionErrors();
});
This successfully creates a record and all, but I don't see a way of testing file uploads or that a field is hidden or not when creating vs editing. TL;DR: What's the proper way of testing creating or editing records when using modal actions, especially when it contains a file upload Any guidance is appreciated πŸ™
2 Replies
Dan Harrin
Dan Harrinβ€’2y ago
potentially 'avatar.0' => UploadedFile::fake() or something
Want results from more Discord servers?
Add your server