diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index e8cf4a967..4ca468502 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -122,7 +122,7 @@ export default { }, methods: { handleCheckedChanged(val) { - if(this.isMultiSelect) { + if(this.isMultiSelect && this.selectedValues) { // Add or remove item to array of data to emit const newSelectedValues = this.selectedValues; val.isChecked ? newSelectedValues.push(val.buttonId) : newSelectedValues.splice(newSelectedValues.indexOf(val.buttonId), 1); diff --git a/src/layouts/nested-radio-poc/nested-radio.vue b/src/layouts/nested-radio-poc/nested-radio.vue index 0795d8b59..d8404e838 100644 --- a/src/layouts/nested-radio-poc/nested-radio.vue +++ b/src/layouts/nested-radio-poc/nested-radio.vue @@ -1,7 +1,7 @@ diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index f47abea5d..28aa0831e 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -71,7 +71,7 @@ export default ({ }, }, mounted(){ - if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) { + if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1 && this.selectedValues) { const newSelectedValues = this.selectedValues; newSelectedValues.push(this.answersToDisplay[0].Name); this.selectedValues = newSelectedValues; diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js index 0e47eb37f..4a26b3426 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.spec.js +++ b/src/layouts/vehicle-damage/vehicle-damage.spec.js @@ -6,6 +6,7 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header"; import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question"; import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question"; +import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options"; // Supporting Files import { settleAllPromises } from "@/helpers/layout-helper.js"; @@ -177,7 +178,7 @@ function setupMocks({ availableReplacementOptions: ["Front", "Back", "Side"], }, windshieldOptions: { - availableReplacementOptions: ["Front", "Back", "Side"], + availableReplacementOptions: ["Single", "Driver", "Passenger"], }, }); }); @@ -198,8 +199,8 @@ function setupMocks({ availableReplacementOptions: ["Front", "Back", "Side"], }, windshieldOptions: { - availableReplacementOptions: ["Front", "Back", "Side"], - } + availableReplacementOptions: ["Single", "Driver", "Passenger"], + }, }, }; @@ -226,12 +227,11 @@ function setupMocks({ initializeComponent: jest.fn(), }; - const windshieldOptions = replaceOptionsQuestion - windshieldOptions.methods = { + damageLocationQuestion.methods = { initializeComponent: jest.fn(), }; - damageLocationQuestion.methods = { + windshieldOptions.methods = { initializeComponent: jest.fn(), }; @@ -262,11 +262,13 @@ function setupMocks({ driverSideOptionsWrapper.vm.initializeComponent = replaceOptionsQuestion.methods.initializeComponent; - const windshieldOptionsWrapper = wrapper.findAllComponents({ - name: "replaceOptionsQuestion", - }).at(1); + const windshieldOptionsWrapper = wrapper.findComponent({ + name: "windshieldOptions", + }); + windshieldOptionsWrapper.vm.initializeComponent = - replaceOptionsQuestion.methods.initializeComponent; + windshieldOptions.methods.initializeComponent; + const damageLocationQuestionWrapper = wrapper.findComponent({ name: "damageLocationQuestion", diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 8a85de6b5..998a43892 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -6,6 +6,10 @@ + @@ -16,8 +20,9 @@ import funnelHeader from "@/common-components/funnel-header/funnel-header"; import funnelFooter from "@/common-components/funnel-footer/funnel-footer"; import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header"; -import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question"; -import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question"; +import replaceOptionsQuestion from"@/layouts/vehicle-damage/replace-options-question/replace-options-question"; +import damageLocationQuestion from"@/layouts/vehicle-damage/damage-location-question/damage-location-question"; +import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options"; // Supporting files import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; @@ -70,6 +75,7 @@ export default { resultMap.cmsContent.DamageLocationQuestion, resultMap.damageOptions ); vm.$refs.windshieldOptions.initializeComponent( + resultMap.cmsContent.WindshieldDamageTypeQuestion, resultMap.cmsContent.WindshieldChipCountQuestion, resultMap.cmsContent.WindshieldReplaceOptionsQuestion, resultMap.damageOptions.windshieldOptions.availableReplacementOptions ); vm.$refs.funnelFooter.initializeComponent( @@ -81,7 +87,7 @@ export default { return { selectedDamageLocations: [], driverSideOptionsData: [], - windshieldOptionsData: [], + selectedWindshieldOptions: [] } }, methods: { @@ -107,6 +113,7 @@ export default { funnelSubHeader, replaceOptionsQuestion, damageLocationQuestion, + windshieldOptions, }, }; diff --git a/src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue b/src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue deleted file mode 100644 index 686f10de9..000000000 --- a/src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - \ No newline at end of file diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js new file mode 100644 index 000000000..123051d35 --- /dev/null +++ b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js @@ -0,0 +1,71 @@ +import { shallowMount } from "@vue/test-utils"; +import windshieldChipCountQuestion from "@/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import store from "@/store"; + +jest.mock("@/store", () => { return {}; }, {virtual: true}); + +describe("windshield-chip-count-question.vue", () => { + test("Selected chip count is emitted upon selection.", async () => { + //Arrange + const { wrapper } = setupMocks({modelValueProp: ["One"]}); + + //Act + wrapper.setValue({ modelValue: ["Two"] }); + await wrapper.vm.$nextTick(); + + //Assert + expect(wrapper.vm.selectedChipCountValues).toEqual(["One"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Two"] }]); + }); + }); + + describe("Windshield-chip-count-question.vue", () => { + test("Should display question and answers from api.", async () => { + + //Arrange + const { wrapper, cmsContent } = setupMocks({modelValueProp: ["One"]}); + + //Act + windshieldChipCountQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent); + + //Assert + expect(wrapper.vm.questionText).toStrictEqual("How many chips are we repairing?"); + expect(wrapper.vm.answersFromCms).toStrictEqual([ { Name: 'One' }, { Name: 'Two' }, { Name: 'Three'} ]); + }); + }); + + function setupMocks({ + modelValueProp = ["Two"], + groupName = "WindshieldChipCountQuestion", + cmsQuestionText = "How many chips are we repairing?", + cmsAnswers = [{Name: "One"}, {Name: "Two"}, {Name: "Three"}], + dataFromStoreApi = [], + }) { + + //Mock store + store.dispatch = jest.fn(() => dataFromStoreApi); + store.getters = { vehicle: {year: 2019, make: 'honda', model: 'civc', style: '2 Door', category: 'CAR'} }; + const mountOptions = getMountOptions({ + store: { + dispatch: store.dispatch, + getters: store.getters, + }, + }); + + //Mock props + mountOptions.propsData = { + modelValue: modelValueProp + }; + + const wrapper = shallowMount(windshieldChipCountQuestion, mountOptions); + + //Mock CMS content + const cmsContent = { + groupName: groupName, + QuestionText: cmsQuestionText, + Answers: cmsAnswers, + }; + const damageOptions = dataFromStoreApi; + return { wrapper, cmsContent, damageOptions }; + } \ No newline at end of file diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue new file mode 100644 index 000000000..41a3b872b --- /dev/null +++ b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js new file mode 100644 index 000000000..3bb64d695 --- /dev/null +++ b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js @@ -0,0 +1,71 @@ +import { shallowMount } from "@vue/test-utils"; +import windshieldDamageTypeQuestion from"@/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import store from "@/store"; + +jest.mock("@/store", () => { return {}; }, {virtual: true}); + +describe("windshield-damage-type-question.vue", () => { + test("Selected chip count is emitted upon selection.", async () => { + //Arrange + const { wrapper } = setupMocks({modelValueProp: ["Repair"]}); + + //Act + wrapper.setValue({ modelValue: ["Replace"] }); + await wrapper.vm.$nextTick(); + + //Assert + expect(wrapper.vm.selectedValues).toEqual(["Repair"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Replace"] }]); + }); + }); + + describe("windshield-damage-type-question.vue", () => { + test("Should display question and answers from api.", async () => { + + //Arrange + const { wrapper, cmsContent } = setupMocks({modelValueProp: ["Repair"]}); + + //Act + windshieldDamageTypeQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent); + + //Assert + expect(wrapper.vm.questionText).toStrictEqual("What's your windshield damage?"); + expect(wrapper.vm.answersFromCms).toStrictEqual([ { Name: 'Repair' }, { Name: 'Replace' } ]); + }); + }); + + function setupMocks({ + modelValueProp = ["Two"], + groupName = "WindshieldDamageTypeQuestion", + cmsQuestionText = "What's your windshield damage?", + cmsAnswers = [{Name: "Repair"}, {Name: "Replace"}], + dataFromStoreApi = [], + }) { + + //Mock store + store.dispatch = jest.fn(() => dataFromStoreApi); + store.getters = { vehicle: {year: 2019, make: 'honda', model: 'civc', style: '2 Door', category: 'CAR'} }; + const mountOptions = getMountOptions({ + store: { + dispatch: store.dispatch, + getters: store.getters, + }, + }); + + //Mock props + mountOptions.propsData = { + modelValue: modelValueProp + }; + + const wrapper = shallowMount(windshieldDamageTypeQuestion, mountOptions); + + //Mock CMS content + const cmsContent = { + groupName: groupName, + QuestionText: cmsQuestionText, + Answers: cmsAnswers, + }; + const damageOptions = dataFromStoreApi; + return { wrapper, cmsContent, damageOptions }; + } \ No newline at end of file diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.vue b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.vue new file mode 100644 index 000000000..80656e0a4 --- /dev/null +++ b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue index 68cce08eb..8f57f61b7 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -1,26 +1,129 @@ \ No newline at end of file diff --git a/src/styles/common-error-styles.scss b/src/styles/common-error-styles.scss index 2ca852f66..4b9a18114 100644 --- a/src/styles/common-error-styles.scss +++ b/src/styles/common-error-styles.scss @@ -23,6 +23,7 @@ &.ui-radio, &.ui-checkbox { input[type=checkbox], + input[type=radio], input[type=radio]+label:before, input[type=checkbox]+label:before { border: 1px solid $red; diff --git a/src/ux-components/radio/radio.vue b/src/ux-components/radio/radio.vue index 9ae2ed8bf..952aefb1d 100644 --- a/src/ux-components/radio/radio.vue +++ b/src/ux-components/radio/radio.vue @@ -1,6 +1,6 @@