diff --git a/mix.lock b/mix.lock index cc71ce93..221bc4e1 100644 --- a/mix.lock +++ b/mix.lock @@ -35,7 +35,7 @@ "parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm", "639b2e8749e11b87b9eb42f2ad325d161c170b39b288ac8d04c4f31f8f0823eb"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, "phoenix": {:hex, :phoenix, "1.5.4", "0fca9ce7e960f9498d6315e41fcd0c80bfa6fbeb5fa3255b830c67fdfb7e703f", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4e516d131fde87b568abd62e1b14aa07ba7d5edfd230bab4e25cc9dedbb39135"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "4.1.0", "a044d0756d0464c5a541b4a0bf4bcaf89bffcaf92468862408290682c73ae50d", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "c5e666a341ff104d0399d8f0e4ff094559b2fde13a5985d4cb5023b2c2ac558b"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "4.2.0", "4ac3300a22240a37ed54dfe6c0be1b5623304385d1a2c210a70f011d9e7af7ac", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 2.15", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "59e7e2a550d7ea082a665c0fc29485f06f55d1a51dd02f513aafdb9d16fc72c4"}, "phoenix_html": {:hex, :phoenix_html, "2.14.2", "b8a3899a72050f3f48a36430da507dd99caf0ac2d06c77529b1646964f3d563e", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "58061c8dfd25da5df1ea0ca47c972f161beb6c875cd293917045b92ffe1bf617"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.4", "940c0344b1d66a2e46eef02af3a70e0c5bb45a4db0bf47917add271b76cd3914", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "38f9308357dea4cc77f247e216da99fcb0224e05ada1469167520bed4cb8cccd"}, "phoenix_live_view": {:hex, :phoenix_live_view, "0.14.4", "7286a96287cd29b594ce4a7314249cea7311af04a06c0fa3e50932e188e73996", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.3", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 0.5", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc4f8cf205c784eeccee35de8afbfeb995ce5511ac4839db63d6d67a5ba091d1"}, diff --git a/test/teslamate_web/live/charge_cost_live_test.exs b/test/teslamate_web/live/charge_cost_live_test.exs index 820a2139..4eecb51d 100644 --- a/test/teslamate_web/live/charge_cost_live_test.exs +++ b/test/teslamate_web/live/charge_cost_live_test.exs @@ -195,24 +195,23 @@ defmodule TeslaMateWeb.ChargeLive.CostTest do assert [] = html |> Floki.parse_document!() - |> Floki.find("#charging_process_cost") + |> Floki.find("##{id}_cost") |> Floki.attribute("value") html = render_submit(view, :save, %{charging_process: %{cost: 42.12}}) |> Floki.parse_document!() - assert "Total" = - html |> Floki.find("#charging_process_mode option[selected]") |> Floki.text() + assert "Total" = html |> Floki.find("##{id}_mode option[selected]") |> Floki.text() - assert ["42.12"] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert ["42.12"] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert %ChargingProcess{cost: decimal("42.12")} = Repo.get(ChargingProcess, id) html = render_submit(view, :save, %{charging_process: %{cost: nil}}) |> Floki.parse_document!() - assert [] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert [] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert nil == Repo.get(ChargingProcess, id).cost end @@ -229,24 +228,23 @@ defmodule TeslaMateWeb.ChargeLive.CostTest do assert [] = html |> Floki.parse_document!() - |> Floki.find("#charging_process_cost") + |> Floki.find("##{id}_cost") |> Floki.attribute("value") html = render_submit(view, :save, %{charging_process: %{cost: 0.12, mode: "per_kwh"}}) |> Floki.parse_document!() - assert "Total" = - html |> Floki.find("#charging_process_mode option[selected]") |> Floki.text() + assert "Total" = html |> Floki.find("##{id}_mode option[selected]") |> Floki.text() - assert ["1.20"] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert ["1.20"] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert %ChargingProcess{cost: decimal("1.20")} = Repo.get(ChargingProcess, id) html = render_submit(view, :save, %{charging_process: %{cost: nil}}) |> Floki.parse_document!() - assert [] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert [] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert nil == Repo.get(ChargingProcess, id).cost end @@ -263,24 +261,23 @@ defmodule TeslaMateWeb.ChargeLive.CostTest do assert [] = html |> Floki.parse_document!() - |> Floki.find("#charging_process_cost") + |> Floki.find("##{id}_cost") |> Floki.attribute("value") html = render_submit(view, :save, %{charging_process: %{cost: -0.029, mode: "per_kwh"}}) |> Floki.parse_document!() - assert "Total" = - html |> Floki.find("#charging_process_mode option[selected]") |> Floki.text() + assert "Total" = html |> Floki.find("##{id}_mode option[selected]") |> Floki.text() - assert ["-0.29"] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert ["-0.29"] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert %ChargingProcess{cost: decimal("-0.29")} = Repo.get(ChargingProcess, id) html = render_submit(view, :save, %{charging_process: %{cost: nil}}) |> Floki.parse_document!() - assert [] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert [] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert nil == Repo.get(ChargingProcess, id).cost end @@ -298,17 +295,16 @@ defmodule TeslaMateWeb.ChargeLive.CostTest do assert [] = html |> Floki.parse_document!() - |> Floki.find("#charging_process_cost") + |> Floki.find("##{id}_cost") |> Floki.attribute("value") html = render_submit(view, :save, %{charging_process: %{cost: 0.10, mode: "per_minute"}}) |> Floki.parse_document!() - assert "Total" = - html |> Floki.find("#charging_process_mode option[selected]") |> Floki.text() + assert "Total" = html |> Floki.find("##{id}_mode option[selected]") |> Floki.text() - assert ["1.50"] = html |> Floki.find("#charging_process_cost") |> Floki.attribute("value") + assert ["1.50"] = html |> Floki.find("##{id}_cost") |> Floki.attribute("value") assert %ChargingProcess{cost: decimal("1.50")} = Repo.get(ChargingProcess, id) end end diff --git a/test/teslamate_web/live/geofence_live_test.exs b/test/teslamate_web/live/geofence_live_test.exs index 5e1e7979..b3cf3098 100644 --- a/test/teslamate_web/live/geofence_live_test.exs +++ b/test/teslamate_web/live/geofence_live_test.exs @@ -113,40 +113,40 @@ defmodule TeslaMateWeb.GeoFenceLiveTest do assert {:ok, view, html} = live(conn, "/geo-fences/#{id}/edit") html = Floki.parse_document!(html) - name = Floki.find(html, "#geo_fence_name") + name = Floki.find(html, "##{id}_name") assert ["Post office"] = Floki.attribute(name, "value") - latitude = Floki.find(html, "#geo_fence_latitude") + latitude = Floki.find(html, "##{id}_latitude") assert ["-25.066188"] = Floki.attribute(latitude, "value") - longitude = Floki.find(html, "#geo_fence_longitude") + longitude = Floki.find(html, "##{id}_longitude") assert ["-130.100502"] = Floki.attribute(longitude, "value") - radius = Floki.find(html, "#geo_fence_radius") + radius = Floki.find(html, "##{id}_radius") assert ["100"] = Floki.attribute(radius, "value") - radius = Floki.find(html, "#geo_fence_cost_per_unit") + radius = Floki.find(html, "##{id}_cost_per_unit") assert ["0.2599"] = Floki.attribute(radius, "value") - radius = Floki.find(html, "#geo_fence_session_fee") + radius = Floki.find(html, "##{id}_session_fee") assert ["5.49"] = Floki.attribute(radius, "value") html = render_submit(view, :save, %{geo_fence: %{name: "", radius: ""}}) |> Floki.parse_document!() - assert [""] = html |> Floki.find("#geo_fence_name") |> Floki.attribute("value") + assert [""] = html |> Floki.find("##{id}_name") |> Floki.attribute("value") - for id <- ["name", "radius"] do + for kind <- ["name", "radius"] do error_html = html |> Floki.find(".field-body .field") - |> Enum.filter(fn field -> Floki.find(field, "#geo_fence_#{id}") |> length() == 1 end) + |> Enum.filter(fn field -> Floki.find(field, "##{id}_#{kind}") |> length() == 1 end) |> Floki.find("span") |> Floki.raw_html(encode: false) assert error_html == - "can't be blank" + "can't be blank" end end @@ -157,16 +157,16 @@ defmodule TeslaMateWeb.GeoFenceLiveTest do assert {:ok, view, html} = live(conn, "/geo-fences/#{id}/edit") html = Floki.parse_document!(html) - name = Floki.find(html, "#geo_fence_name") + name = Floki.find(html, "##{id}_name") assert ["Post office"] = Floki.attribute(name, "value") - latitude = Floki.find(html, "#geo_fence_latitude") + latitude = Floki.find(html, "##{id}_latitude") assert ["-25.066188"] = Floki.attribute(latitude, "value") - longitude = Floki.find(html, "#geo_fence_longitude") + longitude = Floki.find(html, "##{id}_longitude") assert ["-130.100502"] = Floki.attribute(longitude, "value") - radius = Floki.find(html, "#geo_fence_radius") + radius = Floki.find(html, "##{id}_radius") assert ["100"] = Floki.attribute(radius, "value") render_submit(view, :save, %{ @@ -522,8 +522,8 @@ defmodule TeslaMateWeb.GeoFenceLiveTest do h = Floki.parse_document!(h) assert [] == Floki.find(h, ".modal.is-active") - assert ["47.814441"] = h |> Floki.find("#geo_fence_latitude") |> Floki.attribute("value") - assert ["12.367768"] = h |> Floki.find("#geo_fence_longitude") |> Floki.attribute("value") + assert ["47.814441"] = h |> Floki.find("##{id}_latitude") |> Floki.attribute("value") + assert ["12.367768"] = h |> Floki.find("##{id}_longitude") |> Floki.attribute("value") html = render_submit(view, :save, %{geo_fence: %{latitude: 47.814451, longitude: 12.367761}}) @@ -560,8 +560,8 @@ defmodule TeslaMateWeb.GeoFenceLiveTest do h = Floki.parse_document!(h) assert [] == Floki.find(h, ".modal.is-active") - assert ["47.814441"] = h |> Floki.find("#geo_fence_latitude") |> Floki.attribute("value") - assert ["12.367768"] = h |> Floki.find("#geo_fence_longitude") |> Floki.attribute("value") + assert ["47.814441"] = h |> Floki.find("##{id}_latitude") |> Floki.attribute("value") + assert ["12.367768"] = h |> Floki.find("##{id}_longitude") |> Floki.attribute("value") html = render_submit(view, :save, %{geo_fence: %{radius: 50}})