Jo
Testing a Livewire component that is has been added to an Infolist
Thank you for replying. Yes, after writing a bunch of tests following this method it seeems to be working quite well. I also read on the Livewire site that testing components in isolation is the way to go, so it was obviously wrong for me to be essentially trying to test one component through another. Thanks again for your help!
14 replies
Testing a Livewire component that is has been added to an Infolist
So maybe I misunderstood how testing is supposed to be conducted? Is it good enough just to test the Resource for
assertSeeLivewire()
in one test and then for the next test test the actual Component for the behaviour of actions?14 replies
Testing a Livewire component that is has been added to an Infolist
Ok, so I've been tinkering about today to create a mini repo as you mentioned, and in doing so I have actually made some progress because the mindset behind making a mini repo is forcing me to go back to basics!
What I have discovered is that can do effective testing if I target the Livewire component directly. But I just can't do it from the resource. I have to do it in 2 steps. One step test
canSeeLivewire()
on the resource and then another test to do all the assertions for the actions on the Livewire component itself.
Anyway, I created the mini repo as you mentioned yesterday. If you have time, please take a look at the tests tests/Feature/PostTest.php
and let me know if you think this is the best way to do it or if there's a better way?
https://github.com/joseph-d/filament-livewire-test
My biggest concern doing it this way is that I'm not truly testing if the action works when nested in the resource, because I'm testing the two things separately. So I'd like to find an integrated way to accomplish this if it's possible?14 replies
Testing a Livewire component that is has been added to an Infolist
No, using
call
doesn't seem to make any difference. I also dumped out the entire output of the test and I can see from the HTML that it's telling the truth, the component really isn't there! So I think it must be something I'm missing in the way I'm doing livewire(ViewJob::class ...
etc that isn't including the Livewire component from the schema for some reason. I don't know what though.14 replies
Testing actions defined within extraModalFooterActions()
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?15 replies
Testing actions defined within extraModalFooterActions()
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.
15 replies
Testing relation managers
Anyone have any idea about this? It seems like I'm inadvertently testing whether the relationmanager works, when what I am really trying to do is test to see whether it's being displayed on a given page.
This is because I have logic to hide the relation manager when the record has a certain status. So I want to test for that.
3 replies
http instead of https production issue
With the latest Laravel 11 update, the way to do this has changed slightly, see https://laravel.com/docs/11.x/requests#configuring-trusted-proxies
7 replies