Skip to content

Commit

Permalink
Revert "Revert "Enable new line diagram by default""
Browse files Browse the repository at this point in the history
This reverts commit 4495c0e.
  • Loading branch information
phildarnowsky committed Feb 10, 2020
1 parent 24dd11b commit f0f9b3e
Show file tree
Hide file tree
Showing 21 changed files with 9 additions and 211 deletions.
2 changes: 1 addition & 1 deletion apps/site/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ config :site, SiteWeb.ViewHelpers, google_tag_manager_id: System.get_env("GOOGLE

config :laboratory,
features: [
{:schedule_direction_redesign, "Schedule direction_redesign", ""}
{:old_line_diagram, "Go back to the old line diagram", ""}
],
cookie: [
# one month,
Expand Down
2 changes: 1 addition & 1 deletion apps/site/lib/site_web/controllers/schedule/line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule SiteWeb.ScheduleController.Line do
DiagramHelpers.build_stop_list(
branches,
direction_id,
Laboratory.enabled?(conn, :schedule_direction_redesign)
!Laboratory.enabled?(conn, :old_line_diagram)
)
)
|> assign(:branches, branches)
Expand Down
2 changes: 1 addition & 1 deletion apps/site/lib/site_web/controllers/schedule/line_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule SiteWeb.ScheduleController.LineApi do
route_id,
String.to_integer(direction_id),
conn.query_params["variant"],
Laboratory.enabled?(conn, :schedule_direction_redesign)
!Laboratory.enabled?(conn, :old_line_diagram)
)

conn =
Expand Down
2 changes: 1 addition & 1 deletion apps/site/lib/site_web/templates/schedule/_line.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= raw Poison.encode!(@schedule_page_data) %>
</script>

<% redesign_direction? = Laboratory.enabled?(@conn, :schedule_direction_redesign) %>
<% redesign_direction? = !Laboratory.enabled?(@conn, :old_line_diagram) %>

<div class="page-section m-schedule-line">
<div class="row">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 4 additions & 9 deletions apps/site/test/site_web/controllers/schedule/green_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,10 @@ defmodule SiteWeb.ScheduleController.GreenTest do
test "line tab :all_stops is a list of {bubble_info, %RouteStops{}} for all stops on all branches",
%{conn: conn} do
conn = get(conn, green_path(conn, :line, %{direction_id: 0}))
assert [{bubble_types, stop} | all_stops] = conn.assigns.all_stops
assert stop.id == "place-lech"

assert bubble_types == [
{"Green-B", :empty},
{"Green-C", :empty},
{"Green-D", :empty},
{"Green-E", :terminus}
]
assert [{_, %{id: "place-lech"}} | all_stops] = conn.assigns.all_stops

fenway = Enum.find(all_stops, fn {_, stop} -> stop.id == "place-fenwy" end)
assert elem(fenway, 0) == [{"Green-B", :line}, {"Green-C", :line}, {"Green-D", :stop}]

all_stops = Enum.map(all_stops, fn {_, stop} -> stop.id end)
assert "place-lake" in all_stops
Expand Down
32 changes: 0 additions & 32 deletions apps/site/test/site_web/controllers/schedule_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -403,38 +403,6 @@ defmodule SiteWeb.ScheduleControllerTest do
assert conn.assigns.active_shape.id == default_shape_id
end

test "sets schedule link to current direction for last stop and opposite for all other stops on non-bus lines",
%{conn: conn} do
response =
conn
|> get(line_path(conn, :show, "CR-Fitchburg", direction_id: 0))
|> html_response(200)

[last_stop | others] =
response
|> Floki.find(".schedule-link")
|> Enum.reverse()

assert last_stop |> Floki.attribute("href") |> List.first() =~ "direction_id=1"
refute others |> List.last() |> Floki.attribute("href") |> List.first() =~ "direction_id=1"

Enum.each(
others,
&assert(&1 |> Floki.attribute("href") |> List.first() =~ "direction_id=0")
)
end

test "does not show a checkmark next to any stops", %{conn: conn} do
response =
conn
|> get(line_path(conn, :show, "Red"))
|> html_response(200)

stops = Floki.find(response, ".route-branch-stop-list")
refute Enum.empty?(stops)
assert Floki.find(stops, ".fa-check") == []
end

test "assigned :paragraphs key is available to shuttles template", %{conn: conn} do
conn = get(conn, shuttles_path(conn, :show, "Red"))

Expand Down
167 changes: 1 addition & 166 deletions apps/site/test/site_web/views/schedule_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule SiteWeb.ScheduleViewTest do
alias Routes.Route
alias Schedules.Trip
alias SiteWeb.ScheduleView
alias Stops.{RouteStop, Stop}
alias Stops.Stop

import SiteWeb.ScheduleView
import Phoenix.HTML.Tag, only: [content_tag: 3]
Expand Down Expand Up @@ -546,119 +546,6 @@ defmodule SiteWeb.ScheduleViewTest do
end

describe "_line.html" do
@shape %Routes.Shape{id: "test", name: "test", stop_ids: [], direction_id: 0}

