1 require "application_system_test_case"
 
   3 class SiteTest < ApplicationSystemTestCase
 
   4   test "visiting the index" do
 
   7     assert_selector "h1", :text => "OpenStreetMap"
 
  10   test "tooltip shows for Layers button" do
 
  13     assert_no_selector ".tooltip"
 
  14     button = find ".control-layers .control-button"
 
  16     assert_selector ".tooltip", :text => "Layers"
 
  19   test "tooltip shows for Map Key button on Standard layer" do
 
  22     assert_no_selector ".tooltip"
 
  23     button = find ".control-key .control-button"
 
  25     tooltip = find ".tooltip"
 
  26     tooltip.assert_text "Map Key"
 
  27     tooltip.assert_no_text "not available"
 
  30   test "tooltip shows for Map Key button on a layer without a key provided" do
 
  31     visit "/#layers=Y" # assumes that CyclOSM layer has no map key
 
  33     assert_no_selector ".tooltip"
 
  34     button = find ".control-key .control-button"
 
  36     tooltip = find ".tooltip"
 
  37     tooltip.assert_text "Map Key"
 
  38     tooltip.assert_text "not available"
 
  41   test "tooltip shows for query button when zoomed in" do
 
  44     assert_no_selector ".tooltip"
 
  45     button = find ".control-query .control-button"
 
  47     tooltip = find ".tooltip"
 
  48     tooltip.assert_text "Query features"
 
  49     tooltip.assert_no_text "Zoom in"
 
  54     ".control-note .control-button",
 
  55     ".control-query .control-button"
 
  57     test "tooltips on low zoom levels for disabled control '#{selector}'" do
 
  60       assert_no_selector ".tooltip"
 
  62       assert_selector ".tooltip", :text => "Zoom in"
 
  65     test "no zoom-in tooltips on high zoom levels, then tooltips appear after zoom out for control '#{selector}'" do
 
  68       assert_no_selector ".tooltip"
 
  70       assert_no_selector ".tooltip", :text => "Zoom in"
 
  71       find("h1").hover # un-hover original element
 
  74       find("#{selector}.disabled") # Ensure that capybara has waited for JS to finish processing
 
  76       assert_no_selector ".tooltip"
 
  78       assert_selector ".tooltip", :text => "Zoom in"
 
  82   test "notes layer tooltip appears on zoom out" do
 
  83     visit "/#map=9/40/-4" # depends on zoom levels where notes are allowed
 
  85     find(".control-layers .control-button").click
 
  86     li = find(".layers-ui .overlay-layers li:first-child")
 
  87     li.not_matches_css? ".disabled"
 
  88     li.hover # try to trigger disabled tooltip
 
  89     zoomout = find(".control-button.zoomout")
 
  90     zoomout.hover # un-hover the tooltip that's being tested
 
  92     li.matches_css? ".disabled"
 
  94     assert_selector ".tooltip", :text => "Zoom in"