Testing page footer actions in v4
I'm attempting to call a page footer action in a test for a resource page. Typically, in an
EditRecord
page for example, we would have these footer actions:
One essentially fires the public save()
function through wire:submit
and the other uses JS (and doesn't really need testing).
For those that call public functions, typically one can test by using ->call(…)
in the test, bypassing having to mount the action, etc.
For header actions, ->callAction(TestAction::make('header_action'))
works because it's at the top level of the component, but footer actions cannot be resolved and called by the same function.
Consider a custom footer action:
Attempting ->callAction(TestAction::make('footer_action'))
leads to a failed assertion that the footer action is visible.
The composition of pages has changed in v4 with schemas, Form
components, EmbeddedSchemas
etc., and it's quite confusing to know exactly which combinations of $component
and $schema
parameters to use with ->schemaComponent($component, $schema)
on TestAction
.
It would seem that now, these actions have become children of an Actions
component in the footer of a Form
, which eventually forms part of the content
Schema
.
What function calls should I make on the Livewire Testable
to target these (form) footer actions?4 Replies
@Jonathan Christiani did you make any progress on this one? I'm hitting the same issue
No I think it’s a bug from filament
Okay @Jonathan Christiani I've got a proposal over here to resolve this issue:
https://github.com/filamentphp/filament/pull/17875
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...
But, for now, here's a workaround I'm using. By adding this to your resource page, it adds a key to the action group for the form:
Which then makes this TestAction work in your tests:
TestAction::make('save')->schemaComponent('form-actions-content-component', 'content')