Merge pull request #3257 from Safelite/feature/CASH-2981

CASH-2981 - Added ProblemQuestionId
This commit is contained in:
mvalaiyapathi 2026-07-09 15:02:18 -04:00 committed by GitHub
commit 202d16ba35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 198 additions and 14 deletions

View file

@ -244,10 +244,8 @@ describe("Question Chain component", () => {
test("should return answer object if returnedAnswer is a final matching answer", async () => { test("should return answer object if returnedAnswer is a final matching answer", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({
const testReturnedAnswer = "1|answer|DB10840|No"; questionDataProp: [
await wrapper.setData({
questions: [
{ {
questionSequence: 1, questionSequence: 1,
questionText: "Question here?", questionText: "Question here?",
@ -256,17 +254,21 @@ describe("Question Chain component", () => {
answerResult: "DB09410", answerResult: "DB09410",
answerText: "Yes", answerText: "Yes",
nextQuestionSequence: null, nextQuestionSequence: null,
problemQuestionId: 9529,
}, },
{ {
answerResult: "DB10840", answerResult: "DB10840",
answerText: "No", answerText: "No",
nextQuestionSequence: null, nextQuestionSequence: null,
problemQuestionId: 9531,
}, },
], ],
}, },
], ],
}); });
const testReturnedAnswer = "1|answer|DB10840|No";
await wrapper.setProps({ index: 0 }); await wrapper.setProps({ index: 0 });
await nextTick();
//Act //Act
const result = wrapper.vm.getQuestionChainAnswerIfComplete(testReturnedAnswer); const result = wrapper.vm.getQuestionChainAnswerIfComplete(testReturnedAnswer);
@ -274,16 +276,52 @@ describe("Question Chain component", () => {
//Assert //Assert
expect(result).toMatchObject({ expect(result).toMatchObject({
answerResult: "DB10840", answerResult: "DB10840",
answeredQuestions: [ problemQuestionId: 9531,
{ questionNum: 1, questionText: "Question here?", selectedAnswerText: "No" },
{
questionNum: 1,
questionText: "Does only your center sliding piece need to be replaced?",
selectedAnswerText: "No",
},
],
index: 0, 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);
}); });
}); });
}); });

View file

