Merge pull request #3257 from Safelite/feature/CASH-2981
CASH-2981 - Added ProblemQuestionId
This commit is contained in:
commit
202d16ba35
7 changed files with 198 additions and 14 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -320,6 +320,7 @@ describe("partQuestions.vue...", () => {
|
|||
glassName: "Single",
|
||||
isSuppressedPart: undefined,
|
||||
result: "FW04848",
|
||||
problemQuestionId: null,
|
||||
},
|
||||
],
|
||||
false
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue