Misc Questions Pages

This commit is contained in:
Chloe Herd 2023-09-20 13:01:31 -04:00
parent fed47a13e9
commit b7f2f060ab
6 changed files with 75 additions and 13 deletions

View file

@ -237,6 +237,11 @@ describe("capabilityQuestions.vue", () => {
data: [],
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: [],
};
});
// Act
wrapper.vm.forwardButtonAction();
@ -272,6 +277,11 @@ describe("capabilityQuestions.vue", () => {
data: [],
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: [],
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreAction");
// Act
@ -325,7 +335,12 @@ describe("capabilityQuestions.vue", () => {
data: [],
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreAction");
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: [],
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreActionWithLogging");
// Act
wrapper.vm.forwardButtonAction();
@ -334,9 +349,10 @@ describe("capabilityQuestions.vue", () => {
//Assert
expect(spy).toHaveBeenNthCalledWith(
2,
1,
"getPartFromCapabilityQuestionAnswer",
"Windshield",
"capability-questions",
false
);
@ -368,6 +384,11 @@ describe("capabilityQuestions.vue", () => {
data: [],
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: [],
};
});
wrapper.vm.navigateForward = jest.fn();
// Act

View file

@ -162,9 +162,10 @@ export default {
const partsOrQuestions = this.partsOrQuestionsData;
for (let answer of questionAnswersArray) {
const partFromCapabilityQuestionAnswer = (
await this.dispatchStoreAction(
await this.dispatchStoreActionWithLogging(
this.storeActions.GET_PART_FROM_CAPABILITY_QUESTION_ANSWER,
answer.glassLocation,
"capability-questions",
false
)
).data;

View file

@ -248,6 +248,13 @@ describe("partQuestions.vue...", () => {
},
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: {
glassPieceParts: [],
},
};
});
// Act
wrapper.vm.forwardButtonAction();
@ -281,6 +288,13 @@ describe("partQuestions.vue...", () => {
},
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: {
glassPieceParts: [],
},
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreAction");
// Act
@ -328,7 +342,14 @@ describe("partQuestions.vue...", () => {
},
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreAction");
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: {
glassPieceParts: [],
},
};
});
const spy = jest.spyOn(wrapper.vm, "dispatchStoreActionWithLogging");
// Act
wrapper.vm.forwardButtonAction();
@ -336,7 +357,7 @@ describe("partQuestions.vue...", () => {
await nextTick();
//Assert
expect(spy).toHaveBeenNthCalledWith(2, "getParts");
expect(spy).toHaveBeenNthCalledWith(1, "getParts", null, "part-questions");
wrapper.unmount();
});
@ -362,6 +383,13 @@ describe("partQuestions.vue...", () => {
},
};
});
wrapper.vm.dispatchStoreActionWithLogging = jest.fn(() => {
return {
data: {
glassPieceParts: [],
},
};
});
wrapper.vm.navigateForward = jest.fn();
// Act

View file

@ -145,7 +145,11 @@ export default {
);
// call API parts method
const partsLookup = await this.dispatchStoreAction(this.storeActions.GET_PARTS);
const partsLookup = await this.dispatchStoreActionWithLogging(
this.storeActions.GET_PARTS,
null,
"part-questions"
);
const glassPartsForStore = partsLookup.data.glassPieceParts;

View file

@ -408,12 +408,13 @@ export default {
for (let partOrQuestion of partsOrQuestions) {
if (this.hasCapabilityQuestions([partOrQuestion])) {
let capabilityQuestionsForGlassLocation = (
await baseMixin.methods.dispatchStoreAction(
await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_CAPABILITY_QUESTIONS,
{
carId: store.getters.vehicle.carId,
partNumber: partOrQuestion.parts[0].partNumber,
}
},
currentPage
)
).data;
@ -449,13 +450,13 @@ export default {
if (store.getters.order.referralNumber?.length === 6) {
navigateToHeritageFunnel({
shouldSaveSession: true,
pageNameToLog: this.$options.name,
pageNameToLog: currentPage,
loadingModal: self.$refs.loadingModal,
});
} else if (payment.isInsurance && payment.insuranceCoverage.isVerified) {
navigateToHeritageFunnel({
shouldSaveSession: true,
pageNameToLog: this.$options.name,
pageNameToLog: currentPage,
loadingModal: self.$refs.loadingModal,
});
} else {

View file

@ -1171,7 +1171,7 @@ export const actions = {
},
// Parts API Actions
async getParts(context) {
async getParts(context, { pageNameToLog }) {
const vehicle = context.getters.vehicle;
const damage = context.getters.damage;
const order = context.state.order;
@ -1196,6 +1196,8 @@ export const actions = {
zip: zipCode,
vin: vin,
},
logApiCall: true,
pageNameToLog: pageNameToLog,
});
// Flatten location and name properties
@ -1296,14 +1298,17 @@ export const actions = {
});
},
getCapabilityQuestions(context, { carId, partNumber }) {
getCapabilityQuestions(context, { payload: { carId, partNumber }, pageNameToLog }) {
return globalMethods.callHttpClient({
method: endpoints.GetCapabilityQuestions.method,
endpoint: `${endpoints.GetCapabilityQuestions.url}/${carId}/${partNumber}`,
logApiCall: true,
pageNameToLog: pageNameToLog,
});
},
getPartFromCapabilityQuestionAnswer(context, glassLocation) {
getPartFromCapabilityQuestionAnswer(context, { payload, pageNameToLog }) {
const glassLocation = payload;
const pageData = context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS);
const part = pageData.partsOrQuestions.find((x) => x.glassLocation === glassLocation)
@ -1320,6 +1325,8 @@ export const actions = {
part,
capabilityAnswerResults: capabilityQuestionAnswersForPart,
},
logApiCall: true,
pageNameToLog: pageNameToLog,
});
},