From 0b366db781c91970c8b1140ddd88fa64b5f082c4 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 30 Nov 2021 16:08:46 -0500 Subject: [PATCH 1/6] Functionality for year radio buttons --- src/constants/store-actions.js | 2 +- src/constants/store-mutations.js | 5 ++ src/layouts/component-test/component-test.vue | 10 ++-- src/layouts/vehicle-year/vehicle-year.vue | 1 - .../year-question/year-question.spec.js | 3 ++ .../year-question/year-question.vue | 9 +++- src/mixins/base-mixin.js | 4 ++ src/store/index.js | 5 +- src/store/store.spec.js | 21 +++++++- .../radio-list/radio-list.spec.js | 1 - src/ux-components/radio-list/radio-list.vue | 51 ------------------- 11 files changed, 49 insertions(+), 63 deletions(-) create mode 100644 src/constants/store-mutations.js delete mode 100644 src/ux-components/radio-list/radio-list.spec.js delete mode 100644 src/ux-components/radio-list/radio-list.vue diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 60300f78c..db80d3d3f 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -7,7 +7,7 @@ const storeActions = { GET_VEHICLE_STYLES: "getVehicleStyles", GET_EVOX_IMAGE: "getEvoxImage", LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", - LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin" + LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin", }; export { storeActions }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js new file mode 100644 index 000000000..6ade6cd1d --- /dev/null +++ b/src/constants/store-mutations.js @@ -0,0 +1,5 @@ +const storeMutations = { + UPDATE_YEAR: "updateYear", +} + +export { storeMutations }; \ No newline at end of file diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index b25a26b8f..134604ad6 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -73,7 +73,7 @@

Select Vehicle Year

- - - { @@ -19,10 +20,12 @@ describe('year-question.vue', () => { const wrapper = shallowMount(yearQuestion, mountOptions); await wrapper.setProps({questionText: 'What year is your vehicle?'}) await flushPromises(); + wrapper.vm.selectYear(2020); // Assert const radioQuestion = await wrapper.findComponent({name: 'radioQuestion'}); expect(radioQuestion.attributes('questiontext')).toBe("What year is your vehicle?"); expect(radioQuestion.attributes('answers')).toBe('2023,2022,2021'); + expect(store.state.order.vehicle.year).toBe(2020); }); }); diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue index 4aedb12df..d59df5e00 100644 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ b/src/layouts/vehicle-year/year-question/year-question.vue @@ -1,5 +1,9 @@ diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 81a191aa5..586e8c08e 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -1,4 +1,5 @@ import { storeActions } from "@/constants/store-actions.js"; +import { storeMutations } from "@/constants/store-mutations.js"; import { widgetNames } from "@/constants/widget-names.js"; export default { @@ -53,6 +54,9 @@ export default { storeActions() { return storeActions; }, + storeMutations() { + return storeMutations; + }, widgetNames() { return widgetNames; }, diff --git a/src/store/index.js b/src/store/index.js index 0976690b7..bbeaab714 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -64,6 +64,9 @@ export default createStore({ } }, mutations: { + updateYear(state, year){ + state.order.vehicle.year = year; + }, updateVehicleImage(state, data) { state.order.vehicle.imageSrc = data.imgSrc; }, @@ -138,6 +141,6 @@ export default createStore({ endpoint: relativeUrl, payload: {}, }); - }, + } }, }); diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 3442d35bf..6e576b198 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -14,7 +14,6 @@ describe("Actions", () => { await store.dispatch('getVehicleYears') .then( (response) => { years = response.data; - console.log(response); }); // Assert @@ -109,4 +108,22 @@ describe("Actions", () => { // Assert expect(pageData).toBe('Page Info Data'); }); -}) \ No newline at end of file +}) + +describe("Mutations", () => { + it("Should update the year property in the store", () => { + // Act + store.commit('updateYear', 2020); + + // Assert + expect(store.state.order.vehicle.year).toBe(2020); + }); + + it("Should update the vehicle image property in the store", () => { + // Act + store.commit('updateVehicleImage', {imgSrc: 'exampleimage@image.com'}); + + // Assert + expect(store.state.order.vehicle.imageSrc).toBe('exampleimage@image.com'); + }); +}); \ No newline at end of file diff --git a/src/ux-components/radio-list/radio-list.spec.js b/src/ux-components/radio-list/radio-list.spec.js deleted file mode 100644 index 3d0843e10..000000000 --- a/src/ux-components/radio-list/radio-list.spec.js +++ /dev/null @@ -1 +0,0 @@ -test.todo("some test to be written in the future"); diff --git a/src/ux-components/radio-list/radio-list.vue b/src/ux-components/radio-list/radio-list.vue deleted file mode 100644 index 2976ce87e..000000000 --- a/src/ux-components/radio-list/radio-list.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - From b6e0a02deb84e22f51075e13351da518f82a199c Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 1 Dec 2021 09:14:06 -0500 Subject: [PATCH 2/6] Auto stash before merge of "feature/CSR-121_button-click-function" and "feature/CSR-6" --- src/layouts/vehicle-year/vehicle-year.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index 941d1328c..748030c2d 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -13,8 +13,6 @@ import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; import pageHeader from "@/ux-components/header/header"; import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; - -// Supporting files import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import store from "@/store"; @@ -61,7 +59,7 @@ export default { components: { yearQuestion, pageHeader, - vehicleBanner + vehicleBanner, }, }; From d589ce1b9c53acedae73d7111365985631bf4543 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 1 Dec 2021 14:54:58 -0500 Subject: [PATCH 3/6] Adding functionality to radio buttons on year pages --- src/layouts/vehicle-year/vehicle-year.vue | 10 ++-------- .../vehicle-year/year-question/year-question.vue | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index 748030c2d..a67a6d866 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -13,11 +13,11 @@ import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; import pageHeader from "@/ux-components/header/header"; import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; +// Supporting files import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import store from "@/store"; import { storeActions } from "@/constants/store-actions.js"; - export default { name: "vehicle-year", data() { @@ -29,10 +29,8 @@ export default { }, computed: {}, beforeRouteEnter(to, from, next) { - const contentPromise = fetchCmsContentForPage(to.query.fmgPage); const getVehicleYearPromise = store.dispatch(storeActions.GET_VEHICLE_YEARS, {}); - const promiseResultMap = [ { resultKey: "getPageContent", @@ -43,9 +41,7 @@ export default { promise: getVehicleYearPromise, }, ]; - settleAllPromises(promiseResultMap).then((resultMap) => { - // Call our next function to transition to the next page. next((vm) => { vm.pageHeaderWidgets = resultMap.getPageContent.PageHeaderWidget[0]; @@ -54,12 +50,11 @@ export default { }); }); - }, components: { yearQuestion, pageHeader, - vehicleBanner, + vehicleBanner }, }; @@ -67,7 +62,6 @@ export default {