Skip to content

Commit

Permalink
feat(ShuttleHeadsigns): Merge the replacement shuttle bus cards with … (
Browse files Browse the repository at this point in the history
#1769)

* feat(ShuttleHeadsigns): Merge the replacement shuttle bus cards with the commuter rail cards

* Added tests and cleaned up files

* Responded to feed back and cleanup

* Fixed tests

* fixup some more tests

---------

Co-authored-by: Cristen Jones <[email protected]>
  • Loading branch information
kotva006 and thecristen authored Oct 19, 2023
1 parent 685095c commit 1736685
Show file tree
Hide file tree
Showing 38 changed files with 495 additions and 88 deletions.
6 changes: 5 additions & 1 deletion apps/routes/lib/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ defmodule Routes.Parser do
direction_destinations:
direction_attrs(attributes["direction_destinations"], parse_route_patterns(relationships)),
description: parse_gtfs_desc(attributes["description"]),
fare_class: parse_gtfs_fare_class(attributes["fare_class"])
fare_class: parse_gtfs_fare_class(attributes["fare_class"]),
line_id: parse_line_id(relationships)
}
end

defp parse_line_id(%{"line" => [head | _] = _lines}), do: head.id
defp parse_line_id(_), do: nil

def parse_route_with_route_pattern(%Item{relationships: relationships} = item) do
{parse_route(item), parse_route_patterns(relationships)}
end
Expand Down
12 changes: 8 additions & 4 deletions apps/routes/lib/route.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ defmodule Routes.Route do
direction_destinations: :unknown,
description: :unknown,
fare_class: :unknown_fare,
custom_route?: false
custom_route?: false,
line_id: ""

@type id_t :: String.t()
@type t :: %__MODULE__{
Expand All @@ -29,7 +30,8 @@ defmodule Routes.Route do
direction_destinations: %{0 => String.t(), 1 => String.t()} | :unknown,
description: gtfs_route_desc,
fare_class: gtfs_fare_class,
custom_route?: boolean
custom_route?: boolean,
line_id: String.t() | nil
}
@type gtfs_route_type ::
:subway | :commuter_rail | :bus | :ferry | :logan_express | :massport_shuttle
Expand Down Expand Up @@ -263,7 +265,8 @@ defmodule Routes.Route do
direction_destinations: direction_destinations,
description: description,
fare_class: fare_class,
custom_route?: custom_route?
custom_route?: custom_route?,
line_id: line_id
}) do
direction_destinations_value =
if direction_destinations == :unknown,
Expand All @@ -287,7 +290,8 @@ defmodule Routes.Route do
direction_destinations: direction_destinations_value,
description: description,
fare_class: fare_class,
custom_route?: custom_route?
custom_route?: custom_route?,
line_id: line_id
}
end
end
Expand Down
3 changes: 2 additions & 1 deletion apps/routes/test/route_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ defmodule Routes.RouteTest do
type: 1,
color: "DA291C",
sort_order: 5,
fare_class: :unknown_fare
fare_class: :unknown_fare,
line_id: ""
}

assert Route.to_json_safe(route) == expected
Expand Down
1 change: 1 addition & 0 deletions apps/site/assets/ts/__v3api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export interface Route {
name: string;
sort_order?: number;
type: RouteType;
line_id: string | null;
}

