Skip to content
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

Fix Phoenix.LiveViewTest.file_input/4 ignoring last_modified option #3254

Merged

Conversation

ggcampinho
Copy link
Contributor

@ggcampinho ggcampinho commented May 17, 2024

Phoenix.LiveViewTest.file_input/4 is ignoring the option last_modified, so it's impossible to populate entry.client_last_modified with this test function as the documentation says.

Before

[test/phoenix_live_view/upload/external_test.exs:233: Phoenix.LiveView.UploadExternalTest."test consume_uploaded_entries"/1]
file_input(lv, "form", :avatar, [
  %{name: "foo.jpeg", content: String.duplicate("ok", 100), last_modified: 1_594_171_879_000}
]) #=> #Phoenix.LiveViewTest.Upload<
  selector: nil,
  entries: [
    %{
      "content" => "okokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokok",
      "name" => "foo.jpeg",
      "ref" => "9417",
      "relative_path" => nil,
      "size" => 200,
      "type" => "image/jpeg"
    }
  ],
  ...
>

[test/phoenix_live_view/upload/external_test.exs:239: Phoenix.LiveView.UploadExternalTest."test consume_uploaded_entries"/1]
entry #=> %Phoenix.LiveView.UploadEntry{
  progress: 100,
  preflighted?: true,
  upload_config: :avatar,
  upload_ref: "phx-F9CfhwGDfrW4fgdD",
  ref: "1924",
  uuid: "d3bd3c54-cb47-4e41-a40a-6b4ecbf9e294",
  valid?: true,
  done?: true,
  cancelled?: false,
  client_name: "foo.jpeg",
  client_relative_path: nil,
  client_size: 200,
  client_type: "image/jpeg",
  client_last_modified: nil,
  client_meta: nil
}

After

[test/phoenix_live_view/upload/external_test.exs:233: Phoenix.LiveView.UploadExternalTest."test consume_uploaded_entries"/1]
file_input(lv, "form", :avatar, [
  %{name: "foo.jpeg", content: String.duplicate("ok", 100), last_modified: 1_594_171_879_000}
]) #=> #Phoenix.LiveViewTest.Upload<
  selector: nil,
  entries: [
    %{
      "content" => "okokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokokok",
      "last_modified" => 1594171879000,
      "name" => "foo.jpeg",
      "ref" => "4354",
      "relative_path" => nil,
      "size" => 200,
      "type" => "image/jpeg"
    }
  ],
  ...
>

[test/phoenix_live_view/upload/external_test.exs:239: Phoenix.LiveView.UploadExternalTest."test consume_uploaded_entries"/1]
entry #=> %Phoenix.LiveView.UploadEntry{
  progress: 100,
  preflighted?: true,
  upload_config: :avatar,
  upload_ref: "phx-F9CffrMSpNMdjAdC",
  ref: "1923",
  uuid: "61511cac-9568-4e5d-8bed-ede46331ce4c",
  valid?: true,
  done?: true,
  cancelled?: false,
  client_name: "foo.jpeg",
  client_relative_path: nil,
  client_size: 200,
  client_type: "image/jpeg",
  client_last_modified: 1594171879000,
  client_meta: nil
}

`Phoenix.LiveViewTest.file_input/4` is ignoring the option `last_modified`, so it's impossible to populate `entry.client_last_modified` with this test function as the documentation says.
@josevalim josevalim merged commit e742ca8 into phoenixframework:main May 24, 2024
6 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants