From b76e8a8f36f43143692398c611a09000825d08e5 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 11:48:36 -0400 Subject: [PATCH 1/9] Test VIN row --- lib/teslamate_web/live/car_live/summary.html.heex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index c00b35aea3..cc664e96d9 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -432,6 +432,12 @@ <% end %> + <%= unless is_nil(@car.vin) do %> + + <%= gettext("VIN") %> + <%= @car.vin %> + + <% end %> <%= cond do @@ -469,4 +475,4 @@ end %> - + \ No newline at end of file From 63191c8ddda2e3324deae97139fad3e0e18540ea Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 11:58:35 -0400 Subject: [PATCH 2/9] VIN as Tooltip (+ Clipboard) --- .../live/car_live/summary.html.heex | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index cc664e96d9..a326c4458c 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -26,7 +26,16 @@
-

<%= @summary.display_name %>

+

+ + <%= @summary.display_name %> + +

<%= unless is_nil(@car.model) do %>

Model <%= @car.model %> @@ -432,12 +441,6 @@ <% end %> - <%= unless is_nil(@car.vin) do %> - - <%= gettext("VIN") %> - <%= @car.vin %> - - <% end %> <%= cond do From bfdf39f5697a482aac748312daa5ae1a2d344e4a Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 12:00:30 -0400 Subject: [PATCH 3/9] Syntax fix --- lib/teslamate_web/live/car_live/summary.html.heex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index a326c4458c..668068021c 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -29,9 +29,9 @@

<%= @summary.display_name %> From 7b9690ad96a9ed322d2431ad482d3a5ec0c25303 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 12:04:36 -0400 Subject: [PATCH 4/9] Fix Syntax, attempt 2 --- lib/teslamate_web/live/car_live/summary.html.heex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index 668068021c..dd8b2a892c 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -29,7 +29,7 @@

From 741c8bf619f6f923d14fa5d89d971e9eeafc0bc8 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 12:21:17 -0400 Subject: [PATCH 5/9] Use Phoenix for Clipboard --- lib/teslamate_web/live/car_live/summary.html.heex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index dd8b2a892c..e3ee6c236f 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -29,7 +29,7 @@

From 2efa35d1762fcc56d6bb2a51a56e412222d35135 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Thu, 31 Jul 2025 12:28:46 -0400 Subject: [PATCH 6/9] remove clipboard for now --- lib/teslamate_web/live/car_live/summary.html.heex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index e3ee6c236f..7621f607d6 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -27,10 +27,9 @@

- <%= @summary.display_name %> From 9f97b51f7a177372cd14fb3734ab45d695f2a1a4 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Tue, 26 Aug 2025 13:22:40 -0400 Subject: [PATCH 7/9] Fix Formatting --- lib/teslamate_web/live/car_live/summary.html.heex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex index 7621f607d6..d80fe18fe4 100644 --- a/lib/teslamate_web/live/car_live/summary.html.heex +++ b/lib/teslamate_web/live/car_live/summary.html.heex @@ -477,4 +477,4 @@ end %>

-
\ No newline at end of file +
From fec79f853793cb59bf18ab846e9a0a7b789d345b Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Tue, 26 Aug 2025 16:37:51 -0400 Subject: [PATCH 8/9] Fix Tests --- .../controllers/car_controller_test.exs | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/test/teslamate_web/controllers/car_controller_test.exs b/test/teslamate_web/controllers/car_controller_test.exs index 5ecc392638..7ac1015e9f 100644 --- a/test/teslamate_web/controllers/car_controller_test.exs +++ b/test/teslamate_web/controllers/car_controller_test.exs @@ -37,6 +37,14 @@ defmodule TeslaMateWeb.CarControllerTest do |> Enum.find(&match?({"span", [_, {"data-tooltip", ^tooltip}], _}, &1)) end + defp assert_car_title(html, name) do + title_eles = Floki.find(html, "p.title.is-5") + + [{"p", _, content}] = title_eles + + assert Floki.text(content) |> String.trim() == name + end + defp car_fixture(settings) do {:ok, car} = Log.create_car(%{ @@ -121,7 +129,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "asleep") assert table_row(html, "Range (rated)", "380.26 km") assert table_row(html, "Range (est.)", "401.52 km") @@ -156,7 +164,6 @@ defmodule TeslaMateWeb.CarControllerTest do |> Floki.parse_document!() |> Floki.find(".car .subtitle") |> Floki.text() - # Trim all whitespace |> String.trim() |> String.replace(~r/(\n)+/, " ") |> String.replace(~r/(\s)+/, " ") @@ -208,7 +215,14 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") + + [{"p", _, [{"span", attrs, _text}]}] = Floki.find(html, "p.title.is-5") + + attrs_map = Map.new(attrs) + assert attrs_map["data-tooltip"] == "xxxxx" + assert attrs_map["class"] == "has-tooltip-right has-tooltip-left-mobile" + assert attrs_map["style"] == "border-bottom: none;" assert "Model S P90D" == html @@ -282,7 +296,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "charging") assert table_row(html, "Remaining Time", "1 h, 49 min") assert icon(html, "Plugged In", "power-plug") @@ -310,6 +324,7 @@ defmodule TeslaMateWeb.CarControllerTest do events = [ {:ok, online_event( + display_name: "FooCar", drive_state: %{timestamp: 0, latitude: 0.0, longitude: 0.0}, charge_state: %{ timestamp: 0, @@ -326,6 +341,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) + assert_car_title(html, "FooCar") assert table_row(html, "Remaining Time", "19 min") end @@ -350,7 +366,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "driving") assert table_row(html, "Speed", "48 km/h") end @@ -376,7 +392,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "updating") end @@ -391,7 +407,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "asleep") end @@ -406,7 +422,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "offline") end @@ -430,7 +446,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "falling asleep") end @@ -446,7 +462,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

<\/p>/ + assert_car_title(html, "") assert table_row(html, "Status", "unavailable") end @@ -480,7 +496,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Range (rated)", "281.64 km") assert table_row(html, "Range (est.)", "289.68 km") end @@ -526,7 +542,7 @@ defmodule TeslaMateWeb.CarControllerTest do conn = get(conn, Routes.car_path(conn, :index)) assert html = response(conn, 200) - assert html =~ ~r/

FooCar<\/p>/ + assert_car_title(html, "FooCar") assert table_row(html, "Status", "driving") assert table_row(html, "Range (rated)", "200.0 mi") assert table_row(html, "Range (est.)", "180.0 mi") From 268ead60b3957b72162593922c6c8e79297597b1 Mon Sep 17 00:00:00 2001 From: Helvio Pedreschi Date: Wed, 27 Aug 2025 13:07:34 -0400 Subject: [PATCH 9/9] Rename "eles" to "elements" --- test/teslamate_web/controllers/car_controller_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/teslamate_web/controllers/car_controller_test.exs b/test/teslamate_web/controllers/car_controller_test.exs index 7ac1015e9f..06ce1dc5bd 100644 --- a/test/teslamate_web/controllers/car_controller_test.exs +++ b/test/teslamate_web/controllers/car_controller_test.exs @@ -38,9 +38,9 @@ defmodule TeslaMateWeb.CarControllerTest do end defp assert_car_title(html, name) do - title_eles = Floki.find(html, "p.title.is-5") + title_elements = Floki.find(html, "p.title.is-5") - [{"p", _, content}] = title_eles + [{"p", _, content}] = title_elements assert Floki.text(content) |> String.trim() == name end