From f9f76fbee060df4b00654fb831309cae162fb8d0 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 13 Dec 2024 08:37:41 -0600 Subject: [PATCH] remove test for live trip planner form and fix input form tests --- test/dotcom/trip_plan/input_form_test.exs | 31 ++++++------------- .../trip_planner/trip_planner_form_test.exs | 23 -------------- 2 files changed, 9 insertions(+), 45 deletions(-) delete mode 100644 test/dotcom_web/components/live_components/trip_planner/trip_planner_form_test.exs diff --git a/test/dotcom/trip_plan/input_form_test.exs b/test/dotcom/trip_plan/input_form_test.exs index aa7c51da63..b4aecf24c2 100644 --- a/test/dotcom/trip_plan/input_form_test.exs +++ b/test/dotcom/trip_plan/input_form_test.exs @@ -32,15 +32,15 @@ defmodule Dotcom.TripPlan.InputFormTest do assert {_, [validation: :required]} = changeset.errors[:modes] end - describe "validate_params/1" do + describe "changeset/1" do test "validates to & from" do - changeset = InputForm.validate_params(@params) + changeset = InputForm.changeset(@params) assert changeset.valid? end test "adds from & to errors" do changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ "from" => %{ "latitude" => "", "longitude" => "", @@ -62,7 +62,7 @@ defmodule Dotcom.TripPlan.InputFormTest do test "adds error if from & to are the same" do changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ "from" => @from_params, "to" => @from_params }) @@ -73,22 +73,9 @@ defmodule Dotcom.TripPlan.InputFormTest do assert {^expected_error, _} = changeset.errors[:to] end - test "at least one mode required" do - changeset = - InputForm.validate_params(%{ - @params - | "modes" => %{RAIL: false, BUS: false, FERRY: false, SUBWAY: false} - }) - - refute changeset.valid? - - expected_error = InputForm.error_message(:modes) - assert {^expected_error, _} = changeset.errors[:modes] - end - test "adds datetime if using datetime_type == now" do changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ @params | "datetime_type" => "now", "datetime" => nil @@ -102,7 +89,7 @@ defmodule Dotcom.TripPlan.InputFormTest do expected_error = InputForm.error_message(:datetime) changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ @params | "datetime_type" => "arrive_by", "datetime" => nil @@ -112,7 +99,7 @@ defmodule Dotcom.TripPlan.InputFormTest do assert {^expected_error, _} = changeset.errors[:datetime] changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ @params | "datetime_type" => "leave_at", "datetime" => nil @@ -124,7 +111,7 @@ defmodule Dotcom.TripPlan.InputFormTest do test "requires date to be in the future" do changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ @params | "datetime_type" => "arrive_by", "datetime" => Faker.DateTime.forward(1) @@ -135,7 +122,7 @@ defmodule Dotcom.TripPlan.InputFormTest do expected_error = InputForm.error_message(:datetime) changeset = - InputForm.validate_params(%{ + InputForm.changeset(%{ @params | "datetime_type" => "arrive_by", "datetime" => Faker.DateTime.backward(1) diff --git a/test/dotcom_web/components/live_components/trip_planner/trip_planner_form_test.exs b/test/dotcom_web/components/live_components/trip_planner/trip_planner_form_test.exs deleted file mode 100644 index 91dc28e6a3..0000000000 --- a/test/dotcom_web/components/live_components/trip_planner/trip_planner_form_test.exs +++ /dev/null @@ -1,23 +0,0 @@ -defmodule DotcomWeb.Components.LiveComponents.TripPlannerFormTest do - use ExUnit.Case, async: true - - import Phoenix.LiveViewTest - alias DotcomWeb.Components.LiveComponents.TripPlannerForm - - test "renders the needed inputs" do - html = - render_component(TripPlannerForm, %{ - id: "my_form", - form_name: "my_form" - }) - - assert html =~ - ~s(
) - - assert html =~ ~s(name="input_form[from]) - assert html =~ ~s(name="input_form[to]) - assert html =~ ~s(name="input_form[datetime_type]) - assert html =~ ~s(name="input_form[wheelchair]) - assert html =~ ~s(name="input_form[modes]) - end -end