How to test modal actions?
I registered a modal action using the
registerModalActions()
function and when I mount the "parent" action and use the assertSee()
function to check for the modal action's label I can find it just fine, but if I try to actuall call the modal action it says that no action with that name exists on my page, do I maybe have to load the action differently?
This is how I'm currently trying to access it:
11 Replies
Bump
I already checked out the docs but I can't find anything on modal actions specifically.
And if they're treated like normal actions then I think I found a bug.
Actions are modal actions, except if you are using a form you need to pass in the data.
Okay so if I register an action in a modal, I should be able to access it if I mount the action that opens my modal, right?
Did you see part one?
https://filamentphp.com/docs/3.x/actions/testing#getting-started
It says about passing data into an action? the data would normally come from the form so that's how you would do it.
Sorry, maybe I explained my problem wrong but I don't want to pass any data into the modal action or in general do anything, I just want to test if the action exists (->assertActionExists()).
I had to remove some stuff from the action since it's work related, but here's how the modal action is created and how I display it inside of the modal:
And it does display if I click on the ImportAction.
But when I run my test as described I get a
Failed asserting that an action with name [mymodalaction] exists on ...
error.
If I change the test to: ->assertSee('My modalaction');
then it passes.
BumpDo you have a user check on the visible for the action?
No :(