Testing Custom Header Delete or Save Actions

When testing a custom header action, I'm unable to validate the contents of the modal I'd like to surface to my users. Is there a schema I need to pass in to my TestAction that the header actions are associated with? The Action:
protected function getHeaderActions(): array
{
return [
DeleteAction::make('customHeaderAction')
->modalDescription(function (?Measurement $record) {
if (! $record->isUsedByRelatedModels()) {
// Show the default confirmation if there are no linked items
return null;
} else {
return new HtmlString(
'You cannot delete this record<br><br>'
.'Use the form at the bottom of this page to see which items need to enable deleting.'
);
}
})
];
}
protected function getHeaderActions(): array
{
return [
DeleteAction::make('customHeaderAction')
->modalDescription(function (?Measurement $record) {
if (! $record->isUsedByRelatedModels()) {
// Show the default confirmation if there are no linked items
return null;
} else {
return new HtmlString(
'You cannot delete this record<br><br>'
.'Use the form at the bottom of this page to see which items need to enable deleting.'
);
}
})
];
}
My Test:
livewire(EditMeasurement::class, [
'record' => $record->id,
])
->assertActionExists(TestAction::make('customHeaderAction'))
->mountAction(TestAction::make('customHeaderAction'))
->assertSee('You cannot delete this record');
livewire(EditMeasurement::class, [
'record' => $record->id,
])
->assertActionExists(TestAction::make('customHeaderAction'))
->mountAction(TestAction::make('customHeaderAction'))
->assertSee('You cannot delete this record');
I've also tried changing mountAction to callAction and have tried just passing in the string 'customHeaderAction' to both. It does appear that the action exists, so I'm unsure that this is a bug since I have many other action-content-assertion tests that are passing fine, but any of my tests that assert functionality of custom header actions are failing.
1 Reply
mrkbingham
mrkbinghamOP3w ago
GitHub
[4.x] Action modal content not found in tests · Issue #17857 · fi...
Package filament/filament Package Version v4.0.17 Laravel Version v12.30.0 Livewire Version v3.6.4 PHP Version PHP 8.4.12 Problem description When mounting an action on a form schema - either in th...
GitHub
[4.x] Add key to form actions content component for use with testin...
Description This is a proposal to add an explicit key to the default form action components. If there is any modification to the behavior of the default actions in the form, such as a modal to conf...

Did you find this page helpful?