Merge pull request #12963 from murjax/map-network-check-8230

Show alert if map cannot load
This commit is contained in:
Filipe
2024-11-28 12:26:22 -06:00
committed by GitHub
3 changed files with 36 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

@@ -2788,6 +2788,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,28 @@
# 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."
)
end
end
end