+
-
@@ -60,11 +60,19 @@ export default {
ul {
margin-bottom: 0;
}
+ p {
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
}
}
}
.modal-footer {
border-top: none;
+ button {
+ margin: 0;
+ }
}
}
}
diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue
index 0b5f45363..4eaa0b69e 100644
--- a/src/common-components/question-chain/question-chain.vue
+++ b/src/common-components/question-chain/question-chain.vue
@@ -72,7 +72,7 @@ export default {
this.currentQuestionNum = this.questions[0].questionSequence;
// scroll the next question into view
this.$nextTick(() => {
- document.querySelector('.current-question').scrollIntoView({behavior: "smooth"});
+ document.querySelector('.current-question')?.scrollIntoView({behavior: "smooth"});
})
}
},
diff --git a/src/common-components/text-block/text-block.spec.js b/src/common-components/text-block/text-block.spec.js
index 3d0843e10..138a0340b 100644
--- a/src/common-components/text-block/text-block.spec.js
+++ b/src/common-components/text-block/text-block.spec.js
@@ -1 +1,60 @@
-test.todo("some test to be written in the future");
+import { shallowMount } from "@vue/test-utils";
+import TextBlock from "./text-block";
+
+
+describe("modal.vue", () => {
+ it("Should display 'Text' when 'Text' is defined in the CMS", async () => {
+ // Act
+ const wrapper = shallowMount(TextBlock, {
+ mixins: [mockMixin]
+ });
+ expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent['Text']));
+ });
+
+ it("Should contain the typeStyle class as defined by the prop", async () => {
+ // Act
+ const wrapper = shallowMount(TextBlock, {
+ mixins: [mockMixin],
+ propsData: mockProps,
+ });
+ expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['typeStyle']));
+ });
+ it("Should contain the justifyText class as defined by the prop", async () => {
+ // Act
+ const wrapper = shallowMount(TextBlock, {
+ mixins: [mockMixin],
+ propsData: mockProps,
+ });
+ expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['justifyText']));
+ });
+ it("Should contain the fontWeight class as defined by the prop", async () => {
+ // Act
+ const wrapper = shallowMount(TextBlock, {
+ mixins: [mockMixin],
+ propsData: mockProps,
+ });
+ expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['fontWeight']));
+ });
+});
+
+ ///////////////
+ // Constants //
+ ///////////////
+
+const mockMixin = {
+ methods: {
+ getCmsContent: jest.fn((widgetName, cmsFieldName) => {
+ return mockCmsContent[cmsFieldName];
+ })
+ }
+}
+
+const mockProps = {
+ fontWeight: 'mockFontWeight',
+ typeStyle: 'mockTypeStyle',
+ justifyText: 'mockJustifyText'
+}
+
+const mockCmsContent = {
+ 'Text': "Sample text here.",
+}
diff --git a/src/constants/application-config.js b/src/constants/application-config.js
index f42a2c183..0e185cff4 100644
--- a/src/constants/application-config.js
+++ b/src/constants/application-config.js
@@ -7,6 +7,7 @@ const applicationConfig = {
COOKIE_PATH: "/",
CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT, // "Localhost", "Dev", "QA", and "Prod"
APPLICATION_NAME: "FixMyGlass",
+ APPLICATION_ABBREVIATION: "fmg",
SITE_ENTRY_TRIGGER_VALUE: "FixMyGlass"
};
diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js
index d0e05919b..7545f38b0 100644
--- a/src/constants/endpoints.js
+++ b/src/constants/endpoints.js
@@ -1,10 +1,14 @@
const endpoints = {
GetRouteInfo: {
- url: "/content/api/v1/content/RouteInfo",
+ url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/RouteInfo`,
method: "POST",
},
GetHomepageInfo: {
- url: "/content/api/v1/content/HomepageInfo",
+ url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`,
+ method: "GET",
+ },
+ GetPageData: {
+ url: (applicationAbbreviation, pageName) => `/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
method: "GET",
},
GetVehicleYears: {
@@ -31,10 +35,6 @@ const endpoints = {
url: "/parts/api/v1/parts/damage-options",
method: "GET",
},
- GetPageData: {
- url: "/content/api/v1/content",
- method: "GET",
- },
LookupVehicleByYmms: {
url: "/vehicle/api/v1/vehicle/Lookup",
method: "GET",
diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js
index 0630d8b65..9720598eb 100644
--- a/src/helpers/heritage-integration/navigation-helper.js
+++ b/src/helpers/heritage-integration/navigation-helper.js
@@ -50,6 +50,7 @@ export async function navigateToHeritageFunnel(shouldSaveOrder = true) {
{
corid: store.getters.order.referralCorrelationId,
src: "concept-funnel",
+ conceptsqid: store.getters.applicationUser.savedSessionId
}
);
}
diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue
index cdb38c58e..39b96c361 100644
--- a/src/layouts/capability-questions/capability-questions.vue
+++ b/src/layouts/capability-questions/capability-questions.vue
@@ -76,7 +76,6 @@ export default {
capabilityQuestionsData: store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS).partsOrQuestions,
selectedAnswers: {},
currentQuestionChainIndex: 0,
- foundDuplicateQuestions: [],
};
},
computed: {
@@ -97,7 +96,17 @@ export default {
}
},
mounted() {
- this.loadInitialCapabilityQuestionsData();
+ // are there alreadyAnsweredQuestions?
+ const alreadyAnsweredQuestions = store.getters.damage.capabilityQuestionAnswers;
+
+ this.capabilityQuestionsData = this.pageData.partsOrQuestions.filter(x => x.capabilityQuestions).map((glass, i) => {
+ // NOTE: questions for property "questions" can differ between layouts
+ glass.questions = glass.capabilityQuestions;
+ // reset selectedAnswers for this glass
+ this.selectedAnswers[glass.key] = [];
+ // pass in: glass, i, alreadyAnsweredQuestions
+ return this.setupInitialData(glass, i, alreadyAnsweredQuestions);
+ });
},
methods: {
showThisQuestionChain(glass, i) {
@@ -110,14 +119,13 @@ export default {
},
async forwardButtonAction() {
const capabilityQuestionsAnswersArray = this.capabilityQuestionsData.map((glass) => {
- const selectedAnswerResult1 = glass.answerData.answerResult;
- const selectedAnswerResult2 = glass.answerData.answerResult2;
+ const selectedAnswerResult2 = this.getCorrespondingAnswerResult2(glass.answerData.answerResult);
return {
glassLocation: glass.glassLocation,
glassName: glass.glassName,
result: glass.answerData.answerResult,
- result1: selectedAnswerResult1,
+ result1: glass.answerData.answerResult,
result2: selectedAnswerResult2,
answeredQuestions: glass.answerData.answeredQuestions,
isSuppressedPart: glass.isSuppressedPart,
@@ -147,7 +155,7 @@ export default {
// 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
// (does not get run for each invididual question's answer, only when
- // all relevent questions for the current part have been answered)
+ // all relevant questions for the current part have been answered)
/*
answer example format:
@@ -166,6 +174,7 @@ export default {
// collect a list of the answered questions' numbers, needed later below
const answeredQuestionIndexes = [];
+ const foundDuplicateQuestions = [];
// if user has answered a question differently than anything that was preloaded,
// we need to clear out any preloaded answers
@@ -255,7 +264,6 @@ export default {
// restore original answerResult
if (thisAns.originalAnswerResult) {
thisAns.answerResult = thisAns.originalAnswerResult;
- thisAns.answerResult1 = thisAns.originalAnswerResult;
thisAns.originalAnswerResult = null;
}
}
@@ -270,7 +278,6 @@ export default {
thisAns.nextQuestionSequence = null;
thisAns.originalAnswerResult = thisAns.originalAnswerResult || thisAns.answerResult;
thisAns.answerResult = matchedAnswer.answerResult;
- thisAns.answerResult1 = matchedAnswer.answerResult;
}
}
});
@@ -280,12 +287,12 @@ export default {
thisAnsweredCapabilityQuestion.suppressQuestion = true;
const thisGlassPart = "glass" + gpIndex;
- if (this.foundDuplicateQuestions[thisGlassPart]) {
- if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredCapabilityQuestion.questionSequence)) {
- this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredCapabilityQuestion.questionSequence);
+ if (foundDuplicateQuestions[thisGlassPart]) {
+ if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredCapabilityQuestion.questionSequence)) {
+ foundDuplicateQuestions[thisGlassPart].push(thisAnsweredCapabilityQuestion.questionSequence);
}
} else {
- this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredCapabilityQuestion.questionSequence];
+ foundDuplicateQuestions[thisGlassPart] = [thisAnsweredCapabilityQuestion.questionSequence];
}
// are there any questions left that are not suppressed?
@@ -306,7 +313,6 @@ export default {
// set the answerData as 'already answered'
glass.answerData = {
answerResult: matchedAnswer.nextQuestionSequence ? matchedAnswer.nextQuestionSequence : matchedAnswer.answerResult,
- answerResult1: matchedAnswer.nextQuestionSequence ? matchedAnswer.nextQuestionSequence : matchedAnswer.answerResult,
answeredQuestions: [answeredQuestionObj],
};
@@ -332,12 +338,12 @@ export default {
// EX answeredQuestionIndexes: [1,5,11,13]
- // EX this.foundDuplicateQuestions = {
+ // EX foundDuplicateQuestions = {
// "glassPart1": [1],
// "glassPart2": [7, 10]
// };
- const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex];
+ const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex];
const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : [];
const glassPartAnswered = this.capabilityQuestionsData[answer.glassIndex];
@@ -383,14 +389,9 @@ export default {
});
filteredCompleteAnsweredQuestions = filteredCompleteAnsweredQuestions.sort((a, b) => a.questionNum - b.questionNum);
- const selectedAnswerResult1 = answer.answerResult;
- const selectedAnswerResult2 = this.getCorrespondingAnswerResult2(selectedAnswerResult1);
-
// set final answer data for the current answered glass part
glassPartAnswered.answerData = {
- answerResult: selectedAnswerResult1,
- answerResult1: selectedAnswerResult1,
- answerResult2: selectedAnswerResult2,
+ answerResult: answer.answerResult,
answeredQuestions: filteredCompleteAnsweredQuestions,
}
@@ -412,73 +413,6 @@ export default {
.answers.find(answer => answer.answerResult == answerResult1)
.answerResult2;
},
- loadInitialCapabilityQuestionsData() {
- // are there alreadyAnsweredQuestions?
- const alreadyAnsweredQuestions = store.getters.damage.capabilityQuestionAnswers;
-
- this.capabilityQuestionsData = this.pageData.partsOrQuestions.filter(x => x.capabilityQuestions).map((glass, i) => {
- glass.key = glass.glassLocation + "-" + glass.glassName;
- this.selectedAnswers[glass.key] = [];
- if (!alreadyAnsweredQuestions) {
- glass.answerData = null;
- }
-
- alreadyAnsweredQuestions?.forEach((savedPart) => {
-
- if (!savedPart.glassLocation || !savedPart.glassName || !savedPart.answeredQuestions || !savedPart.result) {
- return;
- }
- if (glass.glassLocation === savedPart.glassLocation && glass.glassName === savedPart.glassName) {
- let answerString = "";
-
- // matches; loop through answeredQuestions for matches
- savedPart.answeredQuestions.forEach((aq) => {
- if (!aq.questionNum || !aq.selectedAnswerText) {
- return;
- }
- // determine which answer was previously chosen
- const theAns = glass.capabilityQuestions[aq.questionNum - 1].answers.find((a) => {
- return a.answerText.toUpperCase() === aq.selectedAnswerText.toUpperCase();
- });
- if (theAns.nextQuestionSequence) {
- answerString = `${aq.questionNum}|nextQuestion|${theAns.nextQuestionSequence}|${theAns.answerText}`
- } else {
- answerString = `${aq.questionNum}|answer|${theAns.answerResult}|${theAns.answerText}`
- }
-
- // mark this partQuestion as answered (question-chain will read this)
- glass.capabilityQuestions[aq.questionNum - 1].answerSelected = answerString;
- // mark this partQuestion as duplicate if it is (question-chain will read this)
- if (aq.suppressQuestion) {
- glass.capabilityQuestions[aq.questionNum - 1].suppressQuestion = true;
- }
- });
-
- // advance the currentQuestionChainIndex
- this.currentQuestionChainIndex = i;
-
- // add answerData to current glass
- glass.answerData = {
- answerResult: savedPart.result,
- answerResult1: savedPart.result,
- answerResult2: this.getCorrespondingAnswerResult2(savedPart.result),
- answeredQuestions: savedPart.answeredQuestions
- }
- }
-
- });
-
- // Set up watch for each set of glass questions, which gets updated when all questions for a glass have been answered
- this.$watch("selectedAnswers." + glass.key, (newValue) => {
- if (newValue) {
- this.handleAnswerUpdates(newValue);
- }
- }, { deep: true })
-
- return glass;
- });
-
- },
},
components: {
funnelHeader,
diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue
index 00e71c917..50cfe42c2 100644
--- a/src/layouts/molding-questions/molding-questions.vue
+++ b/src/layouts/molding-questions/molding-questions.vue
@@ -94,7 +94,6 @@ export default {
moldingQuestionsData: store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS).partsOrQuestions,
selectedAnswers: {},
currentGlassIndex: 0,
- foundDuplicateQuestions: [],
};
},
computed: {
@@ -109,7 +108,17 @@ export default {
}
},
mounted() {
- this.LoadInitialData();
+ // are there alreadyAnsweredQuestions?
+ const alreadyAnsweredQuestions = store.getters.damage.moldingQuestionAnswers;
+
+ this.moldingQuestionsData = this.pageData.partsOrQuestions.filter(x => x.parts[0].childPartQuestions.length).map((glass, i) => {
+ // NOTE: questions for property "questions" can differ between layouts
+ glass.questions = glass.parts[0].childPartQuestions;
+ // reset selectedAnswers for this glass
+ this.selectedAnswers[glass.key] = [];
+ // pass in: glass, i, alreadyAnsweredQuestions
+ return this.setupInitialData(glass, i, alreadyAnsweredQuestions);
+ });
},
methods: {
arePagePrerequisitesValid() {
@@ -153,11 +162,11 @@ export default {
this.navigateForward(partsOrQuestions);
},
- handleAnswerUpdates(key, answer) {
+ handleAnswerUpdates(answer) {
// 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
// (does not get run for each invididual question's answer, only when
- // all relevent questions for the current part have been answered)
+ // all relevant questions for the current part have been answered)
/*
answer example format:
@@ -176,6 +185,7 @@ export default {
// collect a list of the answered questions' numbers, needed later below
const answeredQuestionIndexes = [];
+ const foundDuplicateQuestions = [];
// if user has answered a question differently than anything that was preloaded,
// we need to clear out any preloaded answers
@@ -288,12 +298,12 @@ export default {
thisAnsweredPartQuestion.suppressQuestion = true;
const thisGlassPart = "glass" + gpIndex;
- if (this.foundDuplicateQuestions[thisGlassPart]) {
- if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredPartQuestion.questionSequence)) {
- this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredPartQuestion.questionSequence);
+ if (foundDuplicateQuestions[thisGlassPart]) {
+ if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredPartQuestion.questionSequence)) {
+ foundDuplicateQuestions[thisGlassPart].push(thisAnsweredPartQuestion.questionSequence);
}
} else {
- this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredPartQuestion.questionSequence];
+ foundDuplicateQuestions[thisGlassPart] = [thisAnsweredPartQuestion.questionSequence];
}
// are there any questions left that are not suppressed?
@@ -341,12 +351,12 @@ export default {
// EX answeredQuestionIndexes: [1,5,11,13]
- // EX this.foundDuplicateQuestions = {
+ // EX foundDuplicateQuestions = {
// "glassPart1": [1],
// "glassPart2": [7, 10]
// };
- const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex];
+ const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex];
const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : [];
const glassPartAnswered = this.moldingQuestionsData[answer.glassIndex];
@@ -408,75 +418,6 @@ export default {
}
},
- LoadInitialData() {
-
- // are there alreadyAnsweredQuestions?
- const alreadyAnsweredQuestions = store.getters.damage.moldingQuestionAnswers;
-
- this.moldingQuestionsData = this.pageData.partsOrQuestions.filter(x => x.parts[0].childPartQuestions.length).map((glass, i) => {
- glass.key = glass.glassLocation + "-" + glass.glassName;
- // NOTE: property "questions" can differ between layouts
- glass.questions = glass.parts[0].childPartQuestions;
-
- this.selectedAnswers[glass.key] = [];
- if (!alreadyAnsweredQuestions) {
- glass.answerData = null;
- }
-
- alreadyAnsweredQuestions?.forEach((savedPart) => {
-
- if (!savedPart.glassLocation || !savedPart.glassName || !savedPart.answeredQuestions || !savedPart.partNum) {
- return;
- }
- if (glass.glassLocation === savedPart.glassLocation && glass.glassName === savedPart.glassName) {
- let answerString = "";
-
- // matches; loop through answeredQuestions for matches
- savedPart.answeredQuestions.forEach((aq) => {
- if (!aq.questionNum || !aq.selectedAnswerText) {
- return;
- }
- // determine which answer was previously chosen
- const theAns = glass.questions[aq.questionNum-1].answers.find((a) => {
- return a.answerText.toUpperCase() === aq.selectedAnswerText.toUpperCase();
- });
- if (theAns.nextQuestionSequence) {
- answerString = `${aq.questionNum}|nextQuestion|${theAns.nextQuestionSequence}|${theAns.answerText}`
- } else {
- answerString = `${aq.questionNum}|answer|${theAns.answerResult}|${theAns.answerText}`
- }
-
- // mark this partQuestion as answered (question-chain will read this)
- glass.questions[aq.questionNum-1].answerSelected = answerString;
- // mark this partQuestion as duplicate if it is (question-chain will read this)
- if (aq.suppressQuestion) {
- glass.questions[aq.questionNum-1].suppressQuestion = true;
- }
- });
-
- // advance the currentGlassIndex
- this.currentGlassIndex = i;
-
- // add answerData to current glass
- glass.answerData = {
- answerResult: savedPart.partNum,
- answeredQuestions: savedPart.answeredQuestions
- }
- }
-
- });
-
- // Set up watch for each set of glass questions, which gets updated when all questions for a glass have been answered
- this.$watch("selectedAnswers." + glass.key, (newValue) => {
- if (newValue) {
- this.handleAnswerUpdates(glass.key, newValue);
- }
- }, {deep: true})
-
- return glass;
- });
-
- },
},
components: {
funnelHeader,
diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue
index 4906d9526..131a70f44 100644
--- a/src/layouts/part-questions/part-questions.vue
+++ b/src/layouts/part-questions/part-questions.vue
@@ -90,10 +90,9 @@ export default {
},
data() {
return {
- partsQuestionsData: store.getters.pageData(fmgPageValues.PART_QUESTIONS).partsOrQuestions,
+ partsQuestionsData: [],
selectedAnswers: {},
currentGlassIndex: 0,
- foundDuplicateQuestions: [],
};
},
computed: {
@@ -109,7 +108,17 @@ export default {
},
mixins: [vehicleQuestionsMixin],
mounted() {
- this.LoadInitialData();
+ // are there alreadyAnsweredQuestions?
+ const alreadyAnsweredQuestions = store.getters.damage.partQuestionAnswers;
+
+ this.partsQuestionsData = this.pageData.partsOrQuestions.filter(x => x.partQuestions).map((glass, i) => {
+ // NOTE: questions for property "questions" can differ between layouts
+ glass.questions = glass.partQuestions;
+ // reset selectedAnswers for this glass
+ this.selectedAnswers[glass.key] = [];
+ // pass in: glass, i, alreadyAnsweredQuestions
+ return this.setupInitialData(glass, i, alreadyAnsweredQuestions);
+ });
},
methods: {
arePagePrerequisitesValid() {
@@ -149,11 +158,11 @@ export default {
this.navigateForward(glassNameAndPartsForStore);
},
- handleAnswerUpdates(key, answer) {
+ handleAnswerUpdates(answer) {
// 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
// (does not get run for each invididual question's answer, only when
- // all relevent questions for the current part have been answered)
+ // all relevant questions for the current part have been answered)
/*
answer example format:
@@ -172,6 +181,7 @@ export default {
// collect a list of the answered questions' numbers, needed later below
const answeredQuestionIndexes = [];
+ const foundDuplicateQuestions = [];
// if user has answered a question differently than anything that was preloaded,
// we need to clear out any preloaded answers
@@ -284,12 +294,12 @@ export default {
thisAnsweredQuestion.suppressQuestion = true;
const thisGlassPart = "glass" + gpIndex;
- if (this.foundDuplicateQuestions[thisGlassPart]) {
- if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredQuestion.questionSequence)) {
- this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredQuestion.questionSequence);
+ if (foundDuplicateQuestions[thisGlassPart]) {
+ if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredQuestion.questionSequence)) {
+ foundDuplicateQuestions[thisGlassPart].push(thisAnsweredQuestion.questionSequence);
}
} else {
- this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredQuestion.questionSequence];
+ foundDuplicateQuestions[thisGlassPart] = [thisAnsweredQuestion.questionSequence];
}
// are there any questions left that are not suppressed?
@@ -337,12 +347,12 @@ export default {
// EX answeredQuestionIndexes: [1,5,11,13]
- // EX this.foundDuplicateQuestions = {
+ // EX foundDuplicateQuestions = {
// "glassPart1": [1],
// "glassPart2": [7, 10]
// };
- const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex];
+ const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex];
const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : [];
const glassPartAnswered = this.partsQuestionsData[answer.glassIndex];
@@ -404,75 +414,6 @@ export default {
}
},
- LoadInitialData() {
-
- // are there alreadyAnsweredQuestions?
- const alreadyAnsweredQuestions = store.getters.damage.partQuestionAnswers;
-
- this.partsQuestionsData = this.pageData.partsOrQuestions.filter(x => x.partQuestions).map((glass, i) => {
- glass.key = glass.glassLocation + "-" + glass.glassName;
- // NOTE: property "questions" can differ between layouts
- glass.questions = glass.partQuestions;
-
- this.selectedAnswers[glass.key] = [];
- if (!alreadyAnsweredQuestions) {
- glass.answerData = null;
- }
-
- alreadyAnsweredQuestions?.forEach((savedPart) => {
-
- if (!savedPart.glassLocation || !savedPart.glassName || !savedPart.answeredQuestions || !savedPart.result) {
- return;
- }
- if (glass.glassLocation === savedPart.glassLocation && glass.glassName === savedPart.glassName) {
- let answerString = "";
-
- // matches; loop through answeredQuestions for matches
- savedPart.answeredQuestions.forEach((aq) => {
- if (!aq.questionNum || !aq.selectedAnswerText) {
- return;
- }
- // determine which answer was previously chosen
- const theAns = glass.questions[aq.questionNum-1].answers.find((a) => {
- return a.answerText.toUpperCase() === aq.selectedAnswerText.toUpperCase();
- });
- if (theAns.nextQuestionSequence) {
- answerString = `${aq.questionNum}|nextQuestion|${theAns.nextQuestionSequence}|${theAns.answerText}`
- } else {
- answerString = `${aq.questionNum}|answer|${theAns.answerResult}|${theAns.answerText}`
- }
-
- // mark this question as answered (question-chain will read this)
- glass.questions[aq.questionNum-1].answerSelected = answerString;
- // mark this question as duplicate if it is (question-chain will read this)
- if (aq.suppressQuestion) {
- glass.questions[aq.questionNum-1].suppressQuestion = true;
- }
- });
-
- // advance the currentGlassIndex
- this.currentGlassIndex = i;
-
- // add answerData to current glass
- glass.answerData = {
- answerResult: savedPart.result,
- answeredQuestions: savedPart.answeredQuestions
- }
- }
-
- });
-
- // Set up watch for each set of glass questions, which gets updated when all questions for a glass have been answered
- this.$watch("selectedAnswers." + glass.key, (newValue) => {
- if (newValue) {
- this.handleAnswerUpdates(glass.key, newValue);
- }
- }, {deep: true})
-
- return glass;
- });
-
- },
},
components: {
funnelHeader,
diff --git a/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.spec.js b/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.spec.js
new file mode 100644
index 000000000..7dbe32604
--- /dev/null
+++ b/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.spec.js
@@ -0,0 +1,57 @@
+import { shallowMount } from "@vue/test-utils";
+import CashOrInsuranceQuestion from "./cash-or-insurance-question";
+
+
+describe("cash-or-insurance-question.vue", () => {
+ it("Should emit a false boolean value when selectedValues is 'CashAnswer' (update:modelValue)", async () => {
+
+ //Arrange
+ const wrapper = shallowMount(CashOrInsuranceQuestion, {
+ propsData: mockProps,
+ mixins: [mockMixin]
+ });
+
+ //Act
+ wrapper.vm.selectedValues = "CashAnswer";
+ await wrapper.vm.$nextTick();
+
+ //Assert
+ expect(wrapper.emitted()["update:modelValue"][0]).toEqual([false]);
+ expect(typeof wrapper.emitted()["update:modelValue"][0][0]).toBe("boolean");
+ });
+ it("Should return 'CashAnswer' from selectedValues when modelValue is set to false", async () => {
+
+ //Arrange
+ const wrapper = shallowMount(CashOrInsuranceQuestion, {
+ propsData: mockProps,
+ mixins: [mockMixin]
+ });
+
+ //Act
+ wrapper.setProps({modelValue : false});
+ await wrapper.vm.$nextTick();
+
+ //Assert
+ expect(wrapper.vm.selectedValues).toBe("CashAnswer");
+ });
+});
+
+ ///////////////
+ // Constants //
+ ///////////////
+
+const mockMixin = {
+ methods: {
+ getCmsContent: jest.fn((widgetName, cmsFieldName) => {
+ return mockCmsContent[cmsFieldName];
+ })
+ }
+}
+
+const mockProps = {
+ modelValue: true,
+}
+
+const mockCmsContent = {
+ 'Text': "Sample text here.",
+}
diff --git a/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.vue b/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.vue
index b2431406d..f745e8443 100644
--- a/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.vue
+++ b/src/layouts/quote/cash-or-insurance-question/cash-or-insurance-question.vue
@@ -14,6 +14,9 @@