1 # frozen_string_literal: true
3 require "application_system_test_case"
5 class SiteTest < ApplicationSystemTestCase
6 test "visiting the index" do
9 assert_selector "h1", :text => "OpenStreetMap"
12 test "tooltip shows for Layers button" do
15 assert_no_selector ".tooltip"
16 button = find ".control-layers .control-button"
18 assert_selector ".tooltip", :text => "Layers"
21 test "tooltip shows for Map Key button on Standard layer" do
24 assert_no_selector ".tooltip"
25 button = find ".control-legend .control-button"
27 tooltip = find ".tooltip"
28 tooltip.assert_text "Map Key"
29 tooltip.assert_no_text "not available"
32 test "tooltip shows for Map Key button on a layer without a key provided" do
33 visit "/#layers=H" # assumes that HOT layer has no map key
35 assert_no_selector ".tooltip"
36 button = find ".control-legend .control-button"
38 tooltip = find ".tooltip"
39 tooltip.assert_text "Map Key"
40 tooltip.assert_text "not available"
43 test "tooltip shows for query button when zoomed in" do
46 assert_no_selector ".tooltip"
47 button = find ".control-query .control-button"
49 tooltip = find ".tooltip"
50 tooltip.assert_text "Query features"
51 tooltip.assert_no_text "Zoom in"
54 test "tooltips on low zoom levels for disabled control 'Edit'" do
55 check_control_tooltips_on_low_zoom "Edit"
57 test "tooltips on low zoom levels for disabled control 'Add a note to the map'" do
58 check_control_tooltips_on_low_zoom "Add a note to the map"
60 test "tooltips on low zoom levels for disabled control 'Query features'" do
61 check_control_tooltips_on_low_zoom "Query features"
64 test "no zoom-in tooltips on high zoom levels, then tooltips appear after zoom out for control 'Edit'" do
65 check_control_tooltips_on_high_zoom "Edit"
67 test "no zoom-in tooltips on high zoom levels, then tooltips appear after zoom out for control 'Add a note to the map'" do
68 check_control_tooltips_on_high_zoom "Add a note to the map"
70 test "no zoom-in tooltips on high zoom levels, then tooltips appear after zoom out for control 'Query features'" do
71 check_control_tooltips_on_high_zoom "Query features"
74 test "notes layer tooltip appears on zoom out" do
75 visit "/#map=10/40/-4" # depends on zoom levels where notes are allowed
81 assert_field "Map Notes"
82 find_field("Map Notes").hover # try to trigger disabled tooltip
85 zoom_out = find_link("Zoom Out")
86 zoom_out.hover # un-hover the tooltip that's being tested
87 zoom_out.click(:shift)
90 assert_field "Map Notes", :disabled => true
91 find_field("Map Notes", :disabled => true).hover
93 assert_selector ".tooltip", :text => "Zoom in to see"
98 def check_control_tooltips_on_low_zoom(locator)
101 assert_no_selector ".tooltip"
102 find_link(locator).hover
103 assert_selector ".tooltip", :text => "Zoom in to"
106 def check_control_tooltips_on_high_zoom(locator)
109 assert_no_selector ".tooltip"
110 find_link(locator).hover
111 assert_no_selector ".tooltip", :text => "Zoom in to"
112 find("h1").hover # un-hover original element
115 find_link(locator, :class => "disabled") # Ensure that capybara has waited for JS to finish processing
117 assert_no_selector ".tooltip"
118 find_link(locator).hover
119 assert_selector ".tooltip", :text => "Zoom in to"