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"
25 find("#sidebar .sidebar-close-controls button[aria-label='Close']").click
28 assert_no_content "Start popup text"
34 def stub_straight_routing(start_instruction: "Start here", finish_instruction: "Finish there")
35 stub_routing <<~CALLBACK
36 const distance = points[0].distanceTo(points[1]);
37 const time = distance * 30;
38 return Promise.resolve({
41 [points[0], 8, "<b>1.</b> #{start_instruction}", distance, points],
42 [points[1], 14, "<b>2.</b> #{finish_instruction}", 0, [points[1]]]
50 def stub_routing(callback_code)
51 execute_script <<~SCRIPT
53 for (const engine of OSM.Directions.engines) {
54 engine.getRoute = (points, signal) => {