richardfila
richardfila
FFilament
Created by _Davide_ on 12/28/2023 in #❓┊help
how to test anonymous actions?
I found the following code works for anonymous actions in an infolist. There are similar mount / call mounted functions for forms etc. Livewire::test(ViewUser::class, ['record' => $user->id]) ->call( 'mountInfolistAction', 'resendActivationEmail', '.resendActivationEmailAction', 'infolist', ) ->callMountedInfolistAction(); Where "resendActivationEmail" is the name of my anonymous action as defined in Action::make(). The next field with ".resendActivationEmailAction" is that same name prepended with a dot and appended with "Action". You can see all these values by inspecting the button element of the Action in the browser. On the Action used in the code shown I have requireConfirmation() set, so clicking the Action button opens a modal. Therefore the second call in the test callMountedInfolistAction() is required to call the modal and effectively submit the empty form it contains to act as pressing 'Yes' to the confirmation.
7 replies