CSR-504 | Fix unit tests and formatting

This commit is contained in:
Scott Kiener 2022-11-17 16:37:35 -05:00
parent 200918f60f
commit 181de2d386
4 changed files with 38 additions and 22 deletions

View file

@ -21,8 +21,8 @@ const storeActions = {
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
GET_PARTS: "getParts", GET_PARTS: "getParts",
GET_WIPERS: "getWipers", GET_WIPERS: "getWipers",
GET_RAIN_DEFENSE: 'getRainDefense', GET_RAIN_DEFENSE: "getRainDefense",
GET_SUPPORTING_ITEMS: 'getSupportingItems', GET_SUPPORTING_ITEMS: "getSupportingItems",
GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions", GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions",
GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer", GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer",
GET_MOLDING_QUESTIONS: "getMoldingQuestions", GET_MOLDING_QUESTIONS: "getMoldingQuestions",

View file

@ -69,8 +69,12 @@ export default {
// Call APIs // Call APIs
const cmsContent = await fetchCmsContentForPage(to.query.fmgPage); const cmsContent = await fetchCmsContentForPage(to.query.fmgPage);
const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS); const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS);
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_RAIN_DEFENSE); const rainDefensePromise = baseMixin.methods.dispatchStoreAction(
const supportingItemsPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_SUPPORTING_ITEMS); storeActions.GET_RAIN_DEFENSE
);
const supportingItemsPromise = baseMixin.methods.dispatchStoreAction(
storeActions.GET_SUPPORTING_ITEMS
);
const promiseResultMap = [ const promiseResultMap = [
{ {
@ -89,9 +93,18 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
const glassParts = [...store.getters.order.lineItems.glassParts]; const glassParts = [...store.getters.order.lineItems.glassParts];
const availableLineItems = [resultMap.rainDefense, ...resultMap.supportingItems, ...resultMap.wipers, ...glassParts]; const availableLineItems = [
resultMap.rainDefense,
...resultMap.supportingItems,
...resultMap.wipers,
...glassParts,
];
const pricingResults = await baseMixin.methods.dispatchStoreAction(storeActions.PRICE_ORDER_ITEMS, availableLineItems, false); const pricingResults = await baseMixin.methods.dispatchStoreAction(
storeActions.PRICE_ORDER_ITEMS,
availableLineItems,
false
);
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {

View file

@ -874,13 +874,15 @@ export const actions = {
getWipers(context) { getWipers(context) {
const carId = context.getters.vehicle.carId; const carId = context.getters.vehicle.carId;
const serviceZipCode = context.getters.order.serviceLocation.zipCode; const serviceZipCode = context.getters.order.serviceLocation.zipCode;
return globalMethods.callHttpClient({ return globalMethods
method: endpoints.GetWipers.method, .callHttpClient({
endpoint: `${endpoints.GetWipers.url}/${carId}/${serviceZipCode}`, method: endpoints.GetWipers.method,
}).catch(error => { endpoint: `${endpoints.GetWipers.url}/${carId}/${serviceZipCode}`,
// The wiper service sometimes returns 500s on legitimate carId/zipCode combination - return empty array instead of breaking flow })
return []; .catch((error) => {
}); // The wiper service sometimes returns 500s on legitimate carId/zipCode combination - return empty array instead of breaking flow
return [];
});
}, },
getRainDefense(context) { getRainDefense(context) {
@ -898,7 +900,7 @@ export const actions = {
const carId = context.getters.vehicle.carId; const carId = context.getters.vehicle.carId;
const isRepair = context.getters.damage.isRepair; const isRepair = context.getters.damage.isRepair;
const numberOfChips = context.getters.damage.numberOfChips; const numberOfChips = context.getters.damage.numberOfChips;
const accountNumber = "82791";//context.getters.order.accountNumber.toString(); const accountNumber = "82791"; //context.getters.order.accountNumber.toString();
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.GetSupportingItems.method, method: endpoints.GetSupportingItems.method,
endpoint: endpoints.GetSupportingItems.url, endpoint: endpoints.GetSupportingItems.url,
@ -907,8 +909,8 @@ export const actions = {
serviceType: isRepair ? "Repair" : "Replace", serviceType: isRepair ? "Repair" : "Replace",
//accountNumber: accountNumber, //accountNumber: accountNumber,
parts: glassPartsArray, parts: glassPartsArray,
numberOfRepairChips: isRepair ? numberOfChips : 0 numberOfRepairChips: isRepair ? numberOfChips : 0,
}, },
}); });
}, },
@ -1355,9 +1357,9 @@ export const actions = {
// Price order actions // Price order actions
// PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED // PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED
priceOrderItems(context, availableLineItems) { priceOrderItems(context, availableLineItems) {
availableLineItems.forEach((lineItem => { availableLineItems.forEach((lineItem) => {
lineItem["price"] = parseFloat((Math.random() * 100).toFixed(2)); lineItem["price"] = parseFloat((Math.random() * 100).toFixed(2));
})); });
return availableLineItems; return availableLineItems;
}, },
// Misc order actions // Misc order actions

View file

@ -662,7 +662,7 @@ describe("Actions", () => {
const context = state; const context = state;
globalMethods.callHttpClient.mockImplementation(() => { globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: { referralNumber: 123 } }); return Promise.resolve({ data: { referralNumber: 123, order: {} } });
}); });
const commit = jest.fn(); const commit = jest.fn();
@ -675,9 +675,10 @@ describe("Actions", () => {
}); });
// Assert // Assert
expect(response.data).toEqual({ referralNumber: 123 }); expect(response.data).toEqual({ referralNumber: 123, order: {} });
expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, { expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, {
referralNumber: 123, referralNumber: 123,
order: {},
}); });
}); });
@ -686,7 +687,7 @@ describe("Actions", () => {
const context = state; const context = state;
globalMethods.callHttpClient.mockImplementation(() => { globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: { eon: "123" } }); return Promise.resolve({ data: { eon: "123", order: {} } });
}); });
context.commit = jest.fn(); context.commit = jest.fn();
@ -709,7 +710,7 @@ describe("Actions", () => {
const context = state; const context = state;
globalMethods.callHttpClient.mockImplementation(() => { globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: { eon: "123" } }); return Promise.resolve({ data: { eon: "123", order: {} } });
}); });
context.commit = jest.fn(); context.commit = jest.fn();