Merge pull request #782 from Safelite/bug/kbrown/SSR-1256

Updating QuestionData answer to match Question answer during deletion
This commit is contained in:
kirkland-brown 2024-07-19 09:09:45 -04:00 committed by GitHub
commit f7c32ef8d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 82 additions and 0 deletions

View file

@ -118,6 +118,14 @@ export default {
}
});
// remove any disabled dependent answers
const answerQuestionNums = new Set(alreadyAnsweredQuestions[alreadyAnsweredQuestions.length-1].answeredQuestions.map(q => q.questionNum));
glass.questions.forEach(q => {
if(!answerQuestionNums.has(q.questionSequence)) {
delete q.answerSelected
}
});
// advance the currentGlassIndex
self.currentGlassIndex = index;

View file

@ -445,6 +445,80 @@ describe('vehicle-questions-mixin', () => {
expect(returnedGlass.answerData).toMatchObject({ answerResult: 'WKT D1106 C' });
});
});
describe('if alreadyAnsweredQuestions and dependent question has been disabled', () => {
test('should return glass with the answerSelected of partQuestions and questions reflecting the answerData (previous context is being updated to reflect answerData)', async () => {
// Arrange
const glass = {
glassName: 'Single',
glassLocation: 'Windshield',
questions: [
{
questionSequence: 1,
questionText:
'Is your vehicle equipped with leather seats?',
answers: [
{
answerResult: 'FW02334',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '',
answerText: 'No',
nextQuestionSequence: 2
}
]
},
{
questionSequence: 2,
questionText:
'Is your vehicle equipped with heated seats?',
answers: [
{
answerResult: 'FW02334',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: 'FW02333',
answerText: 'No',
nextQuestionSequence: null
}
]
}
]
};
const i = 0;
const alreadyAnsweredQuestions = [
{
glassLocation: 'Windshield',
glassName: 'Single',
partNum: 'FW02334',
answeredQuestions: [
{
questionText:
'Is your vehicle equipped with leather seats?',
selectedAnswerText: 'Yes',
questionNum: 1
}
]
}
];
const { wrapper } = setupMocks({});
// Act
const returnedGlass = await wrapper.vm.setupInitialData(
glass,
i,
alreadyAnsweredQuestions
);
// Assert
expect(returnedGlass.questions[0].answerSelected).toEqual('1|answer|FW02334|Yes');
expect(returnedGlass.questions[1].answerSelected).toBeUndefined();
});
});
});
describe('handleAnswerUpdates', () => {