1 require "application_system_test_case"
3 class DirectionsSystemTest < ApplicationSystemTestCase
4 test "removes popup on sidebar close" do
6 stub_straight_routing(:start_instruction => "Start popup text")
8 fill_in "route_from", :with => "60 30"
9 fill_in "route_to", :with => "61 31"
13 assert_no_content "Start popup text"
17 direction_entry = find "td", :text => "Start popup text"
22 assert_content "Start popup text"
26 find("button[aria-label='Close']").click
30 assert_no_content "Start popup text"
36 def stub_straight_routing(start_instruction: "Start here", finish_instruction: "Finish there")
37 stub_routing <<~CALLBACK
38 const distance = points[0].distanceTo(points[1]);
39 const time = distance * 30;
43 [points[0], 8, "<b>1.</b> #{start_instruction}", distance, points],
44 [points[1], 14, "<b>2.</b> #{finish_instruction}", 0, [points[1]]]
52 def stub_routing(callback_code)
53 execute_script <<~SCRIPT
55 for (const engine of OSM.Directions.engines) {
56 engine.getRoute = (points, callback) => {