Pest Test and sending invalid $data to form?
So I have . right now i get the error
ErrorException: Attempt to read property "mountedTableActions" on null
if i try to pass a role value that doesnt exist in the Select::make('role') field. This worked fine with livewire 2 and earlier pests as i would just check after the fact if the user exists. Right now it fails with that error. How should i instead test this properly. There isn't a test helper method to see what options are in the Select is there? This is actually multi check test there im testing about 6 different roles variations to make sure certain roles can or cannot create other users with role X, etc.8 Replies
well i think this might be the final pest test i have to figure out
so the first passes as it should, the second one fails. When an Action is loading a form, i dont really see a way to test much in that form. You pretty much have to send good data or else you cant test it.
its like Livewire is crashing and removing itself from the test
i dont know if i understand the point of the test though?
Well is there a way to test that a role value doesn’t exist the select options when the form is in a modal? Right now I’m just sending a select option in data that doesn’t exist and expecting it not the submit, worked with alpha
even if it was in the options, the user could still submit it via js
so can you try and replicate that and see what might be happening to livewire when you select an option that doesnt exist
i dont understand how the error is related, otherwise
@Dan Harrin well i guess the key thing that would solve most of this would be a way to test forms in a modal. Right now thats not possible, correct? You can send the data to it as shown above, but you cant do any of the typical form tests with individual fields or even really assertSee() with a form that is launched in a modal, right?
it theoretically is no different, as long as you mount the modal
assertSee should work if you mount it
mountTableAction(...)
mount is different to call, since call will execute the action and close the modal, mount will just open it
@Dan Harrin but $component->assertSee() then would on the whole usertable and not just the modal from what i can see when i do . How can I isolate just to the modal? Right now I am just testing first to see if it can find something
you could assertSeeHtml on the <option tag maybe?