So, I have a phx 1.5 live edit for that was generated via mix phx.gen.live
, and I added a belongs_to association to. I edited the form to have a reference to that relation, but I keep getting errors when mix test tries to fill out the form:
<% inputs_for f, :room_type, fn it -> %>
<%= label it, :id, "Room Type", class: "block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"%>
<%= select it, :id, Enum.map(@room_types, &{&1.description, &1.id}), class: "appearance-none block w-full bg-gray-200 text-gray-700 border rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white"%>
<%= error_tag it, :id, class: "text-red-500 text-xs italic pt-3" %>
<% end %>
Section of test code:
@room_type %{id: 1, name: "some name", description: "some room type"}
@valid_attrs %{description: "some description", room_type: @room_type, name: "some name", owner: "some owner"}
...
{:ok, _, html} =
index_live
|> form("#room-form", island: @create_attrs)
|> render_submit()
|> follow_redirect(conn, Routes.room_index_path(conn, :index))
But I’m getting:
** (ArgumentError) could not find non-disabled input, select or textarea with name "room[room_type]" within:
<input name="_csrf_token" type="hidden" value="AjI4EDkKMwB5DzhZBAUhZn9cbDlyMixXakkAmRBKTHO5hwE660ZjJwy3"/>
<input class="" id="room_name" name="room[name]" type="text"/>
<input class="" id="room_owner" name="room[owner]" type="text"/>
<textarea class="" id="room_description" name="room[description]">
</textarea>
<select class="" id="room_room_type_id" name="room[room_type][id]"><option value="1">some room type</option><option value="2">some other room type</option></select>
Does anyone have any ideas on how I can test this properly?