diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 2f2d3a5a7..69eef0d8b 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -71,7 +71,8 @@ { return true; }); +const defaultProvider = { + providerNumber: null, + address: null, + city: null, + state: null, + zip: null, +}; + export default { name: "service-location", data() { @@ -148,7 +157,8 @@ export default { isGlassServiceableMobile: null, isRecalibrationServiceableMobile: null, selectedAppointmentType: null, - selectedProvider: null, + selectedProvider: this.getSelectedProvider(), + selectedProviderNumber: this.getSelectedProvider().providerNumber, mobileFeePart: null, zipContainsMilitaryBase: false, }; @@ -215,7 +225,7 @@ export default { if (newValue.zipCode !== this.zipCode) { this.resetMobileLocation(); this.selectedAppointmentType = null; - this.selectedProvider = null; + this.selectedProvider = defaultProvider; } this.state = newValue.state; @@ -250,7 +260,7 @@ export default { if (!this.selectedAppointmentType == "Mobile") { this.selectedAppointmentType = null; } - this.selectedProvider = null; + this.selectedProvider = defaultProvider; } }, }, @@ -340,6 +350,9 @@ export default { getServiceZipCodeFromStore() { return store.getters.order.serviceLocation.zipCode; }, + getSelectedProvider() { + return store.getters.order.serviceLocation.provider ?? defaultProvider; + }, setMobileFeePart(mobileFeePart) { this.mobileFeePart = mobileFeePart; }, @@ -373,6 +386,9 @@ export default { async reloadShopData() { await this.$refs.shopQuestion.reloadShopData(this.zipCode); }, + onProviderSelected(selectedProvider) { + this.selectedProvider = selectedProvider; + }, }, components: { alert, diff --git a/src/layouts/service-location/shop-question/shop-question.spec.js b/src/layouts/service-location/shop-question/shop-question.spec.js index 75ec50fc5..70a158f0a 100644 --- a/src/layouts/service-location/shop-question/shop-question.spec.js +++ b/src/layouts/service-location/shop-question/shop-question.spec.js @@ -157,17 +157,7 @@ describe("shop-question.vue", () => { const { wrapper } = setupMocks({ mixins: [mockMixin], props: { - modelValue: { - address: { - city: "POWELL", - country: "US", - state: "OH", - streetAddress: "3938 POWELL RD", - zipCode: "43065", - }, - distanceInMiles: 16.2690495685233, - providerNumber: null, - }, + modelValue: null, serviceZipCode: "43081", selectedAppointmentType: "Dropoff", cmsWidgetName: cmsWidgetName, @@ -435,41 +425,35 @@ describe("shop-question.vue", () => { ]); }); - // it("Should display the number of shops necessary to show a previously selected shop", async () => { - // // Arrange - // const { wrapper } = setupMocks({ - // mixins: [mockMixin], - // props: { - // modelValue: { - // address: { - // city: "POWELL", - // country: "US", - // state: "OH", - // streetAddress: "3938 POWELL RD", - // zipCode: "43065", - // }, - // distanceInMiles: 16.2690495685233, - // providerNumber: "003341", - // }, - // serviceZipCode: "43081", - // selectedAppointmentType: "Dropoff", - // cmsWidgetName: cmsWidgetName, - // }, - // mountOptions: { - // attachTo: document.body, - // }, - // }); + it("Should display the number of shops necessary to show a previously selected shop", async () => { + // Arrange + const selectedProvider = { + providerNumber: "003341", + }; - // // Act - // wrapper.vm.initializeComponent(shopQuestionInitialData); + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + modelValue: selectedProvider.providerNumber, + serviceZipCode: "43081", + selectedAppointmentType: "Dropoff", + cmsWidgetName: cmsWidgetName, + }, + mountOptions: { + attachTo: document.body, + }, + }); - // await wrapper.vm.$nextTick(); - // await wrapper.vm.$nextTick(); - // await wrapper.vm.$nextTick(); + // Act + wrapper.vm.initializeComponent(shopQuestionInitialData); - // // Assert - // expect(wrapper.vm.answers.length).toEqual(5); - // }); + await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); + + // Assert + expect(wrapper.vm.answers.length).toEqual(5); + }); it("Should reset the answers when the selected appointment type changes", async () => { // Arrange diff --git a/src/layouts/service-location/shop-question/shop-question.vue b/src/layouts/service-location/shop-question/shop-question.vue index 10c1595b2..f12319d8d 100644 --- a/src/layouts/service-location/shop-question/shop-question.vue +++ b/src/layouts/service-location/shop-question/shop-question.vue @@ -89,7 +89,8 @@ export default { (provider) => provider.providerNumber == newValue ); - this.$emit("update:modelValue", provider); + this.$emit("update:modelValue", newValue); + this.$emit("providerSelected", provider); }, }, displayDropoffInformation() { @@ -170,6 +171,10 @@ export default { this.answers = []; this.shopIndex = 0; this.selectedValue = ""; + + if (this.$refs.buttonQuestion) { + this.$refs.buttonQuestion.resetField(); + } }, async reloadShopData(serviceZipCode) { const result = await this.loadData(serviceZipCode);