From 52cc88dbcae2493ad7cf1276f0a50b683e2c99cb Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 16 Aug 2023 17:40:57 -0400 Subject: [PATCH 1/4] Move customer-details-modal-question --- .../customer-details-modal-question.spec.js | 2 +- .../customer-details-modal-question.vue | 0 src/layouts/review/review.vue | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/layouts/review/{review-sections/customer-review => }/customer-details-modal-question/customer-details-modal-question.spec.js (96%) rename src/layouts/review/{review-sections/customer-review => }/customer-details-modal-question/customer-details-modal-question.vue (100%) diff --git a/src/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.spec.js b/src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js similarity index 96% rename from src/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.spec.js rename to src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js index a8e0a6f7b..abd264cef 100644 --- a/src/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.spec.js +++ b/src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js @@ -1,7 +1,7 @@ import { shallowMount } from "@vue/test-utils"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import customerDetailsModalQuestion from "@/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question"; +import customerDetailsModalQuestion from "@/layouts/review/customer-details-modal-question/customer-details-modal-question"; const testConstants = { previousCustomerValues: { diff --git a/src/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.vue b/src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue similarity index 100% rename from src/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.vue rename to src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue diff --git a/src/layouts/review/review.vue b/src/layouts/review/review.vue index fe14e8f7e..0c9fa1533 100644 --- a/src/layouts/review/review.vue +++ b/src/layouts/review/review.vue @@ -115,7 +115,7 @@ import serviceLocationReview from "@/layouts/review/review-sections/service-loca import scheduleReview from "@/layouts/review/review-sections/schedule-review/schedule-review"; import customerReview from "@/layouts/review/review-sections/customer-review/customer-review"; -import customerDetailsModalQuestion from "@/layouts/review/review-sections/customer-review/customer-details-modal-question/customer-details-modal-question.vue"; +import customerDetailsModalQuestion from "@/layouts/review/customer-details-modal-question/customer-details-modal-question.vue"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; From d5e47707982c0307fc00a1f5e642e38cb5cfaa4a Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 17 Aug 2023 10:07:40 -0400 Subject: [PATCH 2/4] Change modal to back-nav --- .../customer-details-modal-question.spec.js | 150 ------------------ .../customer-details-modal-question.vue | 148 ----------------- src/layouts/review/review.vue | 12 +- .../router-constants/navigation-scenarios.js | 1 + src/router/router-constants/routing-table.js | 4 + 5 files changed, 9 insertions(+), 306 deletions(-) delete mode 100644 src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js delete mode 100644 src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue diff --git a/src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js b/src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js deleted file mode 100644 index abd264cef..000000000 --- a/src/layouts/review/customer-details-modal-question/customer-details-modal-question.spec.js +++ /dev/null @@ -1,150 +0,0 @@ -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; - -import customerDetailsModalQuestion from "@/layouts/review/customer-details-modal-question/customer-details-modal-question"; - -const testConstants = { - previousCustomerValues: { - firstName: "First", - lastName: "Last", - emailAddress: "builddigitaltest@safelite.com", - phoneNumber: "111-111-1111", - isSmsOptIn: false, - }, - newValues: { - firstName: "New First", - lastName: "New Last", - emailAddress: "builddigitaltest2@safelite.com", - phoneNumber: "222-222-2222", - isSmsOptIn: true, - }, -}; - -let cmsContent; - -describe("Customer Details Modal", () => { - beforeEach(() => { - cmsContent = {}; - }); - - describe("Submit", () => { - test("Should push to store if a field has changed", async () => { - // Arrange - let props = generateDefaultProps(); - - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - wrapper.vm.onModalOpened(); - - wrapper.vm.firstName = testConstants.newValues.firstName; - - await wrapper.vm.setContactDetails(); - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled(); - expect(wrapper.vm.closeModal).toHaveBeenCalled(); - }); - - test("Should not push to store if no fields have changed", async () => { - // Arrange - let props = generateDefaultProps(); - - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - wrapper.vm.onModalOpened(); - - await wrapper.vm.setContactDetails(); - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.dispatchStoreAction).not.toHaveBeenCalled(); - expect(wrapper.vm.closeModal).toHaveBeenCalled(); - }); - }); - - describe("Default values", () => { - test("Should populate on open", () => { - // Arrange - let props = generateDefaultProps(); - - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - wrapper.vm.onModalOpened(); - - // Assert - expect(wrapper.vm.firstName).toBe(testConstants.previousCustomerValues.firstName); - expect(wrapper.vm.lastName).toBe(testConstants.previousCustomerValues.lastName); - expect(wrapper.vm.emailAddress).toBe(testConstants.previousCustomerValues.emailAddress); - expect(wrapper.vm.phoneNumber).toBe(testConstants.previousCustomerValues.phoneNumber); - expect(wrapper.vm.isSmsOptIn).toBe(testConstants.previousCustomerValues.isSmsOptIn); - }); - - test("Should replace old values on open", async () => { - // Arrange - let props = generateDefaultProps(); - - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - wrapper.vm.firstName = testConstants.newValues.firstName; - wrapper.vm.lastName = testConstants.newValues.lastName; - wrapper.vm.emailAddress = testConstants.newValues.emailAddress; - wrapper.vm.phoneNumber = testConstants.newValues.phoneNumber; - wrapper.vm.isSmsOptIn = testConstants.newValues.isSmsOptIn; - - wrapper.vm.onModalOpened(); - - // Assert - expect(wrapper.vm.firstName).toBe(testConstants.previousCustomerValues.firstName); - expect(wrapper.vm.lastName).toBe(testConstants.previousCustomerValues.lastName); - expect(wrapper.vm.emailAddress).toBe(testConstants.previousCustomerValues.emailAddress); - expect(wrapper.vm.phoneNumber).toBe(testConstants.previousCustomerValues.phoneNumber); - expect(wrapper.vm.isSmsOptIn).toBe(testConstants.previousCustomerValues.isSmsOptIn); - }); - }); -}); - -function generateDefaultProps() { - return { - previousCustomerValues: { - firstName: testConstants.previousCustomerValues.firstName, - lastName: testConstants.previousCustomerValues.lastName, - emailAddress: testConstants.previousCustomerValues.emailAddress, - phoneNumber: testConstants.previousCustomerValues.phoneNumber, - isSmsOptIn: testConstants.previousCustomerValues.isSmsOptIn, - }, - }; -} - -function setupMocks(customMountOptions) { - const mountOptions = getMountOptions(customMountOptions); - - const mockMixin = { - methods: { - getCmsContent: jest.fn((widgetName, cmsFieldName) => { - return cmsContent?.[widgetName]?.[cmsFieldName] ?? ""; - }), - }, - }; - - mountOptions.global.mixins = [mockMixin]; - - const wrapper = shallowMount(customerDetailsModalQuestion, mountOptions); - wrapper.vm.setCmsContent = jest.fn(); - wrapper.vm.openModal = jest.fn(); - wrapper.vm.closeModal = jest.fn(); - wrapper.vm.dispatchStoreAction = jest.fn(); - return { wrapper }; -} diff --git a/src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue b/src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue deleted file mode 100644 index 0b08abee7..000000000 --- a/src/layouts/review/customer-details-modal-question/customer-details-modal-question.vue +++ /dev/null @@ -1,148 +0,0 @@ - - - diff --git a/src/layouts/review/review.vue b/src/layouts/review/review.vue index 0c9fa1533..be0af585e 100644 --- a/src/layouts/review/review.vue +++ b/src/layouts/review/review.vue @@ -89,10 +89,6 @@
- - diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index ce2f32134..10339a6a0 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -52,6 +52,7 @@ const navigationScenarios = { CLICKED_SERVICE_PACKAGE_EDIT: "CLICKED_SERVICE_PACKAGE_EDIT", CLICKED_SERVICE_LOCATION_EDIT: "CLICKED_SERVICE_LOCATION_EDIT", CLICKED_SCHEDULE_EDIT: "CLICKED_SCHEDULE_EDIT", + CLICKED_CUSTOMER_EDIT: "CLICKED_CUSTOMER_EDIT", }; export { navigationScenarios }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index f1f83b445..953eaffc3 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -488,6 +488,10 @@ const routingTable = function (store) { scenario: navigationScenarios.CLICKED_SCHEDULE_EDIT, destinationFmgPageValue: fmgPageValues.SCHEDULE, }, + { + scenario: navigationScenarios.CLICKED_CUSTOMER_EDIT, + destinationFmgPageValue: fmgPageValues.CUSTOMER_DETAILS, + }, ], }, ]; From 7ed74f5915f59a7417958941cb0e9e310f3d1a63 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 17 Aug 2023 11:10:48 -0400 Subject: [PATCH 3/4] Remove custom hack from cms as no longer needed --- .../review-sections/customer-review/customer-review.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/layouts/review/review-sections/customer-review/customer-review.vue b/src/layouts/review/review-sections/customer-review/customer-review.vue index d8777d9e4..678dcf0b6 100644 --- a/src/layouts/review/review-sections/customer-review/customer-review.vue +++ b/src/layouts/review/review-sections/customer-review/customer-review.vue @@ -36,10 +36,7 @@ export default { return this.customer?.phoneNumber; }, smsOptIn() { - const rawCmsText = this.getCmsContent(this.cmsWidgetName, "SubheaderText"); - const joinerText = this.customer?.isSmsOptIn ? "in to" : "out of"; - - return rawCmsText.replace("{custom:smsOptInJoiner}", joinerText); + return this.getCmsContent(this.cmsWidgetName, "SubheaderText"); }, }, components: { From 8cae60577a98080f9ba8df67fe916a6e96506c21 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 22 Aug 2023 16:33:13 -0400 Subject: [PATCH 4/4] Update Tests --- .../customer-review/customer-review.spec.js | 61 ++++--------------- 1 file changed, 12 insertions(+), 49 deletions(-) diff --git a/src/layouts/review/review-sections/customer-review/customer-review.spec.js b/src/layouts/review/review-sections/customer-review/customer-review.spec.js index 1bcbbe83b..45627df2e 100644 --- a/src/layouts/review/review-sections/customer-review/customer-review.spec.js +++ b/src/layouts/review/review-sections/customer-review/customer-review.spec.js @@ -9,11 +9,7 @@ const testConstants = { text: "Header", }, sms: { - template: "Test {custom:smsOptInJoiner}", - expected: { - ifTrue: "Test in to", - ifFalse: "Test out of", - }, + text: "Sms", }, }, customer: { @@ -27,7 +23,7 @@ const testConstants = { fullName: "First Last", phoneNumber: "111-111-1111", emailAddress: "builddigitaltest@safelite.com", - smsOptIn: "Test out of", + smsOptIn: "Sms", }, }; @@ -38,7 +34,7 @@ describe("Customer Review Block", () => { cmsContent = { CustomerWidget: { HeaderText: testConstants.cms.header.text, - SubheaderText: testConstants.cms.sms.template, + SubheaderText: testConstants.cms.sms.text, }, }; }); @@ -58,52 +54,19 @@ describe("Customer Review Block", () => { expect(wrapper.vm.header).toEqual(testConstants.cms.header.text); }); - describe("SMS Opt In Text", () => { - test("Should render correctly when opt in is true:", async () => { - // Arrange - let props = generateDefaultProps(); - props.customer.isSmsOptIn = true; + test("Should display sms text from cms", async () => { + // Arrange + let props = generateDefaultProps(); - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.smsOptIn).toEqual(testConstants.cms.sms.expected.ifTrue); + const { wrapper } = setupMocks({ + propsData: props, }); - test("Should render correctly when opt in is false:", async () => { - // Arrange - let props = generateDefaultProps(); - props.customer.isSmsOptIn = false; - const { wrapper } = setupMocks({ - propsData: props, - }); + // Act + await wrapper.vm.$nextTick(); - // Act - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.smsOptIn).toEqual(testConstants.cms.sms.expected.ifFalse); - }); - test("Should render correctly when opt in is null:", async () => { - // Arrange - let props = generateDefaultProps(); - props.customer.isSmsOptIn = null; - - const { wrapper } = setupMocks({ - propsData: props, - }); - - // Act - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.smsOptIn).toEqual(testConstants.cms.sms.expected.ifFalse); - }); + // Assert + expect(wrapper.vm.smsOptIn).toEqual(testConstants.cms.sms.text); }); test("Should render correct display content", async () => {