F
Filament11mo ago
*

Testing select field options

I've implemented some logic to update the query in a select field using modifyQueryUsing(closure) Is there a way to test this logic? Maybe using a closure with assertFormFieldExists()? Like...
livewire(CreateUser::class)
->assertFormFieldExists('organisations', function (Select $input) {
return /* some logic here */;
});
livewire(CreateUser::class)
->assertFormFieldExists('organisations', function (Select $input) {
return /* some logic here */;
});
I've attempted to get the options using the $input closure param above with no luck. Note: My select is multiple() and has preload() Any help and/or insight appreciated.
7 Replies
LeandroFerreira
LeandroFerreira11mo ago
Would you like to check the select options? maybe livewire asserts? https://livewire.laravel.com/docs/testing#assertions ->assertSee, ->assertSeeHtml ?
Laravel
Testing | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
*
*11mo ago
assertSee and assertSeeHtml do not work for me in this case because the options are not readily available when the component renders. I know I can simulate clicks and then test the desired functionality, but looking for alternative takes on properly testing this without going out of the Filament component context, if that makes sense.
LeandroFerreira
LeandroFerreira11mo ago
Hum it is true
cpbret
cpbret9mo ago
@ilker did you ever figure this out? seems like a miss
*
*9mo ago
No, sadly I didn't and moved on without testing that.
cpbret
cpbret9mo ago
That's a bummer. I'm in a similar boat. I'll probably move on for now, but it's a pretty vital part of our site long term. I might need to help provide a patch for that.
hygazp
hygazp4mo ago
Just curious if there has been any updates since last message? Ive had a look through the documentation but couldn't find any updates and testing assertSee / assertSeeHtml still provides no results.