@ -60,6 +60,7 @@ export default {
: q.questionSequence + "|answer|" + a.answerResult + "|" + a.answerText, : q.questionSequence + "|answer|" + a.answerResult + "|" + a.answerText,
nextQuestionSequence: a.nextQuestionSequence, nextQuestionSequence: a.nextQuestionSequence,
answerResult: a.answerResult, answerResult: a.answerResult,
problemQuestionId: a.problemQuestionId,
questionSequence: q.questionSequence, questionSequence: q.questionSequence,
questionType: a.nextQuestionSequence ? "nextQuestion" : "answer", questionType: a.nextQuestionSequence ? "nextQuestion" : "answer",
}; };
@ -81,6 +82,17 @@ export default {
} }
}, },
methods: { 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) { handleAnswer(question, returnedAnswer) {
/* /*
returnedAnswer example format: returnedAnswer example format:
@ -126,6 +138,10 @@ export default {
selectedAnswer: q.answerSelected, selectedAnswer: q.answerSelected,
selectedAnswerText: q.answerSelected.split("|")[3], selectedAnswerText: q.answerSelected.split("|")[3],
questionNum: q.questionSequence, questionNum: q.questionSequence,
problemQuestionId: this.getProblemQuestionIdFromSelectedAnswer(
q,
q.answerSelected
),
}); });
} }
}); });
@ -144,10 +160,17 @@ export default {
} else { } else {
// reset current question index (removes .current-question class) // reset current question index (removes .current-question class)
this.currentQuestionNum = 0; // reset count 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 an object with the part answer, all the answered questions, and the part index
return { return {
answerResult: questionAnswer, answerResult: questionAnswer,
problemQuestionId: this.getProblemQuestionIdFromSelectedAnswer(
answeredQuestion,
returnedAnswer
),
answeredQuestions: answeredQuestions, answeredQuestions: answeredQuestions,
index: this.index, index: this.index,
}; };

View file

@ -320,6 +320,7 @@ describe("partQuestions.vue...", () => {
glassName: "Single", glassName: "Single",
isSuppressedPart: undefined, isSuppressedPart: undefined,
result: "FW04848", result: "FW04848",
problemQuestionId: null,
}, },
], ],
false false

View file

@ -176,6 +176,7 @@ export default {
glassLocation: glass.glassLocation, glassLocation: glass.glassLocation,
glassName: glass.glassName, glassName: glass.glassName,
result: (glass.answerData && glass.answerData.answerResult) || "", result: (glass.answerData && glass.answerData.answerResult) || "",
problemQuestionId: glass.answerData?.problemQuestionId ?? null,
answeredQuestions: glass.answerData?.answeredQuestions, answeredQuestions: glass.answerData?.answeredQuestions,
isSuppressedPart: glass.isSuppressedPart, isSuppressedPart: glass.isSuppressedPart,
}; };

View file

@ -141,6 +141,7 @@ export default {
// add answerData to current glass // add answerData to current glass
glass.answerData = { glass.answerData = {
answerResult: answerResult, answerResult: answerResult,
problemQuestionId: answeredGlass.problemQuestionId ?? null,
answeredQuestions: answeredGlass.answeredQuestions, answeredQuestions: answeredGlass.answeredQuestions,
}; };
} }
@ -320,6 +321,7 @@ export default {
questionText: question.questionText, questionText: question.questionText,
selectedAnswerText: matchedAnswer.answerText, selectedAnswerText: matchedAnswer.answerText,
questionNum: question.questionSequence, questionNum: question.questionSequence,
problemQuestionId: matchedAnswer.problemQuestionId ?? null,
suppressThisQuestion: question.suppressThisQuestion, suppressThisQuestion: question.suppressThisQuestion,
}; };
// set the answerData (used as indicator that it has been already answered) // set the answerData (used as indicator that it has been already answered)
@ -327,6 +329,7 @@ export default {
answerResult: matchedAnswer.nextQuestionSequence answerResult: matchedAnswer.nextQuestionSequence
? matchedAnswer.nextQuestionSequence ? matchedAnswer.nextQuestionSequence
: matchedAnswer.answerResult, : matchedAnswer.answerResult,
problemQuestionId: matchedAnswer.problemQuestionId ?? null,
answeredQuestions: [answeredQuestionObj], answeredQuestions: [answeredQuestionObj],
}; };
@ -346,6 +349,7 @@ export default {
// set final answer data for the current answered glass part // set final answer data for the current answered glass part
self.questionsData[answer.index].answerData = { self.questionsData[answer.index].answerData = {
answerResult: answer.answerResult, answerResult: answer.answerResult,
problemQuestionId: answer.problemQuestionId ?? null,
answeredQuestions: answer.answeredQuestions, answeredQuestions: answer.answeredQuestions,
}; };

View file

@ -4317,11 +4317,17 @@ function convertResultsForApi(resultsArray) {
if (!resultsArray) return []; if (!resultsArray) return [];
const converted = []; const converted = [];
resultsArray.forEach((answer) => { resultsArray.forEach((answer) => {
converted.push({ const convertedAnswer = {
location: answer.glassLocation, location: answer.glassLocation,
name: answer.glassName, name: answer.glassName,
result: answer.result, result: answer.result,
}); };
if (answer.problemQuestionId != null) {
convertedAnswer.problemQuestionId = answer.problemQuestionId;
}
converted.push(convertedAnswer);
}); });
return converted; return converted;
} }

View file

@ -4470,4 +4470,115 @@ describe("isVinOptionalVehicle", () => {
expect(vinOptionalResult).toEqual(expectedVinSkip); 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",
},
],
}),
})
);
});
}); });