From 44644c9ed301ff967ef00ee1935a824533079492 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Mon, 6 Mar 2023 13:18:12 -0500 Subject: [PATCH 01/22] Added initial stub for service-type-question --- .../service-type-question.spec.js | 1 + .../service-type-question.vue | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/layouts/service-location/service-type-question/service-type-question.spec.js create mode 100644 src/layouts/service-location/service-type-question/service-type-question.vue diff --git a/src/layouts/service-location/service-type-question/service-type-question.spec.js b/src/layouts/service-location/service-type-question/service-type-question.spec.js new file mode 100644 index 000000000..66012402c --- /dev/null +++ b/src/layouts/service-location/service-type-question/service-type-question.spec.js @@ -0,0 +1 @@ +test.todo("some test to be written in the future"); \ No newline at end of file diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue new file mode 100644 index 000000000..2a3cdfe22 --- /dev/null +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -0,0 +1,50 @@ + + + From eea249d3c27436e7d8fb91877cfd612162293c16 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 7 Mar 2023 14:04:28 -0500 Subject: [PATCH 02/22] Created service-type-question component --- .../service-type-question.spec.js | 2 +- .../service-type-question.vue | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/layouts/service-location/service-type-question/service-type-question.spec.js b/src/layouts/service-location/service-type-question/service-type-question.spec.js index 66012402c..3d0843e10 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.spec.js +++ b/src/layouts/service-location/service-type-question/service-type-question.spec.js @@ -1 +1 @@ -test.todo("some test to be written in the future"); \ No newline at end of file +test.todo("some test to be written in the future"); diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue index 2a3cdfe22..359e44547 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.vue +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -1,6 +1,6 @@ @@ -29,11 +38,15 @@ // Components import serviceZipModalQuestion from "@/layouts/service-location/service-zip-modal-question/service-zip-modal-question"; import mobileLocationModalQuestions from "@/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions"; +import serviceTypeQuestion from "@/layouts/service-location/service-type-question/service-type-question"; import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; -import { Form } from "vee-validate"; +import { Form, defineRule } from "vee-validate"; +import { required, regex } from "@/helpers/validation-rules"; +import { errorMessages } from "@/constants/error-messages"; + import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; @@ -53,6 +66,7 @@ export default { isZipServiceableMobile: null, isZipServiceableInShop: null, mobileFeePart: null, + selectedServiceType: null }; }, async beforeRouteEnter(to, from, next) { @@ -129,11 +143,12 @@ export default { }, methods: { arePagePrerequisitesValid() { - return ( - store.getters.lineItems.supportingItems !== null && - store.getters.order.serviceLocation.zipCode !== null && - store.getters.payment.isInsurance !== null - ); + return true; + // return ( + // store.getters.lineItems.supportingItems !== null && + // store.getters.order.serviceLocation.zipCode !== null && + // store.getters.payment.isInsurance !== null + // ); }, setData(mobileFeePart) { if (mobileFeePart) { @@ -179,6 +194,7 @@ export default { }, components: { serviceZipModalQuestion, + serviceTypeQuestion, mobileLocationModalQuestions, funnelHeader, funnelFooter, @@ -188,3 +204,11 @@ export default { }, }; + + \ No newline at end of file From 732672c105822a234525c0aa80ccbdab1372bf89 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 7 Mar 2023 14:13:09 -0500 Subject: [PATCH 04/22] Updated styling on vehicle-protected-question to ensure proper alignment --- .../vehicle-protected-question.vue | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue index f5754ea06..c1484500b 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue @@ -51,14 +51,11 @@ export default { From 04efdfcd0f031667f272c04816d4643f40ed8265 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 8 Mar 2023 10:11:48 -0500 Subject: [PATCH 05/22] temp chkin --- .../mobile-location-modal-questions.vue | 1 - .../service-location/service-location.vue | 24 +++++++++++-------- .../service-type-question.vue | 13 ++++++++-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index 0aa64594d..598af5438 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -130,7 +130,6 @@ export default { modalFooterText() { return this.getCmsContent(this.modalWidgetName, "FooterText"); }, - addressModel: { get: function () { return this.modelValue.addressQuestions; diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index e274c120b..37a79d9c8 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -13,10 +13,11 @@ modalWidgetName="ServiceZipModalWidget" /> - + - @@ -43,9 +43,7 @@ import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; -import { Form, defineRule } from "vee-validate"; -import { required, regex } from "@/helpers/validation-rules"; -import { errorMessages } from "@/constants/error-messages"; +import { Form } from "vee-validate"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; @@ -66,7 +64,7 @@ export default { isZipServiceableMobile: null, isZipServiceableInShop: null, mobileFeePart: null, - selectedServiceType: null + selectedServiceType: null, }; }, async beforeRouteEnter(to, from, next) { @@ -113,6 +111,8 @@ export default { this.state = newValue.state; this.zipCode = newValue.zipCode; this.isServiceable = newValue.isServiceable; + + console.log(this); }, }, mobileLocationQuestions: { @@ -176,6 +176,10 @@ export default { }); }, resetMobileLocation(updatedServiceZipCode) { + if (!this.$refs.mobileLocationModalQuestions) { + return; + } + this.streetAddress = ""; this.apartmentNumberOrBusinessName = ""; this.city = ""; @@ -210,5 +214,5 @@ export default { & > span { text-align: center; } -} - \ No newline at end of file +} + diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue index 359e44547..528f7487b 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.vue +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -17,6 +17,8 @@ diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 3e8f506d5..cb22c5844 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -24,7 +24,7 @@ :isGlassServiceableMobile="isGlassServiceableMobile" :isRecalibrationServiceableMobile="isRecalibrationServiceableMobile" ref="serviceTypeQuestion" - groupName="ServiceTypeQuestion" + groupName="serviceTypeQuestion" cmsWidgetName="ServiceTypeQuestionWidget" validationRules="option-required" /> @@ -49,6 +50,7 @@ export default { internalModel: this.copyModel(this.modelValue), serviceZipCodeTextInputId: "", displayInvalidZipAlert: false, + }; }, props: { diff --git a/src/store/index.js b/src/store/index.js index 5a0e86846..a64c279b6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -926,14 +926,13 @@ export const actions = { }); }, - getServiceabilityDetails(context, { serviceZipCode, lineItems }) { - return globalMethods.callMockHttpClient({ + getServiceabilityDetails(context, { serviceZipCode }) { + const lineItems = context.getters.order.lineItems; + const lineItemsToSend = [...lineItems.supportingItems]; + const encodedLineItems = encodeURIComponent(JSON.stringify(lineItemsToSend)) + return globalMethods.callHttpClient({ method: endpoints.GetServiceabilityDetails.method, - //TODO: Remove Mocky Endpoints - //endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable - //endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop - //endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile - endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options + endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}`, }); }, @@ -1664,3 +1663,12 @@ function getLineItemQueryStringForPricing(lineItems) { }) .join(""); } + +function getLineItemQueryStringForServiceability(lineItems) { + return lineItems + .map((lineItem) => { + let queryStringSnippet = `&lineItems=${lineItem.partNumber}`; + return queryStringSnippet; + }) + .join(""); +} diff --git a/src/ux-components/modal-button-main/modal-button-main.spec.js b/src/ux-components/modal-button-main/modal-button-main.spec.js new file mode 100644 index 000000000..41e244a72 --- /dev/null +++ b/src/ux-components/modal-button-main/modal-button-main.spec.js @@ -0,0 +1,187 @@ +import { shallowMount } from "@vue/test-utils"; +import buttonMain from "./button-main"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import { nextTick } from "vue"; + +describe("buttonMain.vue", () => { + it("Should return btn-primary class", () => { + // Arrange/Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + isPrimary: true, + }, + }) + ); + const button = wrapper.find("button"); + + // Assert + expect(button.attributes("class")).toContain("btn-primary"); + }); + + it("Should return aria-disabled state", () => { + // Arrange/Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + isDisabled: true, + }, + }) + ); + const button = wrapper.find("button"); + + // Assert + expect(button.attributes()["aria-disabled"]).toEqual("true"); + }); + + it("Should return loader color", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderColor: "blue", + loaderEnabled: true, + }, + }) + ); + + // Act + wrapper.vm.clicked(); + await nextTick(); + + // Assert + const loader = wrapper.find("loader-stub"); + expect(loader.attributes("class")).toContain("blue"); + }); + + it("Should return loader position", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + }, + }) + ); + + // Act + wrapper.vm.clicked(); + await nextTick(); + + // Assert + const loader = wrapper.find("loader-stub"); + expect(loader.attributes("class")).toContain("right"); + }); + + it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + }, + }) + ); + + wrapper.setData({ + isLoaderDisplayed: true, + }); + + // Act + wrapper.vm.removeLoader(); + await nextTick(); + + // Assert + const loader = wrapper.find("loader-stub"); + expect(wrapper.vm.isLoaderDisplayed).toBe(false); + }); + + it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + }, + }) + ); + + wrapper.setData({ + isLoaderDisplayed: true, + }); + + // Act + wrapper.vm.resetButtonStyle(); + await nextTick(); + + // Assert + expect(wrapper.vm.isLoaderDisplayed).toBe(false); + }); + + it("Should emit 'click-event' event when clicking if the button is enabled", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + isDisabled: false, + }, + }) + ); + + const buttonElement = wrapper.find("button"); + + // Act + buttonElement.trigger("click"); + + await nextTick(); + + // Assert + expect(wrapper.emitted("click-event")).toBeTruthy(); + }); + + it("Should not emit 'click-event' event when clicking if the button is disabled", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + isDisabled: true, + }, + }) + ); + + const buttonElement = wrapper.find("button"); + + // Act + buttonElement.trigger("click"); + + await nextTick(); + + // Assert + expect(wrapper.emitted("click-event")).toBeFalsy(); + }); +}); + +function setupMocks(mountOptionsMockData = {}) { + const defaultMountOptions = { route: { query: { fmgPage: "page-name" } } }; + const baseMountOptions = getMountOptions( + Object.assign(defaultMountOptions, mountOptionsMockData) + ); + const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions); + + return allMountOptions; +} diff --git a/src/ux-components/modal-button-main/modal-button-main.vue b/src/ux-components/modal-button-main/modal-button-main.vue new file mode 100644 index 000000000..eaffdf2d0 --- /dev/null +++ b/src/ux-components/modal-button-main/modal-button-main.vue @@ -0,0 +1,153 @@ + + + + + From 6b25e8ea47601f60edb7981e30695fa89b90f09d Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Mon, 27 Mar 2023 13:22:32 -0400 Subject: [PATCH 15/22] Merge outstanding changes --- .../mobile-location-modal-questions.vue | 14 ++++++++++---- src/layouts/service-location/service-location.vue | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index a319a85b9..d0128bcd3 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -61,7 +61,11 @@ import vehicleProtectedQuestion from "@/layouts/service-location/mobile-location // Helpers import { deepClone } from "@/layouts/service-location/helpers/object-cloning-helper/object-cloning-helper"; -import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; + +import { + getPricedMobileFeePart, + getServiceabilityDetails, +} from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; export default { name: "mobile-location-modal-questions", @@ -187,13 +191,15 @@ export default { } else { // retrieve mobile fee part const serviceZipCode = this.internalModel.addressQuestions.zipCode; - const mobileFeePart = await getPricedMobileFeePart(serviceZipCode); - + + // retrieve serviceability details + const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode); + // update content related to service zip code this.$emit("updated-mobile-fee-part", mobileFeePart); this.$emit("updated-serviceability", serviceabilityDetails.data); - this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); + this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); // Update the page level model this.$emit("update:modelValue", this.internalModel); diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index b049bb0cb..4eaad2cbb 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -37,6 +37,7 @@ linkWidgetName="MobileLocationLinkWidget" modalWidgetName="MobileLocationModalWidget" /> Date: Mon, 27 Mar 2023 13:31:26 -0400 Subject: [PATCH 16/22] Patched in missing Military code --- src/layouts/service-location/service-location.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 4eaad2cbb..6b059079f 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -10,6 +10,7 @@ :mobileFeePart="mobileFeePart" @updated-mobile-fee-part="setMobileFeePart" @updated-serviceability="setServiceabilityDetails" + @updated-contains-military-base="setContainsMilitaryBase" linkWidgetName="ServiceZipLinkWidget" modalWidgetName="ServiceZipModalWidget" /> From 31355e1e735888a3b3283a099614b735592a14e1 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Mon, 27 Mar 2023 13:37:30 -0400 Subject: [PATCH 17/22] added comment --- .../service-zip-modal-question/service-zip-modal-question.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index ed4a3ea69..0698fc340 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -149,6 +149,8 @@ export default { // retrieve mobile fee part const serviceZipCode = this.internalModel.zipCode; const mobileFeePart = await getPricedMobileFeePart(serviceZipCode); + + // retrieve serviceability details const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode); // update content related to service zip code From 902cd698582cb44c5fb93bd609faf81336b55df2 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 28 Mar 2023 08:28:55 -0400 Subject: [PATCH 18/22] WIP --- src/layouts/service-location/service-location.vue | 8 ++++---- .../service-type-question/service-type-question.vue | 11 +++++++++-- src/store/index.js | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 6b059079f..e6613cda8 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -190,10 +190,10 @@ export default { }, }, showMilitaryZipAlert() { - return ( - this.zipContainsMilitaryBase && - (this.isZipServiceableMobile == null || this.isZipServiceableMobile === true) - ); + const isZipServiceableMobile = + this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; + + return this.zipContainsMilitaryBase && isZipServiceableMobile; }, }, methods: { diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue index b74ad989f..d8ba9e864 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.vue +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -55,8 +55,13 @@ export default { return filteredAnswers; }, serviceability() { - const mobileAvailable = - this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; + let mobileAvailable; + if (this.IsRecalibrationServiceableMobile == null) { + mobileAvailable = this.isGlassServiceableMobile; + } else { + mobileAvailable = this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; + } + const inshopAvailable = this.isGlassServiceableInshop && this.isRecalibrationServiceableInshop; @@ -87,6 +92,8 @@ export default { handler(newValue) { if (newValue == "MobileOnly") { this.selectedValues = "Mobile"; + } else { + this.selectedValues = null; } }, }, diff --git a/src/store/index.js b/src/store/index.js index 413d2f8b0..24d9e5b84 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -43,6 +43,7 @@ const getDefaultState = () => { state: null, zipCode: null, zipCodeCtu: null, + serviceType: null, }, customer: { emailAddress: null, From 04854a455cf3fbe1d1d589fe2a1a60f271ce7fc7 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 28 Mar 2023 08:39:54 -0400 Subject: [PATCH 19/22] WIP --- .../service-type-question/service-type-question.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue index d8ba9e864..4f1a36ac7 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.vue +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -59,7 +59,8 @@ export default { if (this.IsRecalibrationServiceableMobile == null) { mobileAvailable = this.isGlassServiceableMobile; } else { - mobileAvailable = this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; + mobileAvailable = + this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; } const inshopAvailable = From 0bde42e0d2cda395b5be2aad279d20cf1763107c Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 28 Mar 2023 13:20:12 -0400 Subject: [PATCH 20/22] WIP --- src/digital-components/modal/modal.vue | 4 ++-- .../mobile-location-modal-questions.vue | 4 ++++ src/layouts/service-location/service-location.vue | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/digital-components/modal/modal.vue b/src/digital-components/modal/modal.vue index 32a00ad15..ba7e60eb6 100644 --- a/src/digital-components/modal/modal.vue +++ b/src/digital-components/modal/modal.vue @@ -29,7 +29,7 @@ Date: Tue, 28 Mar 2023 13:47:09 -0400 Subject: [PATCH 21/22] Updated existing unit tests --- src/digital-components/modal/modal.spec.js | 4 +- .../mobile-location-modal-questions.spec.js | 14 +++++++ .../service-location/service-location.spec.js | 14 +++++++ .../service-zip-modal-question.spec.js | 14 +++++++ .../modal-button-main.spec.js | 38 +++++++++---------- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/digital-components/modal/modal.spec.js b/src/digital-components/modal/modal.spec.js index a948fe99a..e4d8692d4 100644 --- a/src/digital-components/modal/modal.spec.js +++ b/src/digital-components/modal/modal.spec.js @@ -92,7 +92,7 @@ describe("modal.vue", () => { wrapper.vm.resetButtonStyle = resetButtonStyle; // Act - const buttonMain = wrapper.findComponent({ ref: "buttonMain" }); + const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" }); await buttonMain.trigger("click-event"); // Assert @@ -124,7 +124,7 @@ describe("modal.vue", () => { wrapper.vm.resetButtonStyle = resetButtonStyle; // Act - const buttonMain = wrapper.findComponent({ ref: "buttonMain" }); + const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" }); await buttonMain.trigger("click-event"); // Assert diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js index fbea693b9..66bd93799 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js @@ -110,12 +110,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index b48fa2f06..2a056c4d1 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -32,12 +32,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js index 407e129cf..6c9cf42f5 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js @@ -33,12 +33,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/ux-components/modal-button-main/modal-button-main.spec.js b/src/ux-components/modal-button-main/modal-button-main.spec.js index 41e244a72..bd3587f22 100644 --- a/src/ux-components/modal-button-main/modal-button-main.spec.js +++ b/src/ux-components/modal-button-main/modal-button-main.spec.js @@ -1,21 +1,21 @@ import { shallowMount } from "@vue/test-utils"; -import buttonMain from "./button-main"; +import modalButtonMain from "./modal-button-main"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { nextTick } from "vue"; -describe("buttonMain.vue", () => { +describe("modal-button-main.vue", () => { it("Should return btn-primary class", () => { // Arrange/Act const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { isPrimary: true, }, }) ); const button = wrapper.find("button"); - + // Assert expect(button.attributes("class")).toContain("btn-primary"); }); @@ -23,9 +23,9 @@ describe("buttonMain.vue", () => { it("Should return aria-disabled state", () => { // Arrange/Act const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { isDisabled: true, }, }) @@ -39,9 +39,9 @@ describe("buttonMain.vue", () => { it("Should return loader color", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderColor: "blue", loaderEnabled: true, }, @@ -60,9 +60,9 @@ describe("buttonMain.vue", () => { it("Should return loader position", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -81,9 +81,9 @@ describe("buttonMain.vue", () => { it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -106,9 +106,9 @@ describe("buttonMain.vue", () => { it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -130,9 +130,9 @@ describe("buttonMain.vue", () => { it("Should emit 'click-event' event when clicking if the button is enabled", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, isDisabled: false, @@ -154,9 +154,9 @@ describe("buttonMain.vue", () => { it("Should not emit 'click-event' event when clicking if the button is disabled", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, isDisabled: true, From 1639045d748524cf8ce9f0b7add773d8cae741a0 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 29 Mar 2023 07:46:42 -0400 Subject: [PATCH 22/22] Unit tests completed --- .../service-type-question.spec.js | 186 +++++++++++++++++- .../modal-button-main.spec.js | 2 +- 2 files changed, 186 insertions(+), 2 deletions(-) diff --git a/src/layouts/service-location/service-type-question/service-type-question.spec.js b/src/layouts/service-location/service-type-question/service-type-question.spec.js index 3d0843e10..13b727c54 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.spec.js +++ b/src/layouts/service-location/service-type-question/service-type-question.spec.js @@ -1 +1,185 @@ -test.todo("some test to be written in the future"); +import { shallowMount } from "@vue/test-utils"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import serviceTypeQuestion from "./service-type-question"; + +const mockCmsContent = { + QuestionText: "Choose a service option:", + Answers: [ + { + AnswerImageUrl: "", + Name: "Mobile", + SubText: "", + SubWidgetName: "", + Text: "Mobile", + }, + { + AnswerImageUrl: "", + Name: "Inshop", + SubText: "", + SubWidgetName: "", + Text: "In-shop", + }, + { + AnswerImageUrl: "", + Name: "DropOff", + SubText: "", + SubWidgetName: "", + Text: "Drop-off", + }, + ], +}; + +const cmsWidgetName = "ServiceTypeQuestionWidget"; +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + if (widgetName === cmsWidgetName) { + return mockCmsContent[cmsFieldName]; + } + + return null; + }), + }, +}; + +describe("service-type-question.vue", () => { + it("Should display all options if both in-shop and mobile are available", async () => { + // Arrange/Act + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + cmsWidgetName: cmsWidgetName, + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }, + mountOptions: { + attachTo: document.body, + }, + }); + + // Assert + expect(wrapper.vm.answersToDisplay).toEqual([ + { + AnswerImageUrl: "", + Name: "Mobile", + SubText: "", + SubWidgetName: "", + Text: "Mobile", + }, + { + AnswerImageUrl: "", + Name: "Inshop", + SubText: "", + SubWidgetName: "", + Text: "In-shop", + }, + { + AnswerImageUrl: "", + Name: "DropOff", + SubText: "", + SubWidgetName: "", + Text: "Drop-off", + }, + ]); + }); + + it("Should display only the In-Shop and Drop-Off answers when only in-shop service is available", async () => { + // Arrange/Act + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + cmsWidgetName: cmsWidgetName, + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: false, + isRecalibrationServiceableMobile: false, + }, + mountOptions: { + attachTo: document.body, + }, + }); + + // Assert + expect(wrapper.vm.answersToDisplay).toEqual([ + { + AnswerImageUrl: "", + Name: "Inshop", + SubText: "", + SubWidgetName: "", + Text: "In-shop", + }, + { + AnswerImageUrl: "", + Name: "DropOff", + SubText: "", + SubWidgetName: "", + Text: "Drop-off", + }, + ]); + }); + + it("Should display only the Mobile answer when only mobile service is available", async () => { + // Arrange/Act + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + cmsWidgetName: cmsWidgetName, + isGlassServiceableInshop: false, + isRecalibrationServiceableInshop: false, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }, + mountOptions: { + attachTo: document.body, + }, + }); + + // Assert + expect(wrapper.vm.answersToDisplay).toEqual([ + { + AnswerImageUrl: "", + Name: "Mobile", + SubText: "", + SubWidgetName: "", + Text: "Mobile", + }, + ]); + }); + + it("Should display no answers if neither in-shop nor mobile service are available", async () => { + // Arrange/Act + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + cmsWidgetName: cmsWidgetName, + isGlassServiceableInshop: false, + isRecalibrationServiceableInshop: false, + isGlassServiceableMobile: false, + isRecalibrationServiceableMobile: false, + }, + mountOptions: { + attachTo: document.body, + }, + }); + + // Assert + expect(wrapper.vm.answersToDisplay).toEqual([]); + }); +}); + +function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) { + const resultingMountOptions = getMountOptions({ + ...mountOptions, + mixins, + }); + + if (props) resultingMountOptions.propsData = props; + + const wrapper = isShallowMount + ? shallowMount(serviceTypeQuestion, resultingMountOptions) + : mount(serviceTypeQuestion, resultingMountOptions); + + return { wrapper }; +} diff --git a/src/ux-components/modal-button-main/modal-button-main.spec.js b/src/ux-components/modal-button-main/modal-button-main.spec.js index bd3587f22..f212d8ec3 100644 --- a/src/ux-components/modal-button-main/modal-button-main.spec.js +++ b/src/ux-components/modal-button-main/modal-button-main.spec.js @@ -15,7 +15,7 @@ describe("modal-button-main.vue", () => { }) ); const button = wrapper.find("button"); - + // Assert expect(button.attributes("class")).toContain("btn-primary"); });