Failing tests with '** (ArgumentError) could not find non-disabled input' when a field is not used in LiveView

I’m new to LiveView and also the automatically generated tests. My tests are failing for what I’m sure is a simple reason, I just don’t know where to look, and can’t find an answer in this forum.

I am creating entities which—for audit trail/history-keeping reasons—must not allow deletion. Instead, my entities each have an ‘is_active’ boolean field in them; when they are no longer needed, they can be deactivated, (by turning the is_active field to false).

Therefore, I don’t actually want the is_active field displayed in the new and edit forms, removing it from the form_component.ex file.

As soon as I do that, the automated tests produce three (identical) failures, all complaining that the field cannot be found:

** (ArgumentError) could not find non-disabled input, select or textarea with name "continent[is_active]" within:

I’ve looked in the fixture, and in the relevant _web tests, in the _live_test.ex file. Admittedly, I do not understand ExUnit, nor Phoenix.LiveViewTest very well yet, and cannot work out where this field is defined as expected, and how to disable the automated tests expecting it.

Any pointers from those who have come across this and have fixed it would be appreciated, as well as good resources instructing on best (pragmatic) use of this testing framework would be an enormous help.

Environment and reproducing

I’m running Elixir 1.14.3, Phoenix 1.7.2, Phoenix LiveView 0.18.16, and have been able to reproduce the above with a fresh Phoenix instance, creating a single entity, continents using Phoenix’ automatic generation:

mix Resources Continent continents continent_code:string name:string is_active:boolean

I can confirm that all automatically generated tests pass, right up until I remove the following line from the live/continent_live/form_component.ex file:

<.input field={@form[:is_active]}... />

This imediately results in three failed tests with the ** (ArgumentError) could not find non-disabled input... error.

The form/3 test helper here will raise the error you’re seeing if one of the fields it is given isn’t on the screen.

You’ll want to make sure the various attribute lists (@create_attrs etc) in that generated test file don’t have is_active in them.

You’re absolutely right @al2o3cr! In my original project, that’s exactly what I thought it was, and had removed the field from all the @create_attrs constants, which merely led to a deeper reason for the test failure.

In this fresh project, however, this fixed the problem and all tests pass now.

Thank you very much for your help!