Testing a form action.

Hey,

I have the following action on my ListUsers field:

    protected function getHeaderActions(): array
    {
        return [
            Actions\CreateAction::make(),
            Actions\Action::make('nodigGebruikerUit')
                ->form([
                    TextInput::make('email')
                        ->email()
                        ->required()
                ])
                ->action(function ($data) {
                    $invitation = Invitation::create(['email' => $data['email']]);

                    Mail::to($invitation->email)->send(new TeamInvitationMail($invitation));

                    Notification::make('invitedSuccess')
                        ->body('De gebruiker is uitgenodigd')
                        ->success()->send();
                })
        ];
    }


Now I am trying to write a test:

it('sends an email when the button is pushed', function () {
    login(); //don't mind this it's my own helper function
    Mail::fake();

    livewire(ListUsers::class)
        ->callAction('nodigGebruikerUit')
        ->callAction('send', ['email', 'test@example.com']);


    Mail::assertSent(TeamInvitationMail::class, function($mail) {
        return $mail->hasTo('test@example.com');
    });

});


I am getting an error: failed asserting an action with the name [send] exists.
I am not sure how to continue. I have a button, when I press that button a form loads and I want to test that when I press that button, en email is sent.

Thanks for your help.
Solution
I think
->callAction('nodigGebruikerUit')
->set('mountedActionsData.0.email', 'test@example.com')
->callMountedAction()


not sure if fillForm works
Was this page helpful?