This commit is contained in:
Chloe Herd 2023-09-21 10:11:44 -04:00
parent 6161e8de12
commit 9a3318b3fd
3 changed files with 28 additions and 9 deletions

View file

@ -36,6 +36,10 @@ jest.mock("@/mixins/base-mixin", () => ({
if (action === mockPriceOrderStoreAction) return items;
else return mockStoreActionResults[action];
},
dispatchStoreActionWithLogging(action, items, pageName, encode) {
if (action === mockPriceOrderStoreAction) return items;
else return mockStoreActionResults[action];
},
getTierOnePackagePrice() {
return mockTierOnePrice;
},

View file

@ -86,12 +86,20 @@ export default {
async beforeRouteEnter(to, from, next) {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS);
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(
storeActions.GET_RAIN_DEFENSE
const wipersPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_WIPERS,
null,
"quote"
);
const supportingItemsPromise = baseMixin.methods.dispatchStoreAction(
storeActions.GET_SUPPORTING_ITEMS
const rainDefensePromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_RAIN_DEFENSE,
null,
"quote"
);
const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_SUPPORTING_ITEMS,
null,
"quote"
);
const promiseResultMap = [
@ -124,11 +132,12 @@ export default {
...clonedGlassParts,
];
const pricingResults = await baseMixin.methods.dispatchStoreAction(
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
{
availableLineItems: availableLineItems,
},
"quote",
false
);

View file

@ -1210,13 +1210,15 @@ export const actions = {
return response;
},
getWipers(context) {
getWipers(context, { pageNameToLog }) {
const carId = context.getters.vehicle.carId;
const serviceZipCode = context.getters.order.serviceLocation.zipCode;
return globalMethods
.callHttpClient({
method: endpoints.GetWipers.method,
endpoint: `${endpoints.GetWipers.url}/${carId}/${serviceZipCode}`,
logApiCall: true,
pageNameToLog: pageNameToLog,
})
.catch((error) => {
// The wiper service sometimes returns 500s on legitimate carId/zipCode combination - return empty array instead of breaking flow
@ -1224,10 +1226,12 @@ export const actions = {
});
},
getRainDefense(context) {
getRainDefense(context, { pageNameToLog }) {
return globalMethods.callHttpClient({
method: endpoints.GetRainDefense.method,
endpoint: endpoints.GetRainDefense.url,
logApiCall: true,
pageNameToLog: pageNameToLog,
});
},
@ -1959,7 +1963,7 @@ export const actions = {
// Price order actions
async priceOrderItemsAndSaveServerData(
context,
{ availableLineItems, serviceZipCode, serviceZipCodeCtu }
{ payload: { availableLineItems, serviceZipCode, serviceZipCodeCtu }, pageNameToLog }
) {
const zipCodeToUse = serviceZipCode
? serviceZipCode
@ -1999,6 +2003,8 @@ export const actions = {
const response = await globalMethods.callHttpClient({
method: endpoints.PriceOrderItems.method,
endpoint: `${endpoints.PriceOrderItems.url}?${queryString}`,
logApiCall: true,
pageNameToLog: pageNameToLog,
});
context.commit(storeMutations.UPDATE_LINE_ITEMS_SERVER_DATA, response.data.serverData);