F
Filamentβ€’16mo ago
trovster

Testing for Infolist actions (hintAction)

I have a Filament\Infolists\Components\TextEntry with a hintAction. Are there any action test methods for these? I am using ->test(Resource\View::class, ...) and assertActionExists works for actions setup in getHeaderActions`. But this fails for those on the infolist components.
4 Replies
Patrick Boivin
Patrick Boivinβ€’16mo ago
Do you want to assert that the action exists on the TextEntry or test the action code itself?
trovster
trovsterOPβ€’16mo ago
Both! πŸ™‚
Patrick Boivin
Patrick Boivinβ€’16mo ago
I'm not too familiar with testing on v3 yet, so maybe someone else can comment with more information. From a quick look though, I think one option is to manually dig into the infolist component to grab the TextEntry instance and perform assertions:
$testable = Livewire::test(ViewPage::class, ['record' => ...]);

/** @var ViewPage $page */
$page = $testable->instance();

$this->assertArrayHasKey(
'myCustomAction',
$page->getInfolist('infolist')->getComponents()[0]->getActions()
);
$testable = Livewire::test(ViewPage::class, ['record' => ...]);

/** @var ViewPage $page */
$page = $testable->instance();

$this->assertArrayHasKey(
'myCustomAction',
$page->getInfolist('infolist')->getComponents()[0]->getActions()
);
I think the same can be applied to mount and run the action
trovster
trovsterOPβ€’16mo ago
Thanks. I'll have to investigate a little more.
Want results from more Discord servers?
Add your server