diff --git a/jest.config.js b/jest.config.js index 36c4507fc..b8beb88cc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,6 +13,8 @@ module.exports = { "!src/helpers/unit-test-helper.js", "!src/layouts/component-test/component-test.vue", "!src/layouts/form-test/form-test.vue", + "!src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue", + "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", "!src/layouts/address-poc/address-poc.vue", ], //! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 7fff5c238..417230464 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -7,9 +7,9 @@
{{groupName}}
-
+
+ +
@@ -43,6 +47,8 @@ import listButton from "@/ux-components/list-button/list-button"; import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-button-horizontal"; import listCard from "@/ux-components/list-card/list-card"; +import { ErrorMessage } from 'vee-validate'; +import radio from "@/ux-components/radio/radio"; export default { name: "buttonQuestion", @@ -76,6 +82,10 @@ export default { isOverflowScrollable: Boolean, isWide: Boolean, modelValue: Array, + validationRules: String, + name: String, + value: String, + suppressError: Boolean, }, computed: { getFieldSetClasses() { @@ -95,6 +105,9 @@ export default { case 'listCard': classes = 'row justify-content-center g-2' break; + case 'radio': + classes = 'ui-radio d-flex' + break; } return classes; }, @@ -115,6 +128,9 @@ export default { } }, methods: { + chooseAnswer(answer) { + this.$emit("update:modelValue", answer); + }, handleCheckedChanged(val) { if(this.isMultiSelect) { // Add or remove item to array of data to emit @@ -130,6 +146,8 @@ export default { listButton, listButtonHorizontal, listCard, + ErrorMessage, + radio, }, }; diff --git a/src/common-components/funnel-footer/funnel-footer.spec.js b/src/common-components/funnel-footer/funnel-footer.spec.js index a4c127a3e..6b2bd8335 100644 --- a/src/common-components/funnel-footer/funnel-footer.spec.js +++ b/src/common-components/funnel-footer/funnel-footer.spec.js @@ -5,90 +5,50 @@ describe("funnel-footer.vue", () => { it("Should return footer-link class", async () => { // Act - const r = { test:"testing", clientHeight: 10, - classList: { - add: jest.fn(() => ''), - remove: jest.fn() - }, + offsetHeight: 24, }; - global.document.getElementById = jest.fn().mockImplementation(()=> { + global.document.querySelector = jest.fn().mockImplementation(()=> { return r; }); const wrapper = mount(funnelFooter, { }); + wrapper.vm.initializeComponent(cmsContent); // Assert const link = wrapper.find("a"); - console.log(wrapper.html()); // Expect - expect(link.attributes('class')).toContain("footer-link"); - expect(global.document.getElementById).toBeCalled(); - expect(r.classList.add).toBeCalledWith("justify-content-end"); - expect(r.classList.remove).toBeCalledWith("justify-content-start"); + expect(link.attributes('class')).toContain("footer"); }); - it("Should return link text", async () => { + it("Should emit ForwardClicked on button click", async () => { // Act const wrapper = mount(funnelFooter, { - propsData: { - text: "Terms of use", - }, }); - + wrapper.vm.buttonClick(); // Assert - const link = wrapper.find("a"); - - expect(link.text()).toEqual("Terms of use"); + expect(wrapper.emitted()["ForwardClicked"][0]).toHaveBeenCalled; }); - it("Should return class btn-primary", async () => { + it("Should emit BackClicked on link click", async () => { // Act const wrapper = mount(funnelFooter, { - propsData: { - isPrimary: true, - }, }); - + wrapper.vm.linkClick(); // Assert - const input = wrapper.find("button"); - - // Expect - expect(input.attributes("class")).toContain("btn-primary"); - }); - - it("Should return class justify-content-end if paddingHeight < 80px", async () => { - - global.document.getElementById = jest.fn().mockImplementation(()=> { - return { - test:"testing", - clientHeight: 10, - classList: { - add: jest.fn(), - remove: jest.fn() - } - } - }); - - // Act - const wrapper = mount(funnelFooter, { - propsData: { - footer: true - }, - }); - const infoBox = document.getElementById('infoBox'); - // Assert - const stacked = wrapper.find("#stacked"); - wrapper.vm.paddingHeight = 100; - - // Expect - expect(stacked.attributes('class')).toContain("justify-content-end"); + expect(wrapper.emitted()["BackClicked"][0]).toHaveBeenCalled; }); }); + +//Mock CMS content +const cmsContent = { + backLink: "text", + buttonText: "text", +}; diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index 37879d2cf..af604ed99 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -1,28 +1,44 @@ diff --git a/src/layouts/address-poc/address-poc.vue b/src/layouts/address-poc/address-poc.vue index fff528604..8bb42a659 100644 --- a/src/layouts/address-poc/address-poc.vue +++ b/src/layouts/address-poc/address-poc.vue @@ -5,42 +5,51 @@ -
-
- - +
+
+
+ + +
-
-
-
- - + +
+
+
+ + +
-
-
-
- - -
-
- - -
-
- + +
+
+
+ + +
+
+ + +
+
+
An accurate match may not have have been located. Please verify your address before continuing @@ -57,7 +66,8 @@ + type="text" + autocomplete="off" />
@@ -66,7 +76,8 @@ + type="text" + autocomplete="off" />
@@ -75,7 +86,8 @@ + type="text" + autocomplete="off" />
diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index fdb92ab23..3f1ae5ad9 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -2,7 +2,7 @@
-

Inputs

+

Checkbox

@@ -15,6 +15,36 @@ />
+
+
+

Radio Button

+

Sample radio button group

+
+
+
+
+ +
+
+ +
+

Buttons

@@ -50,14 +80,17 @@





-
-
-

Links

-
-
-
-
-

-

-

- -
-

Typography

@@ -926,16 +946,6 @@ />
-
-
-

Funnel Footer

-
-
-
-
- -
-
@@ -949,8 +959,8 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import funnelHeader from "@/common-components/funnel-header/funnel-header"; import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-button-horizontal"; import checkbox from "@/ux-components/checkbox/checkbox"; +import radio from "@/ux-components/radio/radio"; import textLink from "@/ux-components/text-link/text-link"; -import funnelFooter from "@/common-components/funnel-footer/funnel-footer"; export default { name: "App", components: { @@ -962,9 +972,9 @@ export default { vehicleBanner, listButtonHorizontal, checkbox, + radio, funnelHeader, - textLink, - funnelFooter + textLink }, data() { return { diff --git a/src/layouts/form-test/form-test.vue b/src/layouts/form-test/form-test.vue index d56b764b3..1e6d0d7b2 100644 --- a/src/layouts/form-test/form-test.vue +++ b/src/layouts/form-test/form-test.vue @@ -1,367 +1,164 @@ - - diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js index 65434b289..01f063eef 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js @@ -41,7 +41,7 @@ describe("damage-location-question.vue", () => { damageLocationQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, damageOptions, "car-group"); //Assert - expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-SideDoor' }, {Name: "car-RearWindow"} ]) + expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-SideDoor' } ]) }); }); diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue index c48912ff2..36eac0831 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue @@ -1,5 +1,5 @@ \ No newline at end of file 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 41ecac799..31c739b49 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 @@ -9,6 +9,7 @@ :groupName="groupName" buttonType="listCard" v-model="selectedValues" + validationRules="replace-options-required" /> @@ -17,6 +18,15 @@ \ No newline at end of file diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue index 1baf8dd82..f5356b4d5 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -116,3 +116,5 @@ console.log(this); }, }) + + suppressError: Boolean, \ No newline at end of file diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index 023d24023..c91379318 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -1,10 +1,10 @@ + + diff --git a/src/ux-components/text-link/text-link.vue b/src/ux-components/text-link/text-link.vue index 2297b9c71..a03fc52a6 100644 --- a/src/ux-components/text-link/text-link.vue +++ b/src/ux-components/text-link/text-link.vue @@ -13,11 +13,10 @@ export default { text: String, href: { type: String, - default: `javascript:void(0)`, //Prevents page jump when value is empty or # }, }, methods: { - handleClick() { + handleClick(event) { this.$emit("click-event"); }, },