-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't test multiple file upload #3480
Comments
I got the same issue when using (...)
upload_input =
file_input(process, "#upload-form", :images, [
%{
last_modified: 1_594_171_879_000,
name: "valid_file_a.jpg",
content: "dummy file content"
},
%{
last_modified: 1_594_171_879_000,
name: "valid_file_b.jpg",
content: "dummy file content"
}
])
render_upload(upload_input, "valid_file_a.jpg")
IO.inspect("First upload")
render_upload(upload_input, "valid_file_b.jpg")
IO.inspect("Second upload")
process
|> form("#upload-form", [])
|> render_submit()
(...) My error message:
|
@lessless can you share your full example. Looks like you're using |
Just for completeness sake: My upload is basically lifted from the examples. socket
|> allow_upload(:images,
accept: ~w(.jpg .tif),
max_entries: @max_upload_count,
max_file_size: @max_upload_size
) And another observation: If I remove one of the
|
@chrismccord you're spot on about the
I might have misunderstood the documentation then. I use def mount(_params, _session, socket) do
{:ok,
socket
|> allow_upload(:documents, accept: ~w(.pdf .tif .tiff), max_entries: 100, auto_upload: true, progress: &handle_progress/3)}
end defp handle_progress(:documents, %{done?: true}, socket) do
case uploaded_entries(socket, :documents) do
{[_ | _] = _completed, []} ->
consume_uploaded_entries(socket, :documents, fn %{path: path}, entry ->
case upload_file(entry, path, socket.assigns.current_practice) do
{:ok, _} ->
Toaster.toast(socket.id, :info, "#{entry.client_name} successfully uploaded")
{:error, _} ->
Toaster.toast(socket.id, :error, "Failed to upload #{entry.client_name}")
end
{:ok, entry}
end)
{:noreply, socket}
_in_progress ->
{:noreply, socket}
end
end
defp handle_progress(:documents, %{done?: false}, socket) do
{:noreply, socket}
end |
Environment
Actual behavior
The second
render_upload
raises an error when I try to test multiple files uploadthe "after second render_uploa" is never printed the test fails with the error
Expected behavior
I can test multiple file upload
UPDATE:
what seems to happen is that
render_tree
tries to communicate with exited LV processhttps://github.com/phoenixframework/phoenix_live_view/blob/main/lib/phoenix_live_view/test/live_view_test.ex#L1091
as
UploadClient.chunk(upload, entry_name, percent, proxy_pid(upload.view))
(https://github.com/phoenixframework/phoenix_live_view/blob/main/lib/phoenix_live_view/test/live_view_test.ex#L1972C12-L1972C84) returns{:ok, :closed}
during the secondrender_submit
The text was updated successfully, but these errors were encountered: