How to test Infolist Action?
I have a infolist with a ActionsGroup, I want to test if those buttons are working, but I can't figure out how to trigger those actions in the tests. (they work normally in the app)
Infolist Action:
Test:
With that test I get:
The button does exists in the test because I "assertSee" it and it passes, but I cannot call it's action
16 Replies
I guess it should be something like this:
->callInfolistAction('cancelBooking', ['booking' => $booking]);
still didn't work, I've tried
$booking->getKey()
, some different ways to writing, callMountedInfolistAction
...
these don't cause errors, but they don't trigger the button eitherI think you need to mountInfoListAction() before you call it.
@Bruno Silva figure this out? I am in the same boat. Can't get past teh getKey error
Actually not, @Leandro Ferreira was also helping me through a github discussion but I still couldn't make it work.
Leandro, even removing
disabled
condition and just trying to make the assertionActionEnabled
or assertInfolistActionEnabled
, it didn't work, I got this error:
I changed the Action name to "test" only to see if it was any problem with a two-word name.Are you able to create a mini repo on Github to reproduce this issue? or @Mark Chaney?
You can also share your repo. I can take a look
I can make it, I'll send it later tonight
let me know please
super dirty, but if i make a custom Entry field, then use -registerActions() and then call them in the blade of that custom entry, I can then target them with a test using . So custom entry component would be
I absolutely despise it though as its super dirty
my blade for the custom entry compoennt is
so think the problem is not really having a $component to target in the normal infolist
yeah I thought that too, I've tried passing the ViewPage class name, I didn't know what component is expecting, didn't think about livewire component though
anyway here's the repo with the same problem:
https://github.com/brunomdsilva/filament-test.git
GitHub
GitHub - brunomdsilva/filament-test
Contribute to brunomdsilva/filament-test development by creating an account on GitHub.
Solution
@Bruno Silva use this
@Leandro Ferreira shouldn’t it work with the helper though? I’m assuming this is a workaround?
Yeah, I don't understand exactly why, but the helpers work like this:
I think the
.XXX
is because of how the element is in the DOM:
Thanks Leandro, helped a lot 🙏I think if we encounter any issues or need to test specific scenarios, we can use
->call()
.
In addition, ->callInfolistAction('.updateUserNameAction', 'updateUserName')
with this example, should have the same result.this worked. now i can remove all that custom entry component that i was using. thanks!