Form tests fails if the form does not have validation
Not sure if I got something wrong about the library API, but it seems that whenever a form does not have a phx-change event that reassigns its values, the params sent on the phx-submit event are always the default ones. Here is a repo that I created reproducing the issue, where this test fails if I remove the phx-change event.
Thanks for opening this issue @Wigny, and for adding a sample repo with a test failure 🙏 (that's huge help!)
I haven't had time to look at this yet, but I will as soon as I can. Or if someone else wants to take a stab at it, I'd be happy to review a PR.
@Wigny I haven't cloned the repo and given tested it on my computer, but looking at it, I think what you're seeing makes sense. The values you're seeing on name input are what I might call "controlled inputs" (to use a React term):
<input type="text" id={f[:name].id} name={f[:name].name} value={f[:name].value} class="input" />
So the value is going to be whatever is in the f[:name].value. If you don't have a phx-change, after you submit the form, the value for that name will be whatever you have in your to_form(changeset).
As a side note: I know it's been a little while. Are you still dealing with this issue?
Uhmm, so it means that when I call fill_in(form, "Name", with: "John"), it will never alone change the input value in a way that changes the form payload? I'm wrong to have this expectation?
Are you still dealing with this issue?
No, not at the moment, since it's not that common to have a form without validation for us. Thanks for getting back to this to ask.