export interface EnhancedRoute extends Route {
Expand Down
3 changes: 2 additions & 1 deletion apps/site/assets/ts/components/__tests__/DirectionTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const route: EnhancedRoute = {
header: "Route Header",
long_name: "Route Long Name",
description: "Route Description",
type: 1
type: 1,
line_id: null
};

it("it renders", () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/site/assets/ts/components/__tests__/StopCardTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const route: EnhancedRoute = {
header: "Route Header",
long_name: "Route Long Name",
description: "Route Description",
type: 1
type: 1,
line_id: null
};

it("it renders a stop card", () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/site/assets/ts/leaflet/__tests__/MapTooltipTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const routes: EnhancedRoute[] = [
direction_destinations: { "0": "Forest Hills", "1": "Oak Grove" }, // eslint-disable-line camelcase
description: "rapid_transit",
alerts: [], // eslint-disable-line camelcase
header: ""
header: "",
line_id: null
}
];

Expand Down
3 changes: 3 additions & 0 deletions apps/site/assets/ts/models/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ export const isASilverLineRoute = (routeOrRouteId: Route | string): boolean => {
};

export const RAPID_TRANSIT = "rapid_transit";
export const RAIL_REPLACEMENT_BUS = "rail_replacement_bus";

export const isRapidTransit = ({ description }: Route): boolean =>
description === RAPID_TRANSIT;
export const isGreenLine = ({ id }: Route): boolean => id === "Green";
export const isRailReplacementBus = ({ description }: Route): boolean =>
description === RAIL_REPLACEMENT_BUS;

const routeTypesToMode: {
[key in RouteType]: Mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const route: EnhancedRoute = {
id: "Orange",
name: "Orange",
long_name: "Orange Line",
type: 1
type: 1,
line_id: null
};

const notSubwayRoute: EnhancedRoute = {
Expand All @@ -56,7 +57,8 @@ const notSubwayRoute: EnhancedRoute = {
id: "2",
name: "Two",
long_name: "Two",
type: 3
type: 3,
line_id: null
};

it("it renders", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const route: EnhancedRoute = {
"1": "Alewife"
},
description: "rapid_transit",
alerts: []
alerts: [],
line_id: null
};
/* eslint-enable camelcase */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const route = {
description: "key_bus_route",
"custom_route?": false,
header: "",
alerts: []
alerts: [],
line_id: null
} as EnhancedRoute;

const oneDirectionRoute = {
Expand All @@ -71,7 +72,8 @@ const oneDirectionRoute = {
description: "key_bus_route",
"custom_route?": false,
header: "",
alerts: []
alerts: [],
line_id: null
} as EnhancedRoute;

const directionId = 1;
Expand Down Expand Up @@ -243,7 +245,8 @@ const getGreenLineComponent = () => {
},
description: "rapid_transit",
header: "",
alerts: []
alerts: [],
line_id: null
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const route: EnhancedRoute = {
id: "Orange",
long_name: "Orange Line",
name: "Orange",
type: 1
type: 1,
line_id: null
};

const stops = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ const route: EnhancedRoute = {
id: "Orange",
name: "Orange",
long_name: "Orange Line",
type: 1
type: 1,
line_id: null
};

const routeNotSubway: EnhancedRoute = {
Expand All @@ -107,7 +108,8 @@ const routeNotSubway: EnhancedRoute = {
id: "Silver",
name: "Silver 1",
long_name: "Silver Line",
type: 2
type: 2,
line_id: null
};

const service: ServiceInSelector = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const route: Route = {
0: "Begin",
1: "End"
},
description: "key_bus_route"
description: "key_bus_route",
line_id: null
};

const liveData: LiveDataByStop = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const route = {
description: "key_bus_route",
"custom_route?": false,
header: "",
alerts: []
alerts: [],
line_id: null
};

const useSWRSpy = jest.spyOn(swr, "default");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ const route = {
description: "key_bus_route",
"custom_route?": false,
header: "",
alerts: []
alerts: [],
line_id: null
};

const handleStopClick = () => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const route: Route = {
id: "Orange",
long_name: "Orange Line",
name: "Orange",
type: 1
type: 1,
line_id: null
};

const oneDirectionRoute: Route = {
Expand All @@ -30,7 +31,8 @@ const oneDirectionRoute: Route = {
id: "route",
long_name: "the route",
name: "Route",
type: 1
type: 1,
line_id: null
};

const stops: SimpleStopMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const route: Route = {
id: "Orange",
long_name: "Orange Line",
name: "Orange",
type: 1
type: 1,
line_id: null
};

const stops = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const route: EnhancedRoute = {
id: "Orange",
name: "Orange",
long_name: "Orange Line",
type: 1
type: 1,
line_id: null
};

const busRoute: EnhancedRoute = {
Expand All @@ -29,7 +30,8 @@ const busRoute: EnhancedRoute = {
id: "1",
name: "1",
long_name: "1",
type: 3
type: 3,
line_id: null
};

const scheduleNoteData = {
Expand Down Expand Up @@ -216,7 +218,8 @@ describe("ScheduleModalContent", () => {
long_name: "Charlestown Ferry",
name: "Charlestown Ferry",
sort_order: 30001,
type: 4
type: 4,
line_id: null
} as Route;
const wrapper = mount(
<ScheduleModalContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ describe("DailyScheduleSubway", () => {
id: "1",
long_name: "Route 1",
name: "Route 1",
type: 0 as RouteType
type: 0 as RouteType,
line_id: null
};

it("should render", () => {
Expand Down
Loading

0 comments on commit 1736685

Please sign in to comment.