From 602512c23ff19cf16c3593cecd6bc085ae908e37 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 30 Aug 2022 14:37:40 -0400 Subject: [PATCH 1/5] CSR-111 Add test.todos --- src/store/store.spec.js | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/store/store.spec.js b/src/store/store.spec.js index a69be855b..66def95e6 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1154,6 +1154,48 @@ describe("Actions", () => { ]); }); }) + + describe("savePartQuestionAnswers", () => { + test.todo("saves partQuestionAnswers") + + test.todo("there are no previous answers => resets necessary fields") + + // mix up the order to make sure sort is working + test.todo("previous answers match current answers => does not reset fields") + + test.todo("previous answers does not match current answers => resets necessary fields") + }) + + describe("resetMoldingAndCapabilityQuestionAnswersIfNeeded", () => { + test.todo("there are no saved parts => resets necessary fields") + + // mix up the order to make sure sort is working + test.todo("previously saved parts match selected parts => does not reset fields") + + test.todo("previously saved parts do not match selected parts => resets necessary fields") + }) + + describe("saveMoldingQuestionAnswers", () => { + test.todo("saves moldingQuestionAnswers") + + test.todo("there are no previous answers => resets necessary fields") + + // mix up the order to make sure sort is working + test.todo("previous answers match current answers => does not reset fields") + + test.todo("previous answers does not match current answers => resets necessary fields") + }) + + describe("saveCapabilityQuestionAnswers", () => { + test.todo("saves capabilityQuestionAnswers") + + test.todo("there are no previous answers => resets necessary fields") + + // mix up the order to make sure sort is working + test.todo("previous answers match current answers => does not reset fields") + + test.todo("previous answers does not match current answers => resets necessary fields") + }) }); From 756a6e3ce9fcd93aad64b4ffdadaaee0b2f5054e Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 30 Aug 2022 16:06:07 -0400 Subject: [PATCH 2/5] CSR-111 Add resetting logic for molding-questions --- src/layouts/molding-questions/molding-questions.vue | 6 +++--- src/store/index.js | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index ed7e54307..91dcf5e40 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -118,7 +118,7 @@ export default { return moldingQuestionsFromPageData && Object.keys(moldingQuestionsFromPageData).length > 0; }, showThisQuestionChain(glass, i) { - if (glass.questions?.length < 1 || glass.isSuppressedPart) { return false; } // return false if no questions or if suppressed + if (!glass.questions || glass.questions?.length < 1 || glass.isSuppressedPart) { return false; } // return false if no questions or if suppressed return this.currentGlassIndex === i || glass.answerData?.answerResult?.length > 0; }, async forwardButtonAction() { @@ -137,7 +137,7 @@ export default { glass.answerData = {}; }); - // save to vuex store as order.damage.partQuestionAnswers (array) + // save to vuex store as order.damage.moldingQuestionArrays (array) await this.dispatchStoreAction(this.storeActions.SAVE_MOLDING_QUESTION_ANSWERS, questionAnswersArray, false); // get parts from the questionAnswers @@ -460,7 +460,7 @@ export default { // add answerData to current glass glass.answerData = { - answerResult: savedPart.result, + answerResult: savedPart.partNum, answeredQuestions: savedPart.answeredQuestions } } diff --git a/src/store/index.js b/src/store/index.js index 1b2c1dbcd..e82b02251 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1040,15 +1040,10 @@ export const actions = { }, saveMoldingQuestionAnswers(context, moldingQuestionAnswers) { const previousResultsArray = context.getters.damage.moldingQuestionAnswers; - // TODO NOT ACCURATE!! answerData/answerQuestions keeps changing, partNum is undefined a lot const haveMoldingQuestionAnswersChanged = previousResultsArray?.length !== moldingQuestionAnswers.length || - !previousResultsArray.every((x, i) => - x.answeredQuestions && - x.answeredQuestions.length === moldingQuestionAnswers[i].answeredQuestions?.length && - x.answeredQuestions.every((y, j) => y.selectedAnswerText === moldingQuestionAnswers[i].answeredQuestions[j].selectedAnswerText)); + !previousResultsArray.every((x, i) => x.partNum === moldingQuestionAnswers[i].partNum); if (haveMoldingQuestionAnswersChanged) { - // TODO reset glass parts context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null); context.commit(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null }); From 474df4dea4942067aad32f0592c7c555fe29aa20 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 31 Aug 2022 09:38:13 -0400 Subject: [PATCH 3/5] CSR-111 Fix vehicle-parts issue --- src/store/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index e82b02251..e7db95ee2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -225,7 +225,7 @@ export const mutations = { }, // applicationUser MUTATIONS - updateSaveOrderPromise(state, saveOrderPromise){ + updateSaveOrderPromise(state, saveOrderPromise) { state.applicationUser.saveOrderPromise = saveOrderPromise; }, updateSavedSessionId(state, savedSessionId) { @@ -392,7 +392,7 @@ export const getters = { parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, orderPartNumbers: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")], - orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], + orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], hasRecalibrationPart: getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "requiresRecalibration")?.length > 0, selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, selectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), @@ -760,7 +760,7 @@ export const actions = { const part = pageData.partsOrQuestions.find(x => x.glassLocation === glassLocation).parts[0]; const capabilityQuestionAnswers = context.getters.damage.capabilityQuestionAnswers; const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(x => x.glassLocation === glassLocation); - + return globalMethods.callHttpClient({ method: endpoints.GetPartFromCapabilityAnswer.method, endpoint: endpoints.GetPartFromCapabilityAnswer.url, @@ -1022,7 +1022,9 @@ export const actions = { const previousResultsArray = [{ parts: context.getters.lineItems.glassParts }]; function getAllPartNumbers(partsOrQuestions) { - return [...partsOrQuestions].map(glass => glass.parts).flat().map(part => part.partNumber).filter(partNumber => !partNumber.toUpperCase().includes("FEE")).sort().join(","); + return partsOrQuestions[0].parts + ? [...partsOrQuestions].map(glass => glass.parts).flat().map(part => part.partNumber).filter(partNumber => !partNumber.toUpperCase().includes("FEE")).sort().join(",") + : [] } const previouslySelectedPartNumbers = getAllPartNumbers(previousResultsArray); @@ -1041,7 +1043,7 @@ export const actions = { saveMoldingQuestionAnswers(context, moldingQuestionAnswers) { const previousResultsArray = context.getters.damage.moldingQuestionAnswers; const haveMoldingQuestionAnswersChanged = previousResultsArray?.length !== moldingQuestionAnswers.length || - !previousResultsArray.every((x, i) => x.partNum === moldingQuestionAnswers[i].partNum); + !previousResultsArray.every((x, i) => x.partNum === moldingQuestionAnswers[i].partNum); if (haveMoldingQuestionAnswersChanged) { context.commit(storeMutations.UPDATE_GLASS_PARTS, null); From e10c585abe749d2c925006a87d9c551893af6193 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 31 Aug 2022 11:02:25 -0400 Subject: [PATCH 4/5] CSR-111 Use pageData instead of glassParts to check if vehicle-parts selections have changed --- src/mixins/vehicle-questions-mixin.js | 2 +- src/store/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 06776174f..616c1fb5e 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -122,7 +122,7 @@ export default { } }, backButtonAction() { - const partsOrQuestions = this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions; + const partsOrQuestions = (this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS) ?? this.$store.getters.pageData(fmgPageValues.VEHICLE_PARTS))?.partsOrQuestions; const hasPartQuestions = this.hasPartQuestions(partsOrQuestions); const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(partsOrQuestions); const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions); diff --git a/src/store/index.js b/src/store/index.js index e7db95ee2..cfb5e1dff 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1020,14 +1020,15 @@ export const actions = { }, resetMoldingAndCapabilityQuestionAnswersIfNeeded(context, matchedParts) { const previousResultsArray = [{ parts: context.getters.lineItems.glassParts }]; - + const partsOrQuestionsDataToCompareWith = context.getters.pageData(fmgPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ?? context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ?? []; + function getAllPartNumbers(partsOrQuestions) { return partsOrQuestions[0].parts ? [...partsOrQuestions].map(glass => glass.parts).flat().map(part => part.partNumber).filter(partNumber => !partNumber.toUpperCase().includes("FEE")).sort().join(",") : [] } - const previouslySelectedPartNumbers = getAllPartNumbers(previousResultsArray); + const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith); const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts); const haveSelectedVehiclePartsChanged = previouslySelectedPartNumbers !== currentlySelectedPartNumbers; From 1e0726af644e35df19a0576f69a3bedc9f25ecba Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 31 Aug 2022 11:07:50 -0400 Subject: [PATCH 5/5] CSR-111 Leave note for testing --- src/store/store.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 66def95e6..cec370042 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1169,6 +1169,7 @@ describe("Actions", () => { describe("resetMoldingAndCapabilityQuestionAnswersIfNeeded", () => { test.todo("there are no saved parts => resets necessary fields") + // make sure you check the different variations where molding-questions and capability-questions do or don't have pageData // mix up the order to make sure sort is working test.todo("previously saved parts match selected parts => does not reset fields")