From 8a6dbe7b0cd0dd3dff7846115a47888d61a6dde3 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 12 May 2023 07:33:17 -0400 Subject: [PATCH 1/3] Fixed validation issue when switching between appointment types and fixed broken unit test --- .../shop-question/shop-question.spec.js | 54 ++++++++----------- .../shop-question/shop-question.vue | 4 ++ 2 files changed, 26 insertions(+), 32 deletions(-) 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..1a1e0af98 100644 --- a/src/layouts/service-location/shop-question/shop-question.spec.js +++ b/src/layouts/service-location/shop-question/shop-question.spec.js @@ -435,41 +435,31 @@ 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 { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + modelValue: "003341", + serviceZipCode: "43081", + selectedAppointmentType: "Dropoff", + cmsWidgetName: cmsWidgetName, + }, + mountOptions: { + attachTo: document.body, + }, + }); - // // Act - // wrapper.vm.initializeComponent(shopQuestionInitialData); + // Act + wrapper.vm.initializeComponent(shopQuestionInitialData); - // await wrapper.vm.$nextTick(); - // await wrapper.vm.$nextTick(); - // await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); - // // Assert - // expect(wrapper.vm.answers.length).toEqual(5); - // }); + // 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..d64a2e55e 100644 --- a/src/layouts/service-location/shop-question/shop-question.vue +++ b/src/layouts/service-location/shop-question/shop-question.vue @@ -170,6 +170,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); From e115b2a5c11264e07479a057a4909adbb3ff5924 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 12 May 2023 10:07:23 -0400 Subject: [PATCH 2/3] Added separate emit for the full provider object when a button is clicked --- .../service-location/service-location.vue | 31 ++++++++++++++++--- .../shop-question/shop-question.spec.js | 18 ++++------- .../shop-question/shop-question.vue | 3 +- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 2f2d3a5a7..c5b7b0f3c 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,16 @@ export default { async reloadShopData() { await this.$refs.shopQuestion.reloadShopData(this.zipCode); }, + onProviderSelected(selectedProvider) { + this.selectedProvider = selectedProvider; + }, + }, + watch: { + selectedProvider: { + handler(newValue) { + console.log(newValue); + }, + }, }, 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 1a1e0af98..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, @@ -437,10 +427,14 @@ describe("shop-question.vue", () => { it("Should display the number of shops necessary to show a previously selected shop", async () => { // Arrange + const selectedProvider = { + providerNumber: "003341", + }; + const { wrapper } = setupMocks({ mixins: [mockMixin], props: { - modelValue: "003341", + modelValue: selectedProvider.providerNumber, serviceZipCode: "43081", selectedAppointmentType: "Dropoff", cmsWidgetName: cmsWidgetName, diff --git a/src/layouts/service-location/shop-question/shop-question.vue b/src/layouts/service-location/shop-question/shop-question.vue index d64a2e55e..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() { From 63fa093de933afc953d42c7d14c179b44843b8fc Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 12 May 2023 10:10:13 -0400 Subject: [PATCH 3/3] Removed testing watch --- src/layouts/service-location/service-location.vue | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index c5b7b0f3c..69eef0d8b 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -390,13 +390,6 @@ export default { this.selectedProvider = selectedProvider; }, }, - watch: { - selectedProvider: { - handler(newValue) { - console.log(newValue); - }, - }, - }, components: { alert, serviceZipModalQuestion,