From 52645df56c7c340e93ce2380689d3b878c5db92a Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Thu, 5 Mar 2026 10:31:41 -0500 Subject: [PATCH] INSR-8688: More awaits and broader try/catch for google places API calls --- .../contact-details/contact-details.spec.js | 5 +--- .../contact-details/contact-details.vue | 24 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/layouts/contact-details/contact-details.spec.js b/src/layouts/contact-details/contact-details.spec.js index b56a929b..6d1be304 100644 --- a/src/layouts/contact-details/contact-details.spec.js +++ b/src/layouts/contact-details/contact-details.spec.js @@ -13,10 +13,7 @@ import { useMainStore } from '@/store/index.js'; /** @ignore */ function setupMocks({ storeData, - props, - isShallowMount = true, - querySelectorFunction, - geocoderResult = ['1234 Test Street'] + props }) { const mountOptions = getMountOptions({ router: { diff --git a/src/layouts/contact-details/contact-details.vue b/src/layouts/contact-details/contact-details.vue index 8fff6681..b73d3fc4 100644 --- a/src/layouts/contact-details/contact-details.vue +++ b/src/layouts/contact-details/contact-details.vue @@ -158,9 +158,9 @@ export default { async beforeRouteEnter(to, from, next) { const cmsContent = await fetchCmsContentForPage(to.query.issPage); - next((vm) => { + next(async (vm) => { vm.setCmsContent(cmsContent); - vm.setupAddressLookup(); + await vm.setupAddressLookup(); }); }, data() { @@ -272,10 +272,10 @@ export default { this.address2 = ''; this.city = ''; }, - setupAddressLookup() { + async setupAddressLookup() { const apiKey = applicationConfig.GOOGLE_PLACES_API_KEY; - this.$loadScript(`https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places&callback=Function.prototype`) + await this.$loadScript(`https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places&callback=Function.prototype`) .catch(() => { // Failed to fetch script window.console.warn('Unable to load Google Places API script'); @@ -283,15 +283,15 @@ export default { }, geocodeAddress() { const autoCompletePromise = new Promise((resolve, reject) => { - // Get Autocomplete Service - const acService = new window.google.maps.places.AutocompleteService(); - // Get Places Service, needs psuedo element (or a map) - const placeService = new window.google.maps.places.PlacesService(document.createElement('div')); - // Create Autocomplete Session token, multiple requests one pricing hit - const acSessionToken = new window.google.maps.places.AutocompleteSessionToken(); - - const addressValue = `${this.address}, ${this.city}, ${this.state} ${this.zipCode}`; try { + // Get Autocomplete Service + const acService = new window.google.maps.places.AutocompleteService(); + // Get Places Service, needs pseudo element (or a map) + const placeService = new window.google.maps.places.PlacesService(document.createElement('div')); + // Create Autocomplete Session token, multiple requests one pricing hit + const acSessionToken = new window.google.maps.places.AutocompleteSessionToken(); + + const addressValue = `${this.address}, ${this.city}, ${this.state} ${this.zipCode}`; acService.getPlacePredictions( { input: addressValue,