diff --git a/lib/dotcom_web/templates/schedule/_line_header.html.eex b/lib/dotcom_web/templates/schedule/_line_header.html.eex index d23d1162cf..001272ca8c 100644 --- a/lib/dotcom_web/templates/schedule/_line_header.html.eex +++ b/lib/dotcom_web/templates/schedule/_line_header.html.eex @@ -4,6 +4,7 @@ <%= route_header_text(@route) %> <%= route_header_description(@route) %> + <%= frequent_bus_badge(@route) %>
<%= route_header_tabs(@conn) %>
diff --git a/lib/dotcom_web/views/schedule_view.ex b/lib/dotcom_web/views/schedule_view.ex index 4b5558ca03..0c1b2a7494 100644 --- a/lib/dotcom_web/views/schedule_view.ex +++ b/lib/dotcom_web/views/schedule_view.ex @@ -5,6 +5,7 @@ defmodule DotcomWeb.ScheduleView do import DotcomWeb.ScheduleView.StopList import DotcomWeb.ScheduleView.Timetable + import DotcomWeb.ViewHelpers require Routes.Route @@ -411,4 +412,21 @@ defmodule DotcomWeb.ScheduleView do def station?(stop) do stop.station? end + + @spec frequent_bus_badge(Route.t()) :: Safe.t() | nil + def frequent_bus_badge(%Route{description: :frequent_bus_route}) do + content_tag :div, + class: "bg-white rounded-full h-8 w-fit flex gap-2 items-center py-1 pl-1 pr-3 mb-6" do + [ + svg("icon-frequent-bus.svg"), + content_tag :span, class: "text-sm font-bold" do + "Service every 15 minutes or better" + end + ] + end + end + + def frequent_bus_badge(_route) do + nil + end end diff --git a/lib/routes/parser.ex b/lib/routes/parser.ex index c048933a7a..f3fa3526df 100644 --- a/lib/routes/parser.ex +++ b/lib/routes/parser.ex @@ -77,9 +77,12 @@ defmodule Routes.Parser do def parse_gtfs_desc("Ferry"), do: :ferry def parse_gtfs_desc("Rail Replacement Bus"), do: :rail_replacement_bus def parse_gtfs_desc("Key Bus"), do: :key_bus_route + def parse_gtfs_desc("Frequent Bus"), do: :frequent_bus_route def parse_gtfs_desc("Supplemental Bus"), do: :supplemental_bus def parse_gtfs_desc("Commuter Bus"), do: :commuter_bus def parse_gtfs_desc("Community Bus"), do: :community_bus + def parse_gtfs_desc("Coverage Bus"), do: :coverage_bus + def parse_gtfs_desc("Regional Rail"), do: :regional_rail def parse_gtfs_desc(_), do: :unknown @spec parse_gtfs_fare_class(String.t()) :: Route.gtfs_fare_class() diff --git a/priv/static/icon-svg/icon-frequent-bus.svg b/priv/static/icon-svg/icon-frequent-bus.svg new file mode 100644 index 0000000000..9eaafeefcc --- /dev/null +++ b/priv/static/icon-svg/icon-frequent-bus.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/dotcom_web/views/schedule_view_test.exs b/test/dotcom_web/views/schedule_view_test.exs index f6ef6c3eea..e15ad4b345 100644 --- a/test/dotcom_web/views/schedule_view_test.exs +++ b/test/dotcom_web/views/schedule_view_test.exs @@ -456,4 +456,18 @@ defmodule DotcomWeb.ScheduleViewTest do assert station?(%Stop{id: "11257", station?: false}) == false end end + + describe "frequent_bus_badge/1" do + test "returns a badge for frequent bus routes" do + refute frequent_bus_badge(%Route{type: 3, description: :frequent_bus_route}) == nil + end + + test "does not return a badge for key bus routes" do + assert frequent_bus_badge(%Route{type: 3, description: :key_bus_route}) == nil + end + + test "returns nothing otherwise" do + assert frequent_bus_badge(%Route{type: 3, description: :community_bus}) == nil + end + end end diff --git a/test/routes/repo_test.exs b/test/routes/repo_test.exs index f156cfb098..5b7813300e 100644 --- a/test/routes/repo_test.exs +++ b/test/routes/repo_test.exs @@ -193,6 +193,24 @@ defmodule Routes.RepoTest do refute description == :key_bus_route end + test "frequent bus routes are tagged" do + route_id = Faker.Internet.slug() + frequent_route_id = Faker.Internet.slug() + + expect(MBTA.Api.Mock, :get_json, 2, fn "/routes/" <> id, _ -> + if id == frequent_route_id do + %JsonApi{data: [build(:route_item, %{attributes: %{"description" => "Frequent Bus"}})]} + else + %JsonApi{data: [build(:route_item)]} + end + end) + + assert %Route{description: :frequent_bus_route} = get(frequent_route_id) + + %Route{description: description} = get(route_id) + refute description == :frequent_bus_route + end + describe "by_stop/1" do test "can specify type as param" do stop_id = Faker.Internet.slug()