CSR-803: updates for part-questions
This commit is contained in:
parent
cb151e0e57
commit
d73ddf0b46
4 changed files with 15 additions and 13 deletions
|
|
@ -100,7 +100,7 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example returnedAnswers:
|
// returnedAnswer examples:
|
||||||
// "1|nextQuestion|3|No"
|
// "1|nextQuestion|3|No"
|
||||||
// "5|answer|DW02104|Yes"
|
// "5|answer|DW02104|Yes"
|
||||||
|
|
||||||
|
|
@ -108,15 +108,12 @@ export default {
|
||||||
const questionNum = parseInt(returnedAnswerArray[0]);
|
const questionNum = parseInt(returnedAnswerArray[0]);
|
||||||
const questionType = returnedAnswerArray[1];
|
const questionType = returnedAnswerArray[1];
|
||||||
const questionAnswer = returnedAnswerArray[2];
|
const questionAnswer = returnedAnswerArray[2];
|
||||||
const questionAnswerText = returnedAnswerArray[3];
|
|
||||||
const answeredQuestions = [];
|
const answeredQuestions = [];
|
||||||
|
|
||||||
this.questions.forEach((q) => {
|
this.questions.forEach((q) => {
|
||||||
// find this question and mark it as "answered" by populating answerSelected
|
// find this question and mark it as "answered" by populating answerSelected
|
||||||
if (q.questionSequence === questionNum) {
|
if (q.questionSequence === questionNum) {
|
||||||
q.answerSelected = returnedAnswer;
|
q.answerSelected = returnedAnswer;
|
||||||
q.answerNumber = questionNum;
|
|
||||||
q.selectedAnswerText = questionAnswerText;
|
|
||||||
}
|
}
|
||||||
// remove all answers AFTER this question...
|
// remove all answers AFTER this question...
|
||||||
// (needed in case user is changing previously answered questions)
|
// (needed in case user is changing previously answered questions)
|
||||||
|
|
@ -126,6 +123,7 @@ export default {
|
||||||
if (q.answerSelected) {
|
if (q.answerSelected) {
|
||||||
answeredQuestions.push({
|
answeredQuestions.push({
|
||||||
questionText: q.questionText,
|
questionText: q.questionText,
|
||||||
|
selectedAnswer: q.answerSelected,
|
||||||
selectedAnswerText: q.answerSelected.split("|")[3],
|
selectedAnswerText: q.answerSelected.split("|")[3],
|
||||||
questionNum: q.questionSequence,
|
questionNum: q.questionSequence,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -78,12 +78,14 @@ const baseStoreGettersDamage = () => {
|
||||||
{
|
{
|
||||||
questionText:
|
questionText:
|
||||||
"Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?",
|
"Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?",
|
||||||
|
selectedAnswer: "1|nextQuestion|3|Yes",
|
||||||
selectedAnswerText: "Yes",
|
selectedAnswerText: "Yes",
|
||||||
questionNum: 1,
|
questionNum: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
questionText:
|
questionText:
|
||||||
"Is your vehicle equipped with a heated windshield that melts snow and ice from underneath the windshield wiper blades?",
|
"Is your vehicle equipped with a heated windshield that melts snow and ice from underneath the windshield wiper blades?",
|
||||||
|
selectedAnswer: "1|nextQuestion|3|Yes",
|
||||||
selectedAnswerText: "Yes",
|
selectedAnswerText: "Yes",
|
||||||
questionNum: 2,
|
questionNum: 2,
|
||||||
},
|
},
|
||||||
|
|
@ -152,14 +154,14 @@ describe("partQuestions.vue...", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("watch on selectedAnswers should be set up...", () => {
|
describe("watch on selectedAnswers should be set up...", () => {
|
||||||
test("Should trigger handleAnswerUpdates if watched data changes", async () => {
|
test("Should trigger handleCompletedQuestionChainAnswers if watched data changes", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
store.getters = {
|
store.getters = {
|
||||||
pageData: baseStoreGettersPageData,
|
pageData: baseStoreGettersPageData,
|
||||||
damage: baseStoreGettersDamage,
|
damage: baseStoreGettersDamage,
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
const spy = jest.spyOn(wrapper.vm, "handleAnswerUpdates");
|
const spy = jest.spyOn(wrapper.vm, "handleCompletedQuestionChainAnswers");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
|
|
@ -169,11 +171,13 @@ describe("partQuestions.vue...", () => {
|
||||||
answeredQuestions: [
|
answeredQuestions: [
|
||||||
{
|
{
|
||||||
questionText: "One?",
|
questionText: "One?",
|
||||||
|
selectedAnswer: "1|nextQuestion|3|Yes",
|
||||||
selectedAnswerText: "Yes",
|
selectedAnswerText: "Yes",
|
||||||
questionNum: 1,
|
questionNum: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
questionText: "Two?",
|
questionText: "Two?",
|
||||||
|
selectedAnswer: "1|nextQuestion|3|Yes",
|
||||||
selectedAnswerText: "Yes",
|
selectedAnswerText: "Yes",
|
||||||
questionNum: 2,
|
questionNum: 2,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ export default {
|
||||||
"selectedAnswers." + glass.answerKey,
|
"selectedAnswers." + glass.answerKey,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (newValue && Object.keys(newValue).length > 0) {
|
if (newValue && Object.keys(newValue).length > 0) {
|
||||||
this.handleAnswerUpdates(newValue, glass.answerKey);
|
this.handleCompletedQuestionChainAnswers(newValue, glass.answerKey);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue