diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 71d79b31f..e96f15df5 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 if(Array.isArray(this.selectedValues)) { const newSelectedValues = this.selectedValues; diff --git a/src/layouts/nested-radio-poc/nested-radio.vue b/src/layouts/nested-radio-poc/nested-radio.vue index 6d05c4009..3bdeba866 100644 --- a/src/layouts/nested-radio-poc/nested-radio.vue +++ b/src/layouts/nested-radio-poc/nested-radio.vue @@ -1,27 +1,75 @@ + + diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js index c7d994b89..a25c3eb4c 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 sideDoorOptions from "@/layouts/vehicle-damage/side-door-options/side-door-options"; 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"; @@ -190,6 +191,9 @@ function setupMocks({ passengerSideOptions: { availableReplacementOptions: ["Front", "Back", "Side"], } + windshieldOptions: { + availableReplacementOptions: ["Single", "Driver", "Passenger"], + }, }, }; @@ -219,6 +223,10 @@ function setupMocks({ initializeComponent: jest.fn(), }; + windshieldOptions.methods = { + initializeComponent: jest.fn(), + }; + funnelFooter.methods = { initializeComponent: jest.fn(), } diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index cbcdfe0f5..a7d3e4f33 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -5,6 +5,10 @@ + @@ -17,6 +21,7 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header"; import sideDoorOptions from "@/layouts/vehicle-damage/side-door-options/side-door-options"; 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"; @@ -68,6 +73,10 @@ export default { vm.$refs.sideDoorOptions.initializeComponent( resultMap.cmsContent.SideDoorSideQuestion, resultMap.cmsContent.DriverSideReplaceOptionsQuestion, resultMap.cmsContent.PassengerSideReplaceOptionsQuestion, resultMap.damageOptions.driverSideOptions.availableReplacementOptions, resultMap.damageOptions.passengerSideOptions.availableReplacementOptions ); + vm.$refs.windshieldOptions.initializeComponent( + resultMap.cmsContent.WindshieldDamageTypeQuestion, resultMap.cmsContent.WindshieldChipCountQuestion, + resultMap.cmsContent.WindshieldReplaceOptionsQuestion, resultMap.damageOptions.windshieldOptions.availableReplacementOptions + ); vm.$refs.funnelFooter.initializeComponent( resultMap.cmsContent.FunnelFooterWidget ); @@ -81,7 +90,7 @@ export default { selectedDriverSideReplacOptions: [], selectedPassengerSideReplaceOptions: [] }, - windshieldOptionsData: [], + selectedWindshieldOptions: [] } }, methods: { @@ -107,6 +116,7 @@ export default { funnelSubHeader, sideDoorOptions, 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..db6569709 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -1,26 +1,112 @@ \ No newline at end of file diff --git a/src/styles/common-error-styles.scss b/src/styles/common-error-styles.scss index d7d1c019d..4b9a18114 100644 --- a/src/styles/common-error-styles.scss +++ b/src/styles/common-error-styles.scss @@ -22,6 +22,8 @@ } &.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/checkbox/checkbox.vue b/src/ux-components/checkbox/checkbox.vue index 24c9e830e..73eb562bf 100644 --- a/src/ux-components/checkbox/checkbox.vue +++ b/src/ux-components/checkbox/checkbox.vue @@ -1,15 +1,15 @@