test "Bus line with variant filter", %{conn: conn} do
route_stop_1 = %RouteStop{
id: "stop 1",
name: "Stop 1",
zone: "1",
stop_features: [],
connections: []
}

route_stop_2 = %RouteStop{
id: "stop 2",
name: "Stop 2",
zone: "2",
stop_features: [],
connections: []
}

output =
ScheduleView.render(
"_line.html",
conn:
conn
|> Conn.fetch_query_params()
|> put_private(:phoenix_endpoint, SiteWeb.Endpoint),
stop_list_template: "_stop_list.html",
all_stops: [{[{nil, :terminus}], route_stop_1}, {[{nil, :terminus}], route_stop_2}],
route_shapes: [@shape, @shape],
active_shape: @shape,
alerts: [],
connections: [],
channel: "vehicles:1:1",
expanded: nil,
show_variant_selector: true,
map_img_src: nil,
holidays: [],
branches: [%Stops.RouteStops{branch: nil, stops: [route_stop_1, route_stop_2]}],
origin: nil,
destination: nil,
direction_id: 1,
route: %Routes.Route{type: 3, direction_destinations: %{1 => "End"}},
date: ~D[2017-01-01],
date_time: ~N[2017-03-01T07:29:00],
direction_id: 1,
reverse_direction_all_stops: [],
show_date_select?: false,
headsigns: %{0 => [], 1 => []},
vehicle_tooltips: %{},
featured_content: nil,
news: [],
dynamic_map_data: %{},
schedule_page_data: @schedule_page_data
)

assert safe_to_string(output) =~ "shape-filter"
end

test "Bus line without variant filter", %{conn: conn} do
route_stop_1 = %RouteStop{
id: "stop 1",
name: "Stop 1",
zone: "1",
stop_features: [],
connections: []
}

route_stop_2 = %RouteStop{
id: "stop 2",
name: "Stop 2",
zone: "2",
stop_features: [],
connections: []
}

output =
ScheduleView.render(
"_line.html",
conn:
conn
|> Conn.fetch_query_params()
|> put_private(:phoenix_endpoint, SiteWeb.Endpoint),
stop_list_template: "_stop_list.html",
all_stops: [{[{nil, :terminus}], route_stop_1}, {[{nil, :terminus}], route_stop_2}],
route_shapes: [@shape],
alerts: [],
connections: [],
channel: "vehicles:1:1",
upcoming_alerts: [],
expanded: nil,
active_shape: nil,
map_img_src: nil,
holidays: [],
branches: [%Stops.RouteStops{branch: nil, stops: [route_stop_1, route_stop_2]}],
route: %Routes.Route{type: 3, direction_destinations: %{1 => "End"}},
date: ~D[2017-01-01],
date_time: ~N[2017-03-01T07:29:00],
destination: nil,
origin: nil,
direction_id: 1,
reverse_direction_all_stops: [],
show_date_select?: false,
headsigns: %{0 => [], 1 => []},
vehicle_tooltips: %{},
featured_content: nil,
news: [],
dynamic_map_data: %{},
schedule_page_data: @schedule_page_data
)

refute safe_to_string(output) =~ "shape-filter"
end

test "Displays error message when there are no trips in selected direction", %{conn: conn} do
output =
ScheduleView.render(
Expand Down Expand Up @@ -696,58 +583,6 @@ defmodule SiteWeb.ScheduleViewTest do

assert safe_to_string(output) =~ "There are no scheduled"
end

test "Doesn't link to last stop if it's excluded", %{conn: conn} do
route = %Routes.Route{id: "route", type: 3, direction_destinations: %{1 => "End"}}

route_stop = %RouteStop{
id: "last",
name: "last",
zone: "1",
route: route,
connections: [],
stop_features: [],
is_terminus?: true,
is_beginning?: false
}

output =
ScheduleView.render(
"_line.html",
conn:
conn
|> Conn.fetch_query_params()
|> put_private(:phoenix_endpoint, SiteWeb.Endpoint),
stop_list_template: "_stop_list.html",
all_stops: [{[{nil, :terminus}], route_stop}],
alerts: [],
connections: [],
channel: "vehicles:1:1",
route_shapes: [@shape],
expanded: nil,
active_shape: nil,
map_img_src: nil,
holidays: [],
branches: [%Stops.RouteStops{branch: nil, stops: [route_stop]}],
route: route,
date: ~D[2017-01-01],
date_time: ~N[2017-03-01T07:29:00],
destination: nil,
origin: nil,
direction_id: 1,
reverse_direction_all_stops: [%Stops.Stop{id: "last"}],
show_date_select?: false,
headsigns: %{0 => [], 1 => []},
vehicle_tooltips: %{},
featured_content: nil,
news: [],
dynamic_map_data: %{},
schedule_page_data: @schedule_page_data
)

refute safe_to_string(output) =~
trip_view_path(SiteWeb.Endpoint, :show, "route", origin: "last", direction_id: 0)
end
end

describe "no_trips_message/5" do
Expand Down

0 comments on commit f0f9b3e

Please sign in to comment.