diff --git a/src/digital-components/textbox-question/textbox-question.vue b/src/digital-components/textbox-question/textbox-question.vue index 3544a19d8..7df4436f1 100644 --- a/src/digital-components/textbox-question/textbox-question.vue +++ b/src/digital-components/textbox-question/textbox-question.vue @@ -50,6 +50,7 @@ :autocomplete="autocomplete" /> @@ -185,6 +186,7 @@ export default { // Focus cursor in input when search icon is clicked const field = document.querySelector("input"); field.focus(); + this.$emit("search-icon-click"); }, async imageChanged(e) { let file = e.target.files[0]; diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 551e15ae0..68e9e9481 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -219,7 +219,13 @@ describe("service-location.vue", () => { // Arrange const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + /* ******NOTE: if we ever want to revert back to the old way of service location using shopQuestion instead of shopQuestionPopup uncomment all 30 of the lines in this file that read - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); - , and commment all of the blocks of code referencing shopQuestionPopup directly under them. Also remove reference to shopQuestionPopup in the setupMocks function*/ + + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ ref: "shopQuestionPopup" }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } const mobileFeePart = { partNumber: "MOBILE FEE", @@ -387,7 +393,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -414,7 +426,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -441,7 +459,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -468,7 +492,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -495,7 +525,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -523,7 +559,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -551,7 +593,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -579,7 +627,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -607,7 +661,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -635,7 +695,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -663,7 +729,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -691,7 +763,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -719,7 +797,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -747,7 +831,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -775,7 +865,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -806,7 +902,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -833,7 +935,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -860,7 +968,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -888,7 +1002,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -916,7 +1036,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -944,7 +1070,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -974,7 +1106,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1002,7 +1140,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1030,7 +1174,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1058,7 +1208,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1086,7 +1242,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1114,7 +1276,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1142,7 +1310,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1172,7 +1346,13 @@ describe("service-location.vue", () => { const { wrapper } = setupMocks({}); - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + //wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); + const shopQuestionPopupComponent = wrapper.findComponent({ + ref: "shopQuestionPopup", + }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } // Act await serviceLocation.beforeRouteEnter.call( @@ -1199,5 +1379,12 @@ function setupMocks({ mountOptionsMockData = {} }) { const mountOptions = getMountOptions(mountOptionsMockData); const wrapper = shallowMount(serviceLocation, mountOptions); wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; + if (!wrapper.vm.shopProviderData) { + wrapper.vm.shopProviderData = { shopProviders: [] }; + } + const shopQuestionPopupComponent = wrapper.findComponent({ ref: "shopQuestionPopup" }); + if (shopQuestionPopupComponent.exists()) { + shopQuestionPopupComponent.vm.initializeComponent = jest.fn(); + } return { wrapper, apiPromise }; } diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index ccb2c7866..776fe1199 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -89,6 +89,19 @@