Merge pull request #1684 from Safelite/feature/CSR-1610-bugfix-ajc
CSR-1610: copy fix updates into other question pages
This commit is contained in:
commit
0e640cdc92
5 changed files with 80 additions and 7 deletions
|
|
@ -5,11 +5,13 @@
|
|||
:isMetaValid="meta.valid"
|
||||
:alertFewMoreQuestionsHeader="AlertFewMoreQuestionsHeader"
|
||||
:alertFewMoreQuestionsCopy="AlertFewMoreQuestionsCopy"
|
||||
v-if="questionsData"
|
||||
:questionsData="questionsData"
|
||||
validationRules="questions-required"
|
||||
v-model="selectedAnswers"
|
||||
@forwardButtonAction="forwardButtonAction"
|
||||
@back-click="navigateBack"
|
||||
:key="currentGlassIndex"
|
||||
:index="currentGlassIndex" />
|
||||
</Form>
|
||||
</template>
|
||||
|
|
@ -55,7 +57,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
questionsData: [],
|
||||
questionsData: null,
|
||||
selectedAnswers: {},
|
||||
currentGlassIndex: 0,
|
||||
};
|
||||
|
|
@ -120,6 +122,12 @@ export default {
|
|||
|
||||
return updatedGlass;
|
||||
});
|
||||
|
||||
// if no preanswered questions then make sure index starts with the correct value
|
||||
this.currentGlassIndex = this.calculateQuestionIndex(
|
||||
this.currentGlassIndex,
|
||||
this.questionsData
|
||||
);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.questionsData.map((glass) => {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@
|
|||
:isMetaValid="meta.valid"
|
||||
:alertFewMoreQuestionsHeader="AlertFewMoreQuestionsHeader"
|
||||
:alertFewMoreQuestionsCopy="AlertFewMoreQuestionsCopy"
|
||||
v-if="questionsData"
|
||||
:questionsData="questionsData"
|
||||
validationRules="questions-required"
|
||||
v-model="selectedAnswers"
|
||||
@forwardButtonAction="forwardButtonAction"
|
||||
@back-click="navigateBack"
|
||||
:key="currentGlassIndex"
|
||||
:index="currentGlassIndex" />
|
||||
</Form>
|
||||
</template>
|
||||
|
|
@ -55,7 +57,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
questionsData: [],
|
||||
questionsData: null,
|
||||
selectedAnswers: {},
|
||||
currentGlassIndex: 0,
|
||||
};
|
||||
|
|
@ -119,6 +121,12 @@ export default {
|
|||
|
||||
return updatedGlass;
|
||||
});
|
||||
|
||||
// if no preanswered questions then make sure index starts with the correct value
|
||||
this.currentGlassIndex = this.calculateQuestionIndex(
|
||||
this.currentGlassIndex,
|
||||
this.questionsData
|
||||
);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.questionsData.map((glass) => {
|
||||
|
|
|
|||
|
|
@ -121,11 +121,10 @@ export default {
|
|||
});
|
||||
|
||||
// if no preanswered questions then make sure index starts with the correct value
|
||||
if (this.currentGlassIndex === 0) {
|
||||
this.currentGlassIndex = this.questionsData?.findIndex(
|
||||
(glass) => glass.questions?.length > 0
|
||||
);
|
||||
}
|
||||
this.currentGlassIndex = this.calculateQuestionIndex(
|
||||
this.currentGlassIndex,
|
||||
this.questionsData
|
||||
);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.questionsData.map((glass) => {
|
||||
|
|
|
|||
|
|
@ -146,6 +146,13 @@ export default {
|
|||
|
||||
return glass;
|
||||
},
|
||||
calculateQuestionIndex(currentGlassIndex, questionsData) {
|
||||
// if no preanswered questions then make sure index starts with the correct value
|
||||
if (currentGlassIndex === 0) {
|
||||
return questionsData?.findIndex((glass) => glass.questions?.length > 0);
|
||||
}
|
||||
return currentGlassIndex;
|
||||
},
|
||||
handleCompletedQuestionChainAnswers(answer, glassKey, vm) {
|
||||
// only runs when all questions in a question-chain have been answered
|
||||
// when selectedAnswers updates, user has completed this part's question chain and has a final answer
|
||||
|
|
|
|||
|
|
@ -411,6 +411,57 @@ describe("vehicle-questions-mixin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("calculateQuestionIndex", () => {
|
||||
describe("if currentGlassIndex is zero...", () => {
|
||||
test("should return index of first glass piece with questions", () => {
|
||||
// Arrange
|
||||
const questionsData = [
|
||||
{
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
},
|
||||
{
|
||||
glassName: "Front",
|
||||
glassLocation: "Driver",
|
||||
questions: ["example question"],
|
||||
},
|
||||
];
|
||||
const glassIndex = 0;
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// Act
|
||||
const returnedIndex = wrapper.vm.calculateQuestionIndex(glassIndex, questionsData);
|
||||
|
||||
// Assert
|
||||
expect(returnedIndex).toBe(1);
|
||||
});
|
||||
});
|
||||
describe("if currentGlassIndex is NOT zero...", () => {
|
||||
test("should return currentGlassIndex value", () => {
|
||||
// Arrange
|
||||
const questionsData = [
|
||||
{
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
},
|
||||
{
|
||||
glassName: "Front",
|
||||
glassLocation: "Driver",
|
||||
questions: ["example question"],
|
||||
},
|
||||
];
|
||||
const glassIndex = 1;
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// Act
|
||||
const returnedIndex = wrapper.vm.calculateQuestionIndex(glassIndex, questionsData);
|
||||
|
||||
// Assert
|
||||
expect(returnedIndex).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleCompletedQuestionChainAnswers", () => {
|
||||
describe("selectedAnswers", () => {
|
||||
test("should be cleared to be empty", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue