From b7f2f060ab7f682c00cbc27f7ce89aa6e588904f Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 20 Sep 2023 13:01:31 -0400 Subject: [PATCH] Misc Questions Pages --- .../capability-questions.spec.js | 25 +++++++++++++-- .../capability-questions.vue | 3 +- .../part-questions/part-questions.spec.js | 32 +++++++++++++++++-- src/layouts/part-questions/part-questions.vue | 6 +++- src/mixins/vehicle-questions-mixin.js | 9 +++--- src/store/index.js | 13 ++++++-- 6 files changed, 75 insertions(+), 13 deletions(-) diff --git a/src/layouts/capability-questions/capability-questions.spec.js b/src/layouts/capability-questions/capability-questions.spec.js index 34fb4be05..b901db0ca 100644 --- a/src/layouts/capability-questions/capability-questions.spec.js +++ b/src/layouts/capability-questions/capability-questions.spec.js @@ -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 diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index 5456b816c..717865e41 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -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; diff --git a/src/layouts/part-questions/part-questions.spec.js b/src/layouts/part-questions/part-questions.spec.js index 3382ec1dc..a1da5cdef 100644 --- a/src/layouts/part-questions/part-questions.spec.js +++ b/src/layouts/part-questions/part-questions.spec.js @@ -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 diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index b94c92e1d..63e1d9198 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -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; diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index a1d672cd7..43c55e8cf 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -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 { diff --git a/src/store/index.js b/src/store/index.js index 0f7b06406..ebee7760e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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, }); },