From 3793cde7066e4ef1c0e8d74974db3468f8b61e90 Mon Sep 17 00:00:00 2001 From: sloane Date: Wed, 28 Aug 2024 15:00:25 -0400 Subject: [PATCH] chore: suppress alert 590467 on pre-fare screens Alert #590467 represents suspension of red line service on the Braintree branch with shuttles connecting at Ashmont instead of JFK/UMass. Because of this abnormal shuttle pattern, the generated line maps will not be accurate. Evergreen content will be used to display the correct information to riders. --- .../v2/widget_instance/reconstructed_alert.ex | 9 ++++---- .../reconstructed_alert_test.exs | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/screens/v2/widget_instance/reconstructed_alert.ex b/lib/screens/v2/widget_instance/reconstructed_alert.ex index 6ec4a9657..9012f34b4 100644 --- a/lib/screens/v2/widget_instance/reconstructed_alert.ex +++ b/lib/screens/v2/widget_instance/reconstructed_alert.ex @@ -1313,10 +1313,11 @@ defmodule Screens.V2.WidgetInstance.ReconstructedAlert do def alert_ids(%__MODULE__{} = t), do: [t.alert.id] - def valid_candidate?(%__MODULE__{} = t) do - test_alert_ids = ["197140"] - prod_alert_ids = ["580015"] - t.alert.id not in (test_alert_ids ++ prod_alert_ids) + @test_alert_ids ~w[197140] + @prod_alert_ids ~w[580015 590467] + + def valid_candidate?(%__MODULE__{alert: %{id: alert_id}}) do + alert_id not in @test_alert_ids and alert_id not in @prod_alert_ids end defimpl Screens.V2.WidgetInstance do diff --git a/test/screens/v2/widget_instance/reconstructed_alert_test.exs b/test/screens/v2/widget_instance/reconstructed_alert_test.exs index f4ce0727e..91dd99a51 100644 --- a/test/screens/v2/widget_instance/reconstructed_alert_test.exs +++ b/test/screens/v2/widget_instance/reconstructed_alert_test.exs @@ -103,6 +103,10 @@ defmodule Screens.V2.WidgetInstance.ReconstructedAlertTest do %{widget | alert: %{widget.alert | header: header}} end + defp put_alert_id(widget, id) do + %{widget | alert: %{widget.alert | id: id}} + end + defp put_severity(widget, severity) do %{widget | alert: %{widget.alert | severity: severity}} end @@ -3172,4 +3176,21 @@ defmodule Screens.V2.WidgetInstance.ReconstructedAlertTest do ) end end + + describe "valid_candidate?/1" do + test "returns true", %{widget: widget} do + assert WidgetInstance.valid_candidate?(widget) + end + + suppressed_alerts = ~w[197140 580015 590467] + + for alert_id <- suppressed_alerts do + @tag alert_id: alert_id + test "returns false for alert ##{alert_id}", %{widget: widget, alert_id: alert_id} do + refute widget + |> put_alert_id(alert_id) + |> WidgetInstance.valid_candidate?() + end + end + end end