How to test Infolist Action?

I have a infolist with a ActionsGroup, I want to test if those buttons are working, but I can't figure out how to trigger those actions in the tests. (they work normally in the app)

Infolist Action:
Action::make('cancelBooking')
  ->color('danger')
  ->requiresConfirmation()
  ->disabled(function (Booking $record) {
    return $record->cancelled_at || $record->entered_at || $record->exited_at;
  })
  ->action(function (Booking $record) {
    $record->cancelled_at = now();
    $record->save();

    Notification::make()
      ->title('Booking cancelled')
      ->success()
      ->send();
    }),


Test:
livewire(ViewBooking::class, ['record' => $booking->getRouteKey()])
  ->callInfolistAction('action', 'cancelBooking');

  expect($booking->status)->toBe(BookingStatus::CANCELLED);


With that test I get:
Call to a member function getKey() on null


The button does exists in the test because I "assertSee" it and it passes, but I cannot call it's action
Solution
@Bruno Silva use this
->call('mountInfolistAction', 'updateUserName', '.updateUserNameAction', 'infolist')
Was this page helpful?