germsvel / phoenix_test

MIT License
146 stars 20 forks source link

Failing test for nested field in liveview #25

Closed totaltrash closed 7 months ago

totaltrash commented 7 months ago

Hi there, thanks for this library, it is sweet as.

I'm seeing the same thing as #17 and have tracked it down to being an issue for LiveView nested form fields. Hopefully this failing test will highlight what's happening

mix test
.........................................................................

  1) test fill_form + click_button nested form (PhoenixTest.LiveTest)
     test/phoenix_test/live_test.exs:171
     ** (ArgumentError) Could not find element with selector "#nested-form [name=user]"
     code: |> fill_form("#nested-form", user: %{email: "some@example.com"})
     stacktrace:
       (phoenix_test 0.2.4) lib/phoenix_test/query.ex:9: PhoenixTest.Query.find!/2
       (elixir 1.16.1) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
       (phoenix_test 0.2.4) lib/phoenix_test/live.ex:120: PhoenixTest.Driver.PhoenixTest.Live.fill_form/3
       test/phoenix_test/live_test.exs:174: (test)

......................
Finished in 0.2 seconds (0.2s async, 0.00s sync)
96 tests, 1 failure
germsvel commented 7 months ago

A failing test 🤩 Thanks @totaltrash! That'll be super helpful in fixing the issue. I'm honestly shocked (and a bit ashamed) to see that that test didn't already exist -- and that it fails. In theory, LiveView should handle that form, but I think I know what's happening now.

germsvel commented 7 months ago

@totaltrash, commit 180dc0dd7e57427304c9cb144ff0f75f5f119faa fixes the issue. I thought there was something more going on with the failing test, so I didn't tag that as closing this or fixing #17. But it turns out, after that commit, the test was only failing because of a test LiveView implementation when rendering the form fields that were submitted.

In any case, I didn't know if GitHub allowed me to push to your branch. So instead, I opened #26 to capture the test changes you introduced here.

Thanks again for the failing test!