From 8fcd2c7f527f6354e3dc1dfe27b1b55fe365779c Mon Sep 17 00:00:00 2001 From: Minojhini Valaiyapathi Date: Thu, 9 Jul 2026 14:45:27 -0400 Subject: [PATCH] CASH-2981 - Added ProblemQuestionId --- .../question-chain/question-chain.spec.js | 62 ++++++++-- .../question-chain/question-chain.vue | 23 ++++ .../part-questions/part-questions.spec.js | 1 + src/layouts/part-questions/part-questions.vue | 1 + src/mixins/vehicle-questions-mixin.js | 4 + src/store/index.js | 10 +- src/store/store.spec.js | 111 ++++++++++++++++++ 7 files changed, 198 insertions(+), 14 deletions(-) diff --git a/src/digital-components/question-chain/question-chain.spec.js b/src/digital-components/question-chain/question-chain.spec.js index d516afc03..7435feefd 100644 --- a/src/digital-components/question-chain/question-chain.spec.js +++ b/src/digital-components/question-chain/question-chain.spec.js @@ -244,10 +244,8 @@ describe("Question Chain component", () => { test("should return answer object if returnedAnswer is a final matching answer", async () => { //Arrange - const { wrapper } = setupMocks({}); - const testReturnedAnswer = "1|answer|DB10840|No"; - await wrapper.setData({ - questions: [ + const { wrapper } = setupMocks({ + questionDataProp: [ { questionSequence: 1, questionText: "Question here?", @@ -256,17 +254,21 @@ describe("Question Chain component", () => { answerResult: "DB09410", answerText: "Yes", nextQuestionSequence: null, + problemQuestionId: 9529, }, { answerResult: "DB10840", answerText: "No", nextQuestionSequence: null, + problemQuestionId: 9531, }, ], }, ], }); + const testReturnedAnswer = "1|answer|DB10840|No"; await wrapper.setProps({ index: 0 }); + await nextTick(); //Act const result = wrapper.vm.getQuestionChainAnswerIfComplete(testReturnedAnswer); @@ -274,16 +276,52 @@ describe("Question Chain component", () => { //Assert expect(result).toMatchObject({ answerResult: "DB10840", - answeredQuestions: [ - { questionNum: 1, questionText: "Question here?", selectedAnswerText: "No" }, - { - questionNum: 1, - questionText: "Does only your center sliding piece need to be replaced?", - selectedAnswerText: "No", - }, - ], + problemQuestionId: 9531, index: 0, }); + expect(result.answeredQuestions).toEqual([ + { + questionText: "Question here?", + selectedAnswer: "1|answer|DB10840|No", + selectedAnswerText: "No", + questionNum: 1, + problemQuestionId: 9531, + }, + ]); + }); + + test("should include problemQuestionId from parts-or-questions answer on created", async () => { + //Arrange + const { wrapper } = setupMocks({ + questionDataProp: [ + { + questionSequence: 1, + questionText: + "Does the rubber seal around your windshield have a chrome strip running through it?", + answers: [ + { + answerResult: "WCR 848", + answerText: "Yes", + nextQuestionSequence: null, + problemQuestionId: 9531, + }, + { + answerResult: "WCR 848", + answerText: "No", + nextQuestionSequence: null, + problemQuestionId: 9529, + }, + ], + }, + ], + }); + + //Act + await nextTick(); + + //Assert + expect(wrapper.vm.questions[0].answers[0].problemQuestionId).toBe(9531); + expect(wrapper.vm.questions[0].answers[1].problemQuestionId).toBe(9529); }); }); }); diff --git a/src/digital-components/question-chain/question-chain.vue b/src/digital-components/question-chain/question-chain.vue index 18b123aae..b1960eb51 100644 --- a/src/digital-components/question-chain/question-chain.vue +++ b/src/digital-components/question-chain/question-chain.vue @@ -60,6 +60,7 @@ export default { : q.questionSequence + "|answer|" + a.answerResult + "|" + a.answerText, nextQuestionSequence: a.nextQuestionSequence, answerResult: a.answerResult, + problemQuestionId: a.problemQuestionId, questionSequence: q.questionSequence, questionType: a.nextQuestionSequence ? "nextQuestion" : "answer", }; @@ -81,6 +82,17 @@ export default { } }, methods: { + getProblemQuestionIdFromSelectedAnswer(question, selectedAnswer) { + if (!question?.answers || !selectedAnswer) { + return null; + } + + const matchedAnswer = question.answers.find( + (answer) => answer.value === selectedAnswer + ); + + return matchedAnswer?.problemQuestionId ?? null; + }, handleAnswer(question, returnedAnswer) { /* returnedAnswer example format: @@ -126,6 +138,10 @@ export default { selectedAnswer: q.answerSelected, selectedAnswerText: q.answerSelected.split("|")[3], questionNum: q.questionSequence, + problemQuestionId: this.getProblemQuestionIdFromSelectedAnswer( + q, + q.answerSelected + ), }); } }); @@ -144,10 +160,17 @@ export default { } else { // reset current question index (removes .current-question class) this.currentQuestionNum = 0; // reset count + const answeredQuestion = this.questions.find( + (q) => q.questionSequence === questionNum + ); // return an object with the part answer, all the answered questions, and the part index return { answerResult: questionAnswer, + problemQuestionId: this.getProblemQuestionIdFromSelectedAnswer( + answeredQuestion, + returnedAnswer + ), answeredQuestions: answeredQuestions, index: this.index, }; diff --git a/src/layouts/part-questions/part-questions.spec.js b/src/layouts/part-questions/part-questions.spec.js index 4dcbb669c..4e7cb53dd 100644 --- a/src/layouts/part-questions/part-questions.spec.js +++ b/src/layouts/part-questions/part-questions.spec.js @@ -320,6 +320,7 @@ describe("partQuestions.vue...", () => { glassName: "Single", isSuppressedPart: undefined, result: "FW04848", + problemQuestionId: null, }, ], false diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 958a38095..1c342543f 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -176,6 +176,7 @@ export default { glassLocation: glass.glassLocation, glassName: glass.glassName, result: (glass.answerData && glass.answerData.answerResult) || "", + problemQuestionId: glass.answerData?.problemQuestionId ?? null, answeredQuestions: glass.answerData?.answeredQuestions, isSuppressedPart: glass.isSuppressedPart, }; diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 2f64df7b0..1636f0c47 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -141,6 +141,7 @@ export default { // add answerData to current glass glass.answerData = { answerResult: answerResult, + problemQuestionId: answeredGlass.problemQuestionId ?? null, answeredQuestions: answeredGlass.answeredQuestions, }; } @@ -320,6 +321,7 @@ export default { questionText: question.questionText, selectedAnswerText: matchedAnswer.answerText, questionNum: question.questionSequence, + problemQuestionId: matchedAnswer.problemQuestionId ?? null, suppressThisQuestion: question.suppressThisQuestion, }; // set the answerData (used as indicator that it has been already answered) @@ -327,6 +329,7 @@ export default { answerResult: matchedAnswer.nextQuestionSequence ? matchedAnswer.nextQuestionSequence : matchedAnswer.answerResult, + problemQuestionId: matchedAnswer.problemQuestionId ?? null, answeredQuestions: [answeredQuestionObj], }; @@ -346,6 +349,7 @@ export default { // set final answer data for the current answered glass part self.questionsData[answer.index].answerData = { answerResult: answer.answerResult, + problemQuestionId: answer.problemQuestionId ?? null, answeredQuestions: answer.answeredQuestions, }; diff --git a/src/store/index.js b/src/store/index.js index 2fff59ee3..d913ddb06 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4317,11 +4317,17 @@ function convertResultsForApi(resultsArray) { if (!resultsArray) return []; const converted = []; resultsArray.forEach((answer) => { - converted.push({ + const convertedAnswer = { location: answer.glassLocation, name: answer.glassName, result: answer.result, - }); + }; + + if (answer.problemQuestionId != null) { + convertedAnswer.problemQuestionId = answer.problemQuestionId; + } + + converted.push(convertedAnswer); }); return converted; } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 1753ed621..2fae32003 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -4470,4 +4470,115 @@ describe("isVinOptionalVehicle", () => { expect(vinOptionalResult).toEqual(expectedVinSkip); } ); + + it("getParts action, should include problemQuestionId in answerResults payload", async () => { + const context = { + getters: { + vehicle: { carId: "CR00065283", vin: "SAJWA6A73F8K13235" }, + damage: { + glassToReplace: [{ glassLocation: "Windshield", glassName: "Single" }], + partQuestionAnswers: [ + { + glassLocation: "Windshield", + glassName: "Single", + result: "FW04848", + problemQuestionId: 38560, + answeredQuestions: [ + { + questionText: + "Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?", + selectedAnswer: "1|nextQuestion|2|Yes", + selectedAnswerText: "Yes", + questionNum: 1, + problemQuestionId: 38557, + }, + { + questionText: + "Is your vehicle equipped with a heated windshield that melts snow and ice from underneath the windshield wiper blades?", + selectedAnswer: "2|answer|FW04848|Yes", + selectedAnswerText: "Yes", + questionNum: 2, + problemQuestionId: 38560, + }, + ], + }, + ], + }, + payment: { parentAccountNumber: "167132" }, + }, + state: { + order: { + serviceLocation: { zipCode: "43085", appointmentType: null }, + referralSequenceNumber: "11330779", + }, + }, + }; + + globalMethods.callHttpClient.mockImplementation(({ payload }) => { + return Promise.resolve({ data: { glassPieceParts: [] }, payload }); + }); + + await actions.getParts(context, { pageNameToLog: "part-questions" }); + + expect(globalMethods.callHttpClient).toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: endpoints.GetParts.url, + payload: expect.objectContaining({ + answerResults: [ + { + location: "Windshield", + name: "Single", + result: "FW04848", + problemQuestionId: 38560, + }, + ], + }), + }) + ); + }); + + it("getParts action, should omit problemQuestionId when not saved on part question answer", async () => { + const context = { + getters: { + vehicle: { carId: "CR00065283", vin: "SAJWA6A73F8K13235" }, + damage: { + glassToReplace: [{ glassLocation: "Windshield", glassName: "Single" }], + partQuestionAnswers: [ + { + glassLocation: "Windshield", + glassName: "Single", + result: "FW04848", + }, + ], + }, + payment: { parentAccountNumber: "167132" }, + }, + state: { + order: { + serviceLocation: { zipCode: "43085", appointmentType: null }, + referralSequenceNumber: "11330779", + }, + }, + }; + + globalMethods.callHttpClient.mockImplementation(() => { + return Promise.resolve({ data: { glassPieceParts: [] } }); + }); + + await actions.getParts(context, { pageNameToLog: "part-questions" }); + + expect(globalMethods.callHttpClient).toHaveBeenCalledWith( + expect.objectContaining({ + payload: expect.objectContaining({ + answerResults: [ + { + location: "Windshield", + name: "Single", + result: "FW04848", + }, + ], + }), + }) + ); + }); });