© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
20 replies
Bruno Silva

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();
    }),
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);
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
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')
->call('mountInfolistAction', 'updateUserName', '.updateUserNameAction', 'infolist')
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to fullWidth Action in Infolist
FilamentFFilament / ❓┊help
2y ago
Infolist ViewResource Test
FilamentFFilament / ❓┊help
3y ago
Database Notification Actions: Infolist in action?
FilamentFFilament / ❓┊help
3y ago
Infolist - send data to Action
FilamentFFilament / ❓┊help
3y ago