diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue index 0062f422..9ed4f4ea 100644 --- a/src/layouts/vehicle-make/make-question/make-question.vue +++ b/src/layouts/vehicle-make/make-question/make-question.vue @@ -40,8 +40,6 @@ }, set: function(newValue) { this.$emit("update:modelValue", newValue); - this.mainStore.updateVehicleMake(newValue); - this.$router.navigate(this.navigationScenarios.SELECTED_MAKE, this.$route) } } }, diff --git a/src/layouts/vehicle-make/vehicle-make.spec.js b/src/layouts/vehicle-make/vehicle-make.spec.js index 7856dfeb..72d3a604 100644 --- a/src/layouts/vehicle-make/vehicle-make.spec.js +++ b/src/layouts/vehicle-make/vehicle-make.spec.js @@ -5,6 +5,7 @@ import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import baseMixin from "@/mixins/base-mixin.js"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { nextTick } from "vue"; +import { useMainStore } from "@/store"; // Components import vehicleMake from "@/layouts/vehicle-make/vehicle-make.vue"; @@ -72,6 +73,25 @@ describe("vehicle-make.vue", () => { }); }); + test("Year set, arePagePrerequisitesValid should be true ", async () => { + //Arrange + const { wrapper } = setupMocks({}); + useMainStore().order.vehicle.year = 2001; + + //Act + vehicleMake.beforeRouteEnter.call( + wrapper.vm, + { query: { issPage: "vehicle-make" } }, + undefined, + (c) => c(wrapper.vm) + ); + + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + + //Assert + expect(arePagePrerequisitesValid).toBe(true); + }); + }); function setupMocks({ diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index cc10d326..3fc8185d 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -42,7 +42,7 @@ }; }, - async beforeRouteEnter(to, from, next) { + async beforeRouteEnter(to, from, next) { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const makeQuestionInitialDataPromise = makeQuestion.methods.loadInitialData(); @@ -76,6 +76,13 @@ this.$route ); }, + arePagePrerequisitesValid() { + console.log(this.mainStore.order) + if (this.mainStore.order.vehicle.year){ + return true; + } + return false; + }, }, components: { makeQuestion, @@ -83,5 +90,14 @@ siteSubHeader, vehicleBanner, }, + watch: { + selectedMake(make) { + this.mainStore.updateVehicleMake(make); + this.$router.navigate( + this.navigationScenarios.SELECTED_MAKE, + this.$route + ); + }, + }, }; \ No newline at end of file diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index 86f06484..96fa0804 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -65,6 +65,22 @@ ); }); }, + + watch: { + selectedYear(year) { + const parsedYear = parseInt(year); + this.mainStore.updateVehicleYear(parsedYear); + this.$router.navigate( + this.navigationScenarios.SELECTED_YEAR, + this.$route + ); + }, + }, + methods: { + arePagePrerequisitesValid() { + return true; + }, + }, components: { yearQuestion, diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue index 28b3c255..0cd35425 100644 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ b/src/layouts/vehicle-year/year-question/year-question.vue @@ -40,8 +40,6 @@ }, set: function(newValue) { this.$emit("update:modelValue", newValue); - this.mainStore.updateVehicleYear(newValue); - this.$router.navigate(this.navigationScenarios.SELECTED_YEAR, this.$route) } } },