Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show alert if map cannot load #12963

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/assets/javascripts/darkswarm/directives/map_search.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 27 additions & 0 deletions spec/system/consumer/map_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading