From 008d764c3421aa384c284ccf149686023c17a2ea Mon Sep 17 00:00:00 2001 From: Ryan Murphy Date: Fri, 1 Nov 2024 11:31:38 -0400 Subject: [PATCH 1/2] Show alert if map cannot load --- .../darkswarm/directives/map_search.js.coffee | 11 +++++--- config/locales/en.yml | 1 + spec/system/consumer/map_spec.rb | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 spec/system/consumer/map_spec.rb diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index 0d36b87d2b8..8ac7e5b653f 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 80b5a5e90b3..df0e60f54fb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" diff --git a/spec/system/consumer/map_spec.rb b/spec/system/consumer/map_spec.rb new file mode 100644 index 00000000000..b2336243586 --- /dev/null +++ b/spec/system/consumer/map_spec.rb @@ -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 From 32ab821839d1834e3a9f2985efaee6fc64e87e52 Mon Sep 17 00:00:00 2001 From: Ryan Murphy Date: Wed, 6 Nov 2024 08:39:35 -0500 Subject: [PATCH 2/2] 8230 - Map spec update --- spec/system/consumer/map_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/system/consumer/map_spec.rb b/spec/system/consumer/map_spec.rb index b2336243586..7cafdbeda6d 100644 --- a/spec/system/consumer/map_spec.rb +++ b/spec/system/consumer/map_spec.rb @@ -19,9 +19,10 @@ 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) + expect(message).to eq( + "Unable to load map. Please check your browser " \ + "settings and allow 3rd party cookies for this website." + ) end end end