Show alert if map cannot load

This commit is contained in:
Ryan Murphy
2024-11-01 11:31:38 -04:00
parent 9afd545897
commit 008d764c34
3 changed files with 35 additions and 4 deletions

View File

@@ -20,10 +20,13 @@ angular.module('Darkswarm').directive 'mapSearch', ($timeout, Search) ->
$timeout =>
map = ctrl.getMap()
searchBox = scope.createSearchBox map
scope.bindSearchResponse map, searchBox
scope.biasResults map, searchBox
scope.performUrlSearch map
if !map
alert(t('gmap_load_failure'))
else
searchBox = scope.createSearchBox map
scope.bindSearchResponse map, searchBox
scope.biasResults map, searchBox
scope.performUrlSearch map
scope.createSearchBox = (map) ->
map.controls[google.maps.ControlPosition.TOP_LEFT].push scope.input

View File

@@ -2784,6 +2784,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
confirm_hub_change: "Are you sure? This will change your selected hub and remove any items in your shopping cart."
confirm_oc_change: "Are you sure? This will change your selected order cycle and remove any items in your shopping cart."
location_placeholder: "Type in a location..."
gmap_load_failure: "Unable to load map. Please check your browser settings and allow 3rd party cookies for this website."
error_required: "can't be blank"
error_number: "must be number"
error_email: "must be email address"

View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
require 'system_helper'
RSpec.describe 'Map' do
context 'map can load' do
it 'does not show alert' do
url_whitelist = page.driver.browser.url_whitelist
page.driver.browser.url_whitelist = nil
assert_raises(Capybara::ModalNotFound) do
accept_alert { visit '/map' }
end
page.driver.browser.url_whitelist = url_whitelist
end
end
context 'map cannot load' do
it 'shows alert' do
message = accept_alert { visit '/map' }
expect(message).to eq("Unable to load map.
Please check your browser settings
and allow 3rd party cookies for this website.".squish)
end
end
end