F
Filament8mo ago
shabxs

Testing Infolists headerAction

How do we test infolist headerAction which is on an ViewPage with infolist
Solution:
define a key in the section, ->key('sectionStatus') Then, you can use ```php ->assertInfolistActionExists('sectionStatus','updateStatus')...
Jump to solution
4 Replies
LeandroFerreira
LeandroFerreira8mo ago
what code are you using?
shabxs
shabxsOP8mo ago
return $infolist ->schema([ Section::make('DETAILS AND STATUS') ->headerActions( [ Action::make('updateStatus') ->fillForm(fn (Program $record): array => [ 'ProgramStatus' => $record->status, ]) ->form([ Select::make('ProgramStats') ->label('Program Status') ->options(fn() => ProgramStatus::class) ->required(), ]) ->action(function (array $data, Program $record): void { $record->status = $data['ProgramStatus'] ; $record->save(); }), I wanted to test this updateStatus action on a section header of infolist.
Solution
LeandroFerreira
LeandroFerreira8mo ago
define a key in the section, ->key('sectionStatus') Then, you can use
->assertInfolistActionExists('sectionStatus','updateStatus')
->mountInfolistAction('sectionStatus','updateStatus')
->assertInfolistActionExists('sectionStatus','updateStatus')
->mountInfolistAction('sectionStatus','updateStatus')
shabxs
shabxsOP8mo ago
Thanks for that quick reply... testing worked.. Also it seems that instead of 'key' we can also use 'id'. I believe both serve the same purpose
Want results from more Discord servers?
Add your server