From 8e59a8d746de3f209e01286f52a2049d41832189 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 13 Jan 2022 11:32:04 -0500 Subject: [PATCH 1/2] Removing unneeded data from vehicle question vue files --- src/layouts/vehicle-make/make-question/make-question.spec.js | 4 ++-- src/layouts/vehicle-make/make-question/make-question.vue | 5 ++--- .../vehicle-model/model-question/model-question.spec.js | 4 ++-- src/layouts/vehicle-model/model-question/model-question.vue | 5 ++--- .../vehicle-style/style-question/style-question.spec.js | 4 ++-- src/layouts/vehicle-style/style-question/style-question.vue | 5 ++--- src/layouts/vehicle-year/year-question/year-question.spec.js | 4 ++-- src/layouts/vehicle-year/year-question/year-question.vue | 5 ++--- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/layouts/vehicle-make/make-question/make-question.spec.js b/src/layouts/vehicle-make/make-question/make-question.spec.js index 84dd4f7e8..6a811459f 100644 --- a/src/layouts/vehicle-make/make-question/make-question.spec.js +++ b/src/layouts/vehicle-make/make-question/make-question.spec.js @@ -12,11 +12,11 @@ describe("make-question.vue", () => { const makeToSelect = "ford"; //Act - wrapper.setData({ selectedMake: makeToSelect }); + wrapper.setValue({ selectedMake: makeToSelect }); await wrapper.vm.$nextTick(); //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual(["ford"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{selectedMake: "ford"}]); }); }); diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue index 1e5ac38c7..ac6ff45bb 100644 --- a/src/layouts/vehicle-make/make-question/make-question.vue +++ b/src/layouts/vehicle-make/make-question/make-question.vue @@ -3,7 +3,7 @@ :questionText="questionText" :answers="makes" groupName="Choose Vehicle Make" - v-model="selectedMake" + v-model="modelValue" /> @@ -19,7 +19,6 @@ export default { data() { return { questionText: null, - selectedMake: null, makes: Array, } }, @@ -39,7 +38,7 @@ export default { } }, watch: { - selectedMake(val) { + modelValue(val) { this.$emit("update:modelValue", val); } }, diff --git a/src/layouts/vehicle-model/model-question/model-question.spec.js b/src/layouts/vehicle-model/model-question/model-question.spec.js index d6259eb72..e067cef37 100644 --- a/src/layouts/vehicle-model/model-question/model-question.spec.js +++ b/src/layouts/vehicle-model/model-question/model-question.spec.js @@ -12,11 +12,11 @@ describe("model-question.vue", () => { const modelToSelect = "Civic"; //Act - wrapper.setData({ selectedModel: modelToSelect }); + wrapper.setValue({ selectedModel: modelToSelect }); await wrapper.vm.$nextTick(); //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual(["Civic"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{selectedModel: "Civic"}]); }); }); diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue index a78684b12..68d23bc16 100644 --- a/src/layouts/vehicle-model/model-question/model-question.vue +++ b/src/layouts/vehicle-model/model-question/model-question.vue @@ -3,7 +3,7 @@ :questionText="questionText" :answers="models" groupName="Choose Vehicle Model" - v-model="selectedModel" + v-model="modelValue" /> @@ -19,7 +19,6 @@ export default { data() { return { questionText: null, - selectedModel: null, models: Array, } }, @@ -39,7 +38,7 @@ export default { } }, watch: { - selectedModel(val) { + modelValue(val) { this.$emit("update:modelValue", val); } }, diff --git a/src/layouts/vehicle-style/style-question/style-question.spec.js b/src/layouts/vehicle-style/style-question/style-question.spec.js index f03ce5e96..d346e3e62 100644 --- a/src/layouts/vehicle-style/style-question/style-question.spec.js +++ b/src/layouts/vehicle-style/style-question/style-question.spec.js @@ -12,11 +12,11 @@ describe("style-question.vue", () => { const styleToSelect = "4 Door"; //Act - wrapper.setData({ selectedStyle: styleToSelect }); + wrapper.setValue({ selectedStyle: styleToSelect }); await wrapper.vm.$nextTick(); //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual(["4 Door"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{selectedStyle: "4 Door"}]); }); }); diff --git a/src/layouts/vehicle-style/style-question/style-question.vue b/src/layouts/vehicle-style/style-question/style-question.vue index 6d1e1cd46..a9bbd9fbf 100644 --- a/src/layouts/vehicle-style/style-question/style-question.vue +++ b/src/layouts/vehicle-style/style-question/style-question.vue @@ -3,7 +3,7 @@ :questionText="questionText" :answers="styles" groupName="Choose Vehicle Style" - v-model="selectedStyle" + v-model="modelValue" /> @@ -19,7 +19,6 @@ export default { data() { return { questionText: null, - selectedStyle: null, styles: Array, } }, @@ -39,7 +38,7 @@ export default { } }, watch: { - selectedStyle(val) { + modelValue(val) { this.$emit("update:modelValue", val); } }, diff --git a/src/layouts/vehicle-year/year-question/year-question.spec.js b/src/layouts/vehicle-year/year-question/year-question.spec.js index 3c00dcd9d..4d1a32a34 100644 --- a/src/layouts/vehicle-year/year-question/year-question.spec.js +++ b/src/layouts/vehicle-year/year-question/year-question.spec.js @@ -12,11 +12,11 @@ describe("year-question.vue", () => { const yearToSelect = "2021"; //Act - wrapper.setData({ selectedYear: yearToSelect }); + wrapper.setValue({ modelValue: yearToSelect }); await wrapper.vm.$nextTick(); //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual(["2021"]); + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{modelValue: "2021"}]); }); }); diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue index 1a4a80279..6399abb0c 100644 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ b/src/layouts/vehicle-year/year-question/year-question.vue @@ -3,7 +3,7 @@ :questionText="questionText" :answers="years" groupName="Choose Vehicle Year" - v-model="selectedYear" + v-model="modelValue" /> @@ -18,7 +18,6 @@ export default { data() { return { questionText: null, - selectedYear: null, years: Array, } }, @@ -38,7 +37,7 @@ export default { } }, watch: { - selectedYear(val) { + modelValue(val) { this.$emit("update:modelValue", val); } }, From 80a4de2cc796aaf8b4c5220cf505e880f0244bb6 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 13 Jan 2022 11:56:04 -0500 Subject: [PATCH 2/2] Updating method and action name and awaiting data before page change on vehicle style page --- src/constants/store-actions.js | 2 +- src/layouts/vehicle-style/vehicle-style.spec.js | 4 ++-- src/layouts/vehicle-style/vehicle-style.vue | 9 +++++---- src/store/index.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index c6f1a23a9..d052bed32 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -5,7 +5,7 @@ const storeActions = { GET_VEHICLE_MAKES: "getVehicleMakes", GET_VEHICLE_MODELS: "getVehicleModels", GET_VEHICLE_STYLES: "getVehicleStyles", - GET_VEHICLE: "getVehicle", + SET_VEHICLE: "setVehicle", GET_DAMAGE_OPTIONS: "getDamageOptions", GET_EVOX_IMAGE: "getEvoxImage", LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", diff --git a/src/layouts/vehicle-style/vehicle-style.spec.js b/src/layouts/vehicle-style/vehicle-style.spec.js index 7d3bcaca7..31c1b2487 100644 --- a/src/layouts/vehicle-style/vehicle-style.spec.js +++ b/src/layouts/vehicle-style/vehicle-style.spec.js @@ -142,7 +142,7 @@ describe("vehicle-style.vue", () => { }, actionList: [ { - actionName: storeActions.GET_VEHICLE, + actionName: storeActions.SET_VEHICLE, data: 'mockData' } ] @@ -151,7 +151,7 @@ describe("vehicle-style.vue", () => { //Act vehicleStyle.beforeRouteEnter.call(wrapper.vm, { query: { fmgPage: "vehicle-style" } }, undefined, (c) => c(wrapper.vm)); - wrapper.vm.selectVehicle(); + wrapper.vm.setVehicle(); await nextTick(); //Assert diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue index ff9fb86d3..ea3300036 100644 --- a/src/layouts/vehicle-style/vehicle-style.vue +++ b/src/layouts/vehicle-style/vehicle-style.vue @@ -68,16 +68,17 @@ export default { // route to move backwards this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, - selectVehicle() { - this.dispatchNonBlockingStoreAction(this.storeActions.GET_VEHICLE, {year: this.$store.getters.vehicle.year, make: this.$store.getters.vehicle.make, model: this.$store.getters.vehicle.model, style: this.$store.getters.vehicle.style}); + setVehicle() { + return this.dispatchNonBlockingStoreAction(this.storeActions.SET_VEHICLE, {year: this.$store.getters.vehicle.year, make: this.$store.getters.vehicle.make, model: this.$store.getters.vehicle.model, style: this.$store.getters.vehicle.style}); } }, watch: { selectedStyle(style) { this.$store.commit(this.storeMutations.UPDATE_STYLE, style); - this.selectVehicle(); - this.$router.navigate(this.navigationScenarios.SELECTED_STYLE, this.$route); + this.setVehicle().then(() => { + this.$router.navigate(this.navigationScenarios.SELECTED_STYLE, this.$route); + }); } }, diff --git a/src/store/index.js b/src/store/index.js index 742e4be25..f27a362b5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -129,7 +129,7 @@ export default createStore({ payload: {}, }); }, - getVehicle(context, {year, make, model, style}) { + setVehicle(context, {year, make, model, style}) { return globalMethods.callHttpClient({ methods: endpoints.GetVehicle.method, endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`,