I have a multipart form that is sending data with a file attached
<Field name="upload" class="mt-6" > <Label class="label">Upload File APK</Label> {{ live_file_input @uploads.file }} </Field>
but when I test it returns the following error ** (RuntimeError) no uploads allowed for file
but on update I have allowed for the file as shown below
`def update(%{book: book } = assigns, socket) do
changeset = Apks.change_book(book)
user = assigns.user
title =
case assigns.action do
:new -> "Add Book"
:edit -> "Edit Book"
end
{:ok,
socket
|> assign(assigns)
|> assign(:changeset, changeset)
|>assign(:user, user)
|> assign(:title, title)
|> allow_upload(:file,
accept: ~w(.txt),
max_entries: 1,
max_file_size: 5_000_000_000,
auto_upload: true
)
}
end`
This is my failing test
test “the Add book form is submitted successfully”, %{conn: conn, user: user} do
conn = Plug.Test.init_test_session(conn, %{current_user: user, user_uuid: user.uuid})
{:ok, view, html}= live(conn, “/admin/book/new”)
file =
view
|>file_input("#my_form_containing_book",:file, [%{
name: "39e09448-305b-4d52-9a0f-a04f04c2602c.txt",
content: File.read!("/workspace/assets/testfiles/39e09448-305b-4d52-9a0f-a04f04c2602c.txt"),
type: "text/plain"
}])
|>form("#my_form_containing_book", post: %{"title"=> "test", "package_name"=> "test", "category_id" => "2"})
|>render_submit()
assert render_upload(file, "39e09448-305b-4d52-9a0f-a04f04c2602c.txt") =~ "100%"
end`
Not sure where the problem is?
`