diff --git a/jest.config.js b/jest.config.js index b8beb88cc..4a2601c8f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -16,6 +16,7 @@ module.exports = { "!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", + "!src/layouts/nested-radio-poc/nested-radio.vue", ], //! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { diff --git a/src/App.vue b/src/App.vue index 76a01d29c..603bd2cb3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,4 +7,5 @@ @import "@/styles/common-styles.scss"; @import "@/styles/common-typography-styles.scss"; @import "@/styles/common-error-styles.scss"; + @import "@/styles/common-animations.scss"; diff --git a/src/common-components/button-question/button-question.spec.js b/src/common-components/button-question/button-question.spec.js index d5608cd62..d36b73012 100644 --- a/src/common-components/button-question/button-question.spec.js +++ b/src/common-components/button-question/button-question.spec.js @@ -3,12 +3,14 @@ import buttonQuestion from "@/common-components/button-question/button-question" import { nextTick } from "vue"; describe("buttonQuestion.vue", () => { - it("Should show overflow classes on fieldset if isOverflowScrollable is true", async () => { + it("Should show overflow classes on fieldset if isOverflowScrollable is true", () => { // Act - const wrapper = shallowMount(buttonQuestion); - await wrapper.setProps({ - isOverflowScrollable: true, + const wrapper = shallowMount(buttonQuestion, { + propsData: { + isOverflowScrollable: true, + } }); + // Assert const fieldSet = wrapper.find('fieldset'); expect(fieldSet.classes()).toContain("overflow-scroll"); @@ -16,11 +18,12 @@ describe("buttonQuestion.vue", () => { }); describe("buttonQuestion.vue", () => { - it("Fieldset classes should contain row if button type is listCard", async () => { + it("Fieldset classes should contain row if button type is listCard", () => { // Act - const wrapper = shallowMount(buttonQuestion); - await wrapper.setProps({ - buttonType: "listCard", + const wrapper = shallowMount(buttonQuestion, { + propsData: { + buttonType: "listCard", + } }); // Assert const Div = wrapper.find('fieldset div'); @@ -29,11 +32,12 @@ describe("buttonQuestion.vue", () => { }); describe("buttonQuestion.vue", () => { - it("Fieldset classes should contain d-flex if button type is listButtonHorizontal", async () => { + it("Fieldset classes should contain d-flex if button type is listButtonHorizontal", () => { // Act - const wrapper = shallowMount(buttonQuestion); - await wrapper.setProps({ - buttonType: "listButtonHorizontal", + const wrapper = shallowMount(buttonQuestion, { + propsData: { + buttonType: "listButtonHorizontal", + } }); // Assert const Div = wrapper.find('fieldset div'); @@ -49,7 +53,7 @@ describe("buttonQuestion.vue", () => { answers: ["2022", "2021", "2020"], isMultiSelect: false }); - const val = {isChecked: true, buttonId: "2021", } + const val = {checkValue: true, value: "2021", } wrapper.vm.handleCheckedChanged(val); // Assert expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2021"]]); @@ -57,14 +61,15 @@ describe("buttonQuestion.vue", () => { }); describe("buttonQuestion.vue", () => { - it("Should add values to array on checkbox click", async () => { + it("Should add values to array on checkbox click", () => { // Act - const wrapper = shallowMount(buttonQuestion); - await wrapper.setProps({ - modelValue: ["2022", "2021", "2020"], - isMultiSelect: true + const wrapper = shallowMount(buttonQuestion, { + propsData: { + modelValue: ["2022", "2021", "2020"], + isMultiSelect: true, + } }); - const val = {isChecked: true, buttonId: "2019", } + const val = {checkValue: true, value: "2019", } wrapper.vm.handleCheckedChanged(val); // Assert expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2022", "2021", "2020", "2019"]]); diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index b3ea56043..6bc67a273 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -4,7 +4,7 @@ {{ questionText }}
-
+
{{groupName}}
@@ -74,17 +73,11 @@ export default { type: String, default: "right", }, - sizeInRem: { - type: [String, Number], - default: 1.5, - }, isRequired: Boolean, isOverflowScrollable: Boolean, isWide: Boolean, modelValue: Array, validationRules: String, - name: String, - value: String, suppressError: Boolean, }, computed: { @@ -111,6 +104,13 @@ export default { } return classes; }, + getColLength(){ + if(this.isWide) { + return "12" + } else { + return this.answers.length < 3 ? '' : '-4'; + } + }, selectedValues: { get: function() { return this.modelValue; @@ -120,25 +120,17 @@ export default { } }, }, - mounted(){ - if(Array.isArray(this.answers) && this.answers.length === 1) { - const newSelectedValues = this.selectedValues; - newSelectedValues.push(typeof(this.answers[0]) === 'object' ? this.answers[0].Name : this.answers[0]); - this.selectedValues = newSelectedValues; - } - }, methods: { - chooseAnswer(answer) { - this.$emit("update:modelValue", answer); - }, 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); - this.selectedValues = newSelectedValues; + if(Array.isArray(this.selectedValues)) { + val.checkValue ? newSelectedValues.push(val.value) : newSelectedValues.splice(newSelectedValues.indexOf(val.value), 1); + this.selectedValues = newSelectedValues; + } } else { - this.selectedValues = [val.buttonId]; + this.selectedValues = [val.value]; } }, }, diff --git a/src/common-components/dropdown-question/dropdown-question.spec.js b/src/common-components/dropdown-question/dropdown-question.spec.js new file mode 100644 index 000000000..0d1095c94 --- /dev/null +++ b/src/common-components/dropdown-question/dropdown-question.spec.js @@ -0,0 +1,81 @@ +import { shallowMount } from "@vue/test-utils"; +import dropdownQuestion from "./dropdown-question"; +import { nextTick } from "vue"; + +describe("dropdownQuestion.vue", () => { + + it("Should return aria-disabled state", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + isDisabled: true, + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes()["aria-disabled"]).toEqual("true"); + }); + + it("Should render a text input", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + name: "test", + label: "unit test label", + }, + }); + + // Assert + const input = wrapper.find("select"); + + expect(input.exists()).toBe(true); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + labelText: "label text", + }, + }); + + // Assert + const label = wrapper.find("label"); + + expect(label.text()).toEqual("label text"); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + +}); diff --git a/src/common-components/dropdown-question/dropdown-question.vue b/src/common-components/dropdown-question/dropdown-question.vue index edbd8787f..e593a61b9 100644 --- a/src/common-components/dropdown-question/dropdown-question.vue +++ b/src/common-components/dropdown-question/dropdown-question.vue @@ -1,13 +1,19 @@ + + + + diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index af604ed99..062a3574a 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -21,7 +21,6 @@ isPrimary :buttonText="buttonText" loaderColor="white" - sizeInRem="1" :class="isDisabled && 'form-test-invalid'" :aria-disabled="isDisabled" :isDisabled="isDisabled" @@ -97,6 +96,10 @@ export default { .btn-primary { width: 100%; } + a { + display: flex; + justify-content: center; + } @media only screen and (min-width: 340px) { .button-col, .link-col { @@ -105,6 +108,10 @@ export default { .btn-primary { width: auto; } + a { + display: flex; + justify-content: flex-start; + } } } diff --git a/src/common-components/funnel-header/funnel-header.vue b/src/common-components/funnel-header/funnel-header.vue index 86cb76197..382640219 100644 --- a/src/common-components/funnel-header/funnel-header.vue +++ b/src/common-components/funnel-header/funnel-header.vue @@ -60,7 +60,7 @@ export default { diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index 43d67533f..d75266010 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -1,203 +1,300 @@ - - + diff --git a/src/layouts/nested-radio-poc/nested-radio.vue b/src/layouts/nested-radio-poc/nested-radio.vue new file mode 100644 index 000000000..3bdeba866 --- /dev/null +++ b/src/layouts/nested-radio-poc/nested-radio.vue @@ -0,0 +1,75 @@ + + + + + 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 01f063eef..92feec9b8 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' } ]) + expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'Windshield' }, { Name: '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 36eac0831..89b3244e3 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,7 +1,6 @@