Merge pull request #3299 from Safelite/feature/CASH-2800

CASH-2800 - In Shop Maps link
This commit is contained in:
mvalaiyapathi 2026-07-31 10:56:22 -04:00 committed by GitHub
commit f36e7cf91f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 3 deletions

View file

@ -48,12 +48,13 @@ jest.mock("@/helpers/page-prerequisites-helper.js", () => ({
hasInsuranceInfo: jest.fn(() => true), hasInsuranceInfo: jest.fn(() => true),
})); }));
function setupMocks() { function setupMocks({ isAppleBrowser = false } = {}) {
const baseMixin = { const baseMixin = {
methods: { methods: {
getCmsContent: jest.fn(() => ""), getCmsContent: jest.fn(() => ""),
setCmsContent: jest.fn(), setCmsContent: jest.fn(),
getTotalLineItemPrice: jest.fn(() => 0), getTotalLineItemPrice: jest.fn(() => 0),
isAppleBrowser: jest.fn(() => isAppleBrowser),
}, },
}; };
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
@ -249,4 +250,40 @@ describe("scheduling.vue", () => {
wrapper.unmount(); wrapper.unmount();
}); });
}); });
describe("in-shop Maps link", () => {
const address = {
city: "Lewis Center",
state: "OH",
streetAddress: "1343 Cameron Ave",
zipCode: "43035",
};
const query = encodeURIComponent(
"safelite,Safelite Autoglass, 1343 Cameron Ave, Lewis Center, OH 43035"
);
test("onInshopAddressClicked opens Maps in a new tab for Google and Apple", () => {
const openSpy = jest.spyOn(window, "open").mockImplementation(() => null);
const { wrapper } = setupMocks();
wrapper.vm.onInshopAddressClicked({ address });
expect(openSpy).toHaveBeenCalledWith(
`https://www.google.com/maps/search/?api=1&query=${query}`,
"_blank",
"noopener,noreferrer"
);
wrapper.unmount();
openSpy.mockClear();
const { wrapper: appleWrapper } = setupMocks({ isAppleBrowser: true });
appleWrapper.vm.onInshopAddressClicked({ address });
expect(openSpy).toHaveBeenCalledWith(
`https://maps.apple.com/?q=${query}`,
"_blank",
"noopener,noreferrer"
);
appleWrapper.unmount();
openSpy.mockRestore();
});
});
}); });

View file

@ -130,6 +130,7 @@ const SCHEDULING_RADIO_GROUP_NAME = "schedulingTimeSlot";
const INITIAL_INSHOP_PROVIDER_COUNT = 3; const INITIAL_INSHOP_PROVIDER_COUNT = 3;
const MAX_INSHOP_PROVIDERS = 9; const MAX_INSHOP_PROVIDERS = 9;
const VIEW_MORE_SHOPS_BATCH_SIZE = 3; const VIEW_MORE_SHOPS_BATCH_SIZE = 3;
const INSHOP_MAPS_PLACE_NAME = "safelite,Safelite Autoglass";
/** /**
* Appends days from newSlots into entry.timeSlots, initializing it if absent. * Appends days from newSlots into entry.timeSlots, initializing it if absent.
@ -461,9 +462,32 @@ export default {
const day = providerEntry?.timeSlots?.days?.find((d) => d.date === this.selectedDate); const day = providerEntry?.timeSlots?.days?.find((d) => d.date === this.selectedDate);
return day?.timeSlots ?? []; return day?.timeSlots ?? [];
}, },
buildInshopMapsQuery(address) {
const streetAddress = address?.streetAddress?.trim();
if (!streetAddress) {
return null;
}
const street = [streetAddress, address.streetAddress2?.trim()]
.filter(Boolean)
.join(" ");
return `${INSHOP_MAPS_PLACE_NAME}, ${street}, ${address.city}, ${address.state} ${address.zipCode}`;
},
buildInshopMapsUrl(address) {
const query = this.buildInshopMapsQuery(address);
if (!query) {
return null;
}
if (this.isAppleBrowser()) {
return `https://maps.apple.com/?q=${encodeURIComponent(query)}`;
}
return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`;
},
onInshopAddressClicked(provider) { onInshopAddressClicked(provider) {
// TODO: open Google Maps when address link functionality is implemented const url = this.buildInshopMapsUrl(provider?.address);
console.log("onInshopAddressClicked", provider?.providerNumber); if (!url) {
return;
}
window.open(url, "_blank", "noopener,noreferrer");
}, },
onMobileZipCodeClicked() { onMobileZipCodeClicked() {
this.$refs.schedulingZipSearch?.focusZipInput(); this.$refs.schedulingZipSearch?.focusZipInput();