From cba66f5368ebdbb4bd2d222c2a0cbc451afc3703 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Thu, 7 Nov 2024 16:55:07 -0600 Subject: [PATCH 01/12] run query params through an anti corruption layer --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 46 +++++++++++++++++++ .../live_components/trip_planner_form.ex | 20 ++++++-- lib/dotcom_web/live/trip_planner.ex | 5 +- 3 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 lib/dotcom/trip_plan/anti_corruption_layer.ex diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex new file mode 100644 index 0000000000..23752e0a2c --- /dev/null +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -0,0 +1,46 @@ +defmodule Dotcom.TripPlan.AntiCorruptionLayer do + @moduledoc false + + def convert(%{"plan" => params}) do + %{ + "datetime" => Map.get(params, "date_time") |> convert_datetime(), + "datetime_type" => Map.get(params, "time", "now"), + "from" => %{ + "latitude" => Map.get(params, "from_latitude"), + "longitude" => Map.get(params, "from_longitude"), + "name" => Map.get(params, "from"), + "stop_id" => Map.get(params, "from_stop_id", "") + }, + "modes" => Map.get(params, "modes") |> convert_modes(), + "to" => %{ + "latitude" => Map.get(params, "to_latitude"), + "longitude" => Map.get(params, "to_longitude"), + "name" => Map.get(params, "to"), + "stop_id" => Map.get(params, "to_stop_id", "") + }, + "wheelchair" => Map.get(params, "wheelchair") || "false" + } + end + + def convert(_), do: convert(%{"plan" => %{}}) + + defp convert_datetime(datetime) when is_binary(datetime) do + case Timex.parse(datetime, "%Y-%m-%d %H:%M %p", :strftime) do + {:ok, naivedatetime} -> naivedatetime |> Timex.to_datetime("America/New_York") + {:error, _} -> Timex.now("America/New_York") + end + end + + defp convert_datetime(_), do: Timex.now("America/New_York") + + defp convert_modes(modes) when is_map(modes) do + default_modes = for {k, _} <- Dotcom.TripPlan.InputForm.initial_modes(), into: %{}, do: {k, "false"} + + modes + |> Enum.reduce(default_modes, fn {key, value}, acc -> + Map.put(acc, String.upcase(key), value) + end) + end + + defp convert_modes(_), do: Dotcom.TripPlan.InputForm.initial_modes() +end diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index adcdf99f98..0cbab5e782 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -13,20 +13,29 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do @impl true def mount(socket) do - form_defaults = %{ + {:ok, socket} + end + + @impl true + def update(assigns, socket) do + form_defaults = Map.get(assigns, :form_values, %{ "datetime_type" => "now", "datetime" => Timex.now("America/New_York"), "modes" => InputForm.initial_modes(), "wheelchair" => true - } + }) defaults = %{ form: %InputForm{} |> InputForm.changeset(form_defaults) |> to_form(), location_keys: InputForm.Location.fields(), show_datepicker: false } + new_socket = + socket + |> assign(assigns) + |> assign(defaults) - {:ok, assign(socket, defaults)} + {:ok, new_socket} end @impl true @@ -40,7 +49,6 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do for={@form} method="get" phx-submit="save_form" - phx-change="handle_change" phx-target={@myself} >
@@ -136,6 +144,10 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do
+
+ <%= inspect(@form[:datetime_type].value) %> + <%= inspect(@form[:datetime].value) %> +
""" end diff --git a/lib/dotcom_web/live/trip_planner.ex b/lib/dotcom_web/live/trip_planner.ex index 98d525610d..e45c4b3c0c 100644 --- a/lib/dotcom_web/live/trip_planner.ex +++ b/lib/dotcom_web/live/trip_planner.ex @@ -18,11 +18,12 @@ defmodule DotcomWeb.Live.TripPlanner do @map_config Application.compile_env!(:mbta_metro, :map) @impl true - def mount(_params, _session, socket) do + def mount(params, _session, socket) do socket = socket |> assign(:error, nil) |> assign(:form_name, @form_id) + |> assign(:form_values, Dotcom.TripPlan.AntiCorruptionLayer.convert(params)) |> assign(:map_config, @map_config) |> assign(:from, []) |> assign(:to, []) @@ -39,7 +40,7 @@ defmodule DotcomWeb.Live.TripPlanner do ~H"""

Trip Planner Preview

- <.live_component module={TripPlannerForm} id={@form_name} form_name={@form_name} /> + <.live_component module={TripPlannerForm} id={@form_name} form_name={@form_name} form_values={@form_values} />

<%= submission_summary(@submitted_values) %>

<%= time_summary(@submitted_values) %>

From c53e928ec448b9778f631cb9b94b6e0bc3830aca Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 11:26:21 -0600 Subject: [PATCH 02/12] dont account for time selections --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 11 ---------- .../live_components/trip_planner_form.ex | 20 +++++++++---------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index 23752e0a2c..748ff90546 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -3,8 +3,6 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do def convert(%{"plan" => params}) do %{ - "datetime" => Map.get(params, "date_time") |> convert_datetime(), - "datetime_type" => Map.get(params, "time", "now"), "from" => %{ "latitude" => Map.get(params, "from_latitude"), "longitude" => Map.get(params, "from_longitude"), @@ -24,15 +22,6 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do def convert(_), do: convert(%{"plan" => %{}}) - defp convert_datetime(datetime) when is_binary(datetime) do - case Timex.parse(datetime, "%Y-%m-%d %H:%M %p", :strftime) do - {:ok, naivedatetime} -> naivedatetime |> Timex.to_datetime("America/New_York") - {:error, _} -> Timex.now("America/New_York") - end - end - - defp convert_datetime(_), do: Timex.now("America/New_York") - defp convert_modes(modes) when is_map(modes) do default_modes = for {k, _} <- Dotcom.TripPlan.InputForm.initial_modes(), into: %{}, do: {k, "false"} diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index 0cbab5e782..4910860ad2 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -18,12 +18,16 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do @impl true def update(assigns, socket) do - form_defaults = Map.get(assigns, :form_values, %{ - "datetime_type" => "now", - "datetime" => Timex.now("America/New_York"), - "modes" => InputForm.initial_modes(), - "wheelchair" => true - }) + form_defaults = + assigns + |> Map.get(:form_values, %{ + "modes" => InputForm.initial_modes(), + "wheelchair" => true + }) + |> Map.merge(%{ + "datetime_type" => "now", + "datetime" => Timex.now("America/New_York"), + }) defaults = %{ form: %InputForm{} |> InputForm.changeset(form_defaults) |> to_form(), @@ -144,10 +148,6 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do
-
- <%= inspect(@form[:datetime_type].value) %> - <%= inspect(@form[:datetime].value) %> -
""" end From 425cd7e1b2af28632555a5cfb9194a54a613ce95 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 11:34:04 -0600 Subject: [PATCH 03/12] add handle change back in --- lib/dotcom_web/components/live_components/trip_planner_form.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index 4910860ad2..d2e1aca1e2 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -53,6 +53,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do for={@form} method="get" phx-submit="save_form" + phx-change="handle_change" phx-target={@myself} >
From 2e77d2c9c4db8e679930eadff0a89eb77d24251b Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 11:38:42 -0600 Subject: [PATCH 04/12] docs --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index 748ff90546..097e7ca688 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -1,5 +1,12 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do - @moduledoc false + @moduledoc """ + This anti-corruption layer is responsible for converting the data from the old trip planner query params to the new trip planner form values. + + Currently, not all modes are sent. So, we default to setting them to 'false' if they aren't set. + Likewise with wheelchair, we default to 'false' if it isn't set because the old trip planner worked by just not setting it rather than setting it to 'false'. + + We ignore datetime_type and datetime and allow those to be set to 'now' and the current time respectively. + """ def convert(%{"plan" => params}) do %{ From b54a2a608a35b23978530b3fb7a35acf75d0cc56 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 11:38:55 -0600 Subject: [PATCH 05/12] mix format --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 3 ++- .../components/live_components/trip_planner_form.ex | 3 ++- lib/dotcom_web/live/trip_planner.ex | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index 097e7ca688..bfc25d4362 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -30,7 +30,8 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do def convert(_), do: convert(%{"plan" => %{}}) defp convert_modes(modes) when is_map(modes) do - default_modes = for {k, _} <- Dotcom.TripPlan.InputForm.initial_modes(), into: %{}, do: {k, "false"} + default_modes = + for {k, _} <- Dotcom.TripPlan.InputForm.initial_modes(), into: %{}, do: {k, "false"} modes |> Enum.reduce(default_modes, fn {key, value}, acc -> diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index d2e1aca1e2..91c55d340d 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -26,7 +26,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do }) |> Map.merge(%{ "datetime_type" => "now", - "datetime" => Timex.now("America/New_York"), + "datetime" => Timex.now("America/New_York") }) defaults = %{ @@ -34,6 +34,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do location_keys: InputForm.Location.fields(), show_datepicker: false } + new_socket = socket |> assign(assigns) diff --git a/lib/dotcom_web/live/trip_planner.ex b/lib/dotcom_web/live/trip_planner.ex index e45c4b3c0c..01960c5876 100644 --- a/lib/dotcom_web/live/trip_planner.ex +++ b/lib/dotcom_web/live/trip_planner.ex @@ -40,7 +40,12 @@ defmodule DotcomWeb.Live.TripPlanner do ~H"""

Trip Planner Preview

- <.live_component module={TripPlannerForm} id={@form_name} form_name={@form_name} form_values={@form_values} /> + <.live_component + module={TripPlannerForm} + id={@form_name} + form_name={@form_name} + form_values={@form_values} + />

<%= submission_summary(@submitted_values) %>

<%= time_summary(@submitted_values) %>

From 6c5307b542e30decb64333b05c58894c59b12596 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 11:40:19 -0600 Subject: [PATCH 06/12] function doc --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index bfc25d4362..a0290f12bc 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -8,6 +8,11 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do We ignore datetime_type and datetime and allow those to be set to 'now' and the current time respectively. """ + @doc""" + Given the params from the old trip planner, convert them to the new trip planner form values. + + If no plan is given, then we default to empty form values. + """ def convert(%{"plan" => params}) do %{ "from" => %{ From 8124d3952977254016af14e2ac6fee4c9bf4f7d0 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 12:06:03 -0600 Subject: [PATCH 07/12] format --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index a0290f12bc..efdb023b76 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -8,7 +8,7 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do We ignore datetime_type and datetime and allow those to be set to 'now' and the current time respectively. """ - @doc""" + @doc """ Given the params from the old trip planner, convert them to the new trip planner form values. If no plan is given, then we default to empty form values. From f6314fd8429688a3f76cdae96e9e1c0e913866d9 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 8 Nov 2024 12:08:59 -0600 Subject: [PATCH 08/12] alias --- lib/dotcom_web/live/trip_planner.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/dotcom_web/live/trip_planner.ex b/lib/dotcom_web/live/trip_planner.ex index 01960c5876..71e2c99f88 100644 --- a/lib/dotcom_web/live/trip_planner.ex +++ b/lib/dotcom_web/live/trip_planner.ex @@ -7,12 +7,12 @@ defmodule DotcomWeb.Live.TripPlanner do use DotcomWeb, :live_view - alias DotcomWeb.Components.LiveComponents.TripPlannerForm - alias Dotcom.TripPlan.{InputForm.Modes, ItineraryGroups} - import DotcomWeb.Components.TripPlanner.ItineraryGroup, only: [itinerary_group: 1] import MbtaMetro.Components.{Feedback, Spinner} + alias DotcomWeb.Components.LiveComponents.TripPlannerForm + alias Dotcom.TripPlan.{AntiCorruptionLayer, InputForm.Modes, ItineraryGroups} + @form_id "trip-planner-form" @map_config Application.compile_env!(:mbta_metro, :map) @@ -23,7 +23,7 @@ defmodule DotcomWeb.Live.TripPlanner do socket |> assign(:error, nil) |> assign(:form_name, @form_id) - |> assign(:form_values, Dotcom.TripPlan.AntiCorruptionLayer.convert(params)) + |> assign(:form_values, AntiCorruptionLayer.convert(params)) |> assign(:map_config, @map_config) |> assign(:from, []) |> assign(:to, []) From 59eb2c2895399b4a4a0f92b037ac350c199c05c7 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Tue, 12 Nov 2024 09:54:16 -0600 Subject: [PATCH 09/12] submit the form if form values are present --- .../live_components/trip_planner_form.ex | 68 ++++++++++++------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index 91c55d340d..a02ef1b97b 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -17,17 +17,13 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do end @impl true + @doc """ + If form values are passed in, we merge them with the defaults and submit the form. + + Otherwise, we just render the form. + """ def update(assigns, socket) do - form_defaults = - assigns - |> Map.get(:form_values, %{ - "modes" => InputForm.initial_modes(), - "wheelchair" => true - }) - |> Map.merge(%{ - "datetime_type" => "now", - "datetime" => Timex.now("America/New_York") - }) + form_defaults = get_form_defaults(assigns) defaults = %{ form: %InputForm{} |> InputForm.changeset(form_defaults) |> to_form(), @@ -40,6 +36,10 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do |> assign(assigns) |> assign(defaults) + if assigns[:form_values] do + save_form(form_defaults, new_socket) + end + {:ok, new_socket} end @@ -191,22 +191,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do end def handle_event("save_form", %{"input_form" => params}, socket) do - params - |> InputForm.validate_params() - |> Ecto.Changeset.apply_action(:update) - |> case do - {:ok, data} -> - send(self(), {:updated_form, data}) - - {:noreply, socket} - - {:error, changeset} -> - form = - changeset - |> Phoenix.Component.to_form() - - {:noreply, assign(socket, %{form: form})} - end + {:noreply, save_form(params, socket)} end defp datepicker_config do @@ -218,6 +203,18 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do } end + defp get_form_defaults(assigns) do + assigns + |> Map.get(:form_values, %{ + "modes" => InputForm.initial_modes(), + "wheelchair" => true + }) + |> Map.merge(%{ + "datetime_type" => "now", + "datetime" => Timex.now("America/New_York") + }) + end + defp nearest_5_minutes do datetime = Timex.now("America/New_York") minutes = datetime.minute @@ -226,4 +223,23 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do Timex.shift(datetime, minutes: added_minutes) end + + defp save_form(params, socket) do + params + |> InputForm.validate_params() + |> Ecto.Changeset.apply_action(:update) + |> case do + {:ok, data} -> + send(self(), {:updated_form, data}) + + socket + + {:error, changeset} -> + form = + changeset + |> Phoenix.Component.to_form() + + assign(socket, %{form: form}) + end + end end From cef97f1c182f9ede560ec6f5319bb9f382bccf78 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Wed, 13 Nov 2024 09:43:22 -0600 Subject: [PATCH 10/12] rename function and add tests --- lib/dotcom/trip_plan/anti_corruption_layer.ex | 4 +- lib/dotcom_web/live/trip_planner.ex | 2 +- .../trip_plan/anti_corruption_layer_test.exs | 49 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 test/dotcom/trip_plan/anti_corruption_layer_test.exs diff --git a/lib/dotcom/trip_plan/anti_corruption_layer.ex b/lib/dotcom/trip_plan/anti_corruption_layer.ex index efdb023b76..24fa84ebdc 100644 --- a/lib/dotcom/trip_plan/anti_corruption_layer.ex +++ b/lib/dotcom/trip_plan/anti_corruption_layer.ex @@ -13,7 +13,7 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do If no plan is given, then we default to empty form values. """ - def convert(%{"plan" => params}) do + def convert_old_params(%{"plan" => params}) do %{ "from" => %{ "latitude" => Map.get(params, "from_latitude"), @@ -32,7 +32,7 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayer do } end - def convert(_), do: convert(%{"plan" => %{}}) + def convert_old_params(_), do: convert_old_params(%{"plan" => %{}}) defp convert_modes(modes) when is_map(modes) do default_modes = diff --git a/lib/dotcom_web/live/trip_planner.ex b/lib/dotcom_web/live/trip_planner.ex index 71e2c99f88..3fbf53abcd 100644 --- a/lib/dotcom_web/live/trip_planner.ex +++ b/lib/dotcom_web/live/trip_planner.ex @@ -23,7 +23,7 @@ defmodule DotcomWeb.Live.TripPlanner do socket |> assign(:error, nil) |> assign(:form_name, @form_id) - |> assign(:form_values, AntiCorruptionLayer.convert(params)) + |> assign(:form_values, AntiCorruptionLayer.convert_old_params(params)) |> assign(:map_config, @map_config) |> assign(:from, []) |> assign(:to, []) diff --git a/test/dotcom/trip_plan/anti_corruption_layer_test.exs b/test/dotcom/trip_plan/anti_corruption_layer_test.exs new file mode 100644 index 0000000000..bf89278bb6 --- /dev/null +++ b/test/dotcom/trip_plan/anti_corruption_layer_test.exs @@ -0,0 +1,49 @@ +defmodule Dotcom.TripPlan.AntiCorruptionLayerTest do + use ExUnit.Case + + import Dotcom.TripPlan.AntiCorruptionLayer, only: [convert_old_params: 1] + + describe "convert_old_params/1" do + test "returns all defaults when no params are given" do + assert convert_old_params(%{}) == convert_old_params(%{"plan" => %{}}) + end + + test "sets all modes to true when no modes are given" do + old_params = %{ + "plan" => %{} + } + + new_params = convert_old_params(old_params) + + assert new_params["modes"] == Dotcom.TripPlan.InputForm.initial_modes() + end + + test "sets given modes as given and all non-given as false" do + old_params = %{ + "plan" => %{ + "modes" => %{ + "bus" => "true", + "subway" => "true" + } + } + } + + new_params = convert_old_params(old_params) + + assert new_params["modes"]["BUS"] == "true" + assert new_params["modes"]["SUBWAY"] == "true" + assert new_params["modes"]["FERRY"] == "false" + assert new_params["modes"]["RAIL"] == "false" + end + + test "defaults to wheelchair false when no wheelchair is given" do + old_params = %{ + "plan" => %{} + } + + new_params = convert_old_params(old_params) + + assert "false" == new_params["wheelchair"] + end + end +end From a00fca97eea3e1cbd531241caacd52267f29347a Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Wed, 13 Nov 2024 09:45:30 -0600 Subject: [PATCH 11/12] rearrange assert --- test/dotcom/trip_plan/anti_corruption_layer_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotcom/trip_plan/anti_corruption_layer_test.exs b/test/dotcom/trip_plan/anti_corruption_layer_test.exs index bf89278bb6..a4936feef9 100644 --- a/test/dotcom/trip_plan/anti_corruption_layer_test.exs +++ b/test/dotcom/trip_plan/anti_corruption_layer_test.exs @@ -43,7 +43,7 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayerTest do new_params = convert_old_params(old_params) - assert "false" == new_params["wheelchair"] + assert new_params["wheelchair"] == "false" end end end From d82b6c3b9fd3745bc17f7d9a1f1e7e02e7f9c656 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Wed, 13 Nov 2024 09:47:39 -0600 Subject: [PATCH 12/12] test a given false mode --- test/dotcom/trip_plan/anti_corruption_layer_test.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/dotcom/trip_plan/anti_corruption_layer_test.exs b/test/dotcom/trip_plan/anti_corruption_layer_test.exs index a4936feef9..665620b910 100644 --- a/test/dotcom/trip_plan/anti_corruption_layer_test.exs +++ b/test/dotcom/trip_plan/anti_corruption_layer_test.exs @@ -23,6 +23,7 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayerTest do "plan" => %{ "modes" => %{ "bus" => "true", + "ferry" => "false", "subway" => "true" } } @@ -31,9 +32,9 @@ defmodule Dotcom.TripPlan.AntiCorruptionLayerTest do new_params = convert_old_params(old_params) assert new_params["modes"]["BUS"] == "true" - assert new_params["modes"]["SUBWAY"] == "true" assert new_params["modes"]["FERRY"] == "false" assert new_params["modes"]["RAIL"] == "false" + assert new_params["modes"]["SUBWAY"] == "true" end test "defaults to wheelchair false when no wheelchair is given" do