Testing actions defined within extraModalFooterActions()
When using Pest for testing, is there a way to test the actions defined within
extraModalFooterActions()
? I've tried the obvious things like mounting / calling the action which calls the modal first and even dot notation but nothing seems to be working.
Basic example:
This test passes:
This fails:
I just want to be able to do a similar test for action2
as I can do for action1
Solution:Jump to solution
mountInfolistAction
after a mountInfolistAction
is the issue.. not sure if it is a bug, but I think it isn't a big problem if you can use call()
10 Replies
Where is the action?
Well that was a cut-down example because my real code is quite long. I guess it wasn't clear though so I've written a complete new example which is just the Infolist and the Tests to be more clear:
Infolist:
Test:
The 1st test passes, the 2nd test fails.
.action2Action
instead of .action1Action
?Well that's what I thought at first, yes, but Filament actually renders the HTML as
.action1Action
for the 2nd one too.This is how the HTML is rendered by Filament based on the infolist code I gave above. Also of note is the fact that
component
and name
are the opposite way around here than required by mountInfolistAction()
(also, I did try
.action2Action
and it made no difference, the test fails in the same way)
Also, something very weird which I don't understand is that this does pass:
Note that I'm using .action1Action
for both of them and that I've switched the name
and component
arguments around in call()
compared to the order they're in when using mountInfolistAction()
as it seems to require them in the opposite order.
So two weird things here: 1) It works with call()
but not mountInfolistAction()
and 2) It necessary to swap the order of the arguments. Do you think it could be a bug?try this in the 2nd modal
Yes, that passes too.
Solution
mountInfolistAction
after a mountInfolistAction
is the issue.. not sure if it is a bug, but I think it isn't a big problem if you can use call()
Yeah, it's fine now that I know to do it 🙂
Thank you for your help!