From 93ed73da317360e8a04bc33bcf5edd86c9931777 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Thu, 15 Aug 2024 10:43:06 -0400 Subject: [PATCH] In progress --- .../order-confirmation.spec.js | 1000 ++++++++++------- .../order-confirmation/order-confirmation.vue | 111 +- 2 files changed, 640 insertions(+), 471 deletions(-) diff --git a/src/layouts/order-confirmation/order-confirmation.spec.js b/src/layouts/order-confirmation/order-confirmation.spec.js index 80cead3a..acf25001 100644 --- a/src/layouts/order-confirmation/order-confirmation.spec.js +++ b/src/layouts/order-confirmation/order-confirmation.spec.js @@ -5,19 +5,22 @@ import orderConfirmation from '@/layouts/order-confirmation/order-confirmation.v import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { useMainStore } from '@/store/index.js'; import settleAllPromises from '@/helpers/layout-helper.js'; -import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; +import { fetchCmsContentForPage, getStringWithCustomValues } from '@/helpers/cms-content-helper'; import { mount } from '@vue/test-utils'; import { createTestingPinia } from '@pinia/testing'; import { nextTick } from 'vue'; import coverageStatuses from '@/constants/coverage-statuses'; import coverageType from '@/constants/coverage-type'; +import { deepClone } from '@/helpers/object-helper'; +import { AppointmentTypeStrings } from '@/constants/schedule-constants'; jest.mock('@/helpers/layout-helper.js', () => jest.fn()); jest.mock('@/helpers/cms-content-helper', () => ({ fetchCmsContentForPage: jest.fn(), processIfStatements: jest.fn(), - splitCopyOnCMSPlaceHolder: jest.fn() + splitCopyOnCMSPlaceHolder: jest.fn(), + getStringWithCustomValues: jest.fn() })); const wordingText = 'wording text {custom:address}'; @@ -124,7 +127,14 @@ const sessionStorage = { vaps: [] }, policy: {}, - damage: {} + damage: {}, + vehicle: { + year: 2000, + make: 'Honda', + model: 'Civic' + }, + customer: {}, + customerPortalLoginToken: 'token' }; const sessionStorageMock = (() => { @@ -199,10 +209,13 @@ describe('OrderConfirmation.vue', () => { window.sessionStorage.removeItem('submittedOrder'); }); describe('Page pre-requisites', () => { - test('If submitted order saved to store, page pre-reqs return true', async () => { + // TODO fix + test.skip('If submitted order saved to store, page pre-reqs return true', async () => { // Arrange - window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage)); - const { wrapper } = getMountedComponent(initialStore); + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage); + }; + const { wrapper } = getMountedComponent({}, {}, mockStoreActions); // Act const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); @@ -301,422 +314,593 @@ describe('OrderConfirmation.vue', () => { }); }); describe('Computed properties', () => { - test('appointmentDateFormatted should return date in expected format', () => { - // Arrange - window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage)); - const { wrapper } = getMountedComponent(initialStore); + describe.skip('customValueMap', () =>{ + test.each([ + 'inShopAppointment', + 'dropOffAppointment', + 'vehicleYear', + 'vehicleMake', + 'vehicleModel', + 'address', + 'inShopDuration', + 'email', + 'CUSTOMER_PORTAL_URL', + 'CUSTOMER_PORTAL_LOGIN_TOKEN' + ])('contains key %p', (key) => { + // Arrange + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage); + }; + const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions); - // Act - const testValue = wrapper.vm.appointmentDateFormatted; + // Act + const keyExists = key in wrapper.vm.customValueMap; - // Assert - expect(testValue).toEqual('Friday, March 1'); + // Assert + expect(keyExists).toBeTruthy(); + }); + test('returns expected vehicle info', () => { + // Arrange + var order = deepClone(sessionStorage); + const year = 1998; + const make = 'Toyota'; + const model = 'Cruse'; + order.vehicle = { + year, make, model + }; + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order); + }; + const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions); + + // Act + const actualYear = wrapper.vm.customValueMap['vehicleYear']; + const actualMake = wrapper.vm.customValueMap['vehicleMake']; + const actualModel = wrapper.vm.customValueMap['vehicleModel']; + + // Assert + expect(actualYear).toBe(year); + expect(actualMake).toBe(make); + expect(actualModel).toBe(model); + }); + test('returns expected customer email', () => { + // Arrange + var order = deepClone(sessionStorage); + const emailAddress = 'email@google.com'; + order.customer.emailAddress = emailAddress; + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order); + }; + const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions); + + // Act + const actualEmail = wrapper.vm.customValueMap['email']; + + // Assert + expect(actualEmail).toBe(emailAddress); + }); + }) + describe.only('confirmationEmailText', () => { + const greaterId = ">"; + const lessId = "<"; + test.each([ + ['test', 'test'], + // [`te${greaterId}st`, 'te>st'], + // [`${greaterId}test${greaterId}`, '>test>'], + // [`te${greaterId}st ${greaterId}`, 'te>st >'], + // [`${lessId} test`, '< test'], + // [`t${lessId}e${lessId}st`, 'tt<'] + ])('given %p returned from cms, returns %p', (rawCms, expected) => { + // Arrange + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage); + }; + const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions); + + // TODO mock return of cms + getStringWithCustomValues.mockImplementationOnce(() => "test 1"); + + // Act + const text = wrapper.vm.confirmationEmailText; + + // Assert + expect(text).toBe(expected); + }); + test('replaces all ">" with >', () => {}); }); - test('appointmentTimeFormatted should return Mobile time in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - appointmentType: 'Mobile' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); + describe.skip('appointmentTimeText', () => { + test.each([ + ['Between 9 AM - 10 AM', '09:00', '10:00'], + ['Between 1 PM - 5 PM', '13:00', '17:00'], + ['Between 8:30 AM - 3 PM', '08:30', '15:00'], + ['Between 1 AM - 2 AM', '01:00', '02:00'], + ['Between 12 AM - 2 AM', '00:00', '02:00'], + ['Between 12 PM - 2 AM', '12:00', '02:00'], + ['Between 11 PM - 12 AM', '23:00', '00:00'] + ])('should return Mobile time in expected format "%p" when start time "%p" and end time "%p"', (expected, startTime, endTime) => { + // Arrange + var order = deepClone(sessionStorage); + order.schedule.startTime = startTime; + order.schedule.endTime = endTime; + order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE; + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order); + }; + const { wrapper } = getMountedComponent({}, {}, mockStoreActions); - // Act - const testValue = wrapper.vm.appointmentTimeFormatted; + // Act + const testValue = wrapper.vm.appointmentTimeText; - // Assert - expect(testValue).toEqual('Between 9 AM - 10 AM'); + // Assert + expect(testValue).toEqual(expected); + }); + test.each([ + ['09:00', '10:00'], + ['13:00', '17:00'], + ['08:30', '15:00'], + ['01:00', '02:00'] + ])('should return Drop off time in same format regardless of start/end time', (startTime, endTime) => { + // Arrange + var order = deepClone(sessionStorage); + order.schedule.startTime = startTime; + order.schedule.endTime = endTime; + order.serviceLocation.appointmentType = AppointmentTypeStrings.DROP_OFF; + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order); + }; + const { wrapper } = getMountedComponent({}, {}, mockStoreActions); + + // Act + const testValue = wrapper.vm.appointmentTimeText; + + // Assert + expect(testValue).toEqual('Drop off before 9:30 AM'); + }); + test.each([ + ['at 9:00 AM', '09:00', '10:00'], + ['at 1:00 PM', '13:00', '17:00'], + ['at 8:30 AM', '08:30', '15:00'], + ['at 1:00 AM', '01:00', '02:00'], + ['at 12:00 AM', '00:00', '02:00'], + ['at 12:00 PM', '12:00', '02:00'] + ])('should return In Shop time in expected format "%p" when start time "%p"', (expected, startTime, endTime) => { + // Arrange + var order = deepClone(sessionStorage); + order.schedule.startTime = startTime; + order.schedule.endTime = endTime; + order.serviceLocation.appointmentType = AppointmentTypeStrings.IN_SHOP; + const mockStoreActions = () => { + useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order); + }; + const { wrapper } = getMountedComponent({}, {}, mockStoreActions); + + // Act + const testValue = wrapper.vm.appointmentTimeText; + + // Assert + expect(testValue).toEqual(expected); + }); }); - test('appointmentTimeFormatted should return Drop Off time in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - appointmentType: 'Dropoff', - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } - } - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentTimeFormatted; - - // Assert - expect(testValue).toEqual('Drop off before 9:30 AM'); + describe('appointmentLocation', () => { + test('mobile location returns service location', () => {}); + test('in shop appointment location returns shop location', () => {}); + test('drop off appointment location returns shop location', () => {}); + test('unknown appointment type returns null', () => {}); }); - test('appointmentTimeFormatted should return In Shop time in expected format', () => { - // Arrange - window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage)); - const { wrapper } = getMountedComponent(initialStore); - - // Act - const testValue = wrapper.vm.appointmentTimeFormatted; - - // Assert - expect(testValue).toEqual('at 9:00 AM'); - }); - test('appointmentWordingText should return Mobile text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - address: '123 Test Way', - address2: '#1', - city: 'Mesa', - state: 'AZ', - zipCode: '12345', - appointmentType: 'Mobile' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentWordingText; - - // Assert - expect(testValue).toEqual('wording text 123 Test Way, #1,
Mesa, AZ 12345'); - }); - test('appointmentWordingText should return Drop Off text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } + describe('serviceLocationFullAddress', () => { + // TODO + test('serviceLocationFullAddress should return text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' }, - appointmentType: 'Dropoff' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentWordingText; - - // Assert - expect(testValue).toEqual('wording text 123 Safelite Street,
Mesa, AZ 12345'); - }); - test('appointmentWordingText should return In Shop text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } + serviceLocation: { + address: '123 Test Way', + address2: '#1', + city: 'Mesa', + state: 'AZ', + zipCode: '12345', + appointmentType: 'Mobile' }, - appointmentType: 'Inshop' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentWordingText; - - // Assert - expect(testValue).toEqual('wording text 123 Safelite Street,
Mesa, AZ 12345'); - }); - test('serviceLocationFullAddress should return text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - address: '123 Test Way', - address2: '#1', - city: 'Mesa', - state: 'AZ', - zipCode: '12345', - appointmentType: 'Mobile' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.serviceLocationFullAddress; - - // Assert - expect(testValue).toEqual('123 Test Way, #1,
Mesa, AZ 12345'); - }); - test('providerFullAddress should return text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible }, - appointmentType: 'Inshop' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.providerFullAddress; - - // Assert - expect(testValue).toEqual('123 Safelite Street,
Mesa, AZ 12345'); - }); - test('appointmentWordingText2 should return Mobile text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - address: '123 Test Way', - address2: '#1', - city: 'Mesa', - state: 'AZ', - zipCode: '12345', - appointmentType: 'Mobile' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentWordingText2; - - // Assert - expect(testValue).toEqual(wordingText); - }); - test('appointmentWordingText2 should return Drop Off and text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } + payment: { + isPayInAdvance: false }, - appointmentType: 'Dropoff' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); - - // Act - const testValue = wrapper.vm.appointmentWordingText2; - const expected = wrapper.vm.getBodyText2FromCms('Test Widget'); - - // Assert - expect(testValue).toEqual(expected); - }); - test('appointmentWordingText2 should return In Shop text in expected format', () => { - // Arrange - const testSessionStorage = { - schedule: { - date: '2019-01-01', - startTime: '09:00', - endTime: '10:00' - }, - serviceLocation: { - provider: { - address: { - streetAddress: '123 Safelite Street', - city: 'Mesa', - state: 'AZ', - zipCode: '12345' - } + lineItems: { + vaps: [] }, - appointmentType: 'Inshop' - }, - insuranceCoverage: { - coverageStatus: coverageStatuses.VERIFIED, - coverageType: coverageType.Deductible - }, - payment: { - isPayInAdvance: false - }, - lineItems: { - vaps: [] - }, - policy: {}, - damage: {} - }; - window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); - const { wrapper } = getMountedComponent(); + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); - // Act - const testValue = wrapper.vm.appointmentWordingText2; - const expected = wrapper.vm.getBodyText2FromCms('Test Widget'); + // Act + const testValue = wrapper.vm.serviceLocationFullAddress; - // Assert - expect(testValue).toEqual(expected); + // Assert + expect(testValue).toEqual('123 Test Way, #1,
Mesa, AZ 12345'); + }); + }); + describe('providerFullAddress', () => { + // TODO + test('providerFullAddress should return text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + provider: { + address: { + streetAddress: '123 Safelite Street', + city: 'Mesa', + state: 'AZ', + zipCode: '12345' + } + }, + appointmentType: 'Inshop' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.providerFullAddress; + + // Assert + expect(testValue).toEqual('123 Safelite Street,
Mesa, AZ 12345'); + }); + }); + describe('appointmentWordingText', () => { + test('mobile location returns mobile wording', () => {}); + test('in shop appointment location returns non mobile wording', () => {}); + test('drop off appointment location returns non mobile wording', () => {}); + test('unknown appointment type returns null', () => {}); + }); + describe('appointmentWordingText2', () => { + test('mobile location returns mobile wording 2', () => {}); + test('in shop appointment location returns non mobile wording 2', () => {}); + test('drop off appointment location returns non mobile wording 2', () => {}); + test('unknown appointment type returns null', () => {}); + }); + describe('isMobileAppointment', () => { + test.each([ + AppointmentTypeStrings.MOBILE, + AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP + ])('mobile appointment type %p returns true', (type) => { + + }); + test.each([ + AppointmentTypeStrings.IN_SHOP, + AppointmentTypeStrings.DROP_OFF, + 'invalid type', + null, + undefined + ])('non mobile appointment type %p returns false', (type) => { + + }); + }); + describe('isInShopAppointment', () => { + test('in shop appointment type returns true', () => { + + }); + test.each([ + AppointmentTypeStrings.MOBILE, + AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP, + AppointmentTypeStrings.DROP_OFF, + 'invalid type', + null, + undefined + ])('non in shop appointment type %p returns false', (type) => { + + }); + }); + describe('isDropOffAppointment', () => { + test('drop off appointment type returns true', () => { + + }); + test.each([ + AppointmentTypeStrings.MOBILE, + AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP, + AppointmentTypeStrings.IN_SHOP, + 'invalid type', + null, + undefined + ])('non drop off appointment type %p returns false', (type) => { + + }); + }); + describe('uncategorized', () => { + // TODO make format date test + test('appointmentDateFormatted should return date in expected format', () => { + // Arrange + window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage)); + const { wrapper } = getMountedComponent(initialStore); + + // Act + const testValue = wrapper.vm.appointmentDateFormatted; + + // Assert + expect(testValue).toEqual('Friday, March 1'); + }); + + test('appointmentWordingText should return Mobile text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + address: '123 Test Way', + address2: '#1', + city: 'Mesa', + state: 'AZ', + zipCode: '12345', + appointmentType: 'Mobile' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText; + + // Assert + expect(testValue).toEqual('wording text 123 Test Way, #1,
Mesa, AZ 12345'); + }); + test('appointmentWordingText should return Drop Off text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + provider: { + address: { + streetAddress: '123 Safelite Street', + city: 'Mesa', + state: 'AZ', + zipCode: '12345' + } + }, + appointmentType: 'Dropoff' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText; + + // Assert + expect(testValue).toEqual('wording text 123 Safelite Street,
Mesa, AZ 12345'); + }); + test('appointmentWordingText should return In Shop text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + provider: { + address: { + streetAddress: '123 Safelite Street', + city: 'Mesa', + state: 'AZ', + zipCode: '12345' + } + }, + appointmentType: 'Inshop' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText; + + // Assert + expect(testValue).toEqual('wording text 123 Safelite Street,
Mesa, AZ 12345'); + }); + + test('appointmentWordingText2 should return Mobile text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + address: '123 Test Way', + address2: '#1', + city: 'Mesa', + state: 'AZ', + zipCode: '12345', + appointmentType: 'Mobile' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText2; + + // Assert + expect(testValue).toEqual(wordingText); + }); + test('appointmentWordingText2 should return Drop Off and text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + provider: { + address: { + streetAddress: '123 Safelite Street', + city: 'Mesa', + state: 'AZ', + zipCode: '12345' + } + }, + appointmentType: 'Dropoff' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText2; + const expected = wrapper.vm.getBodyText2FromCms('Test Widget'); + + // Assert + expect(testValue).toEqual(expected); + }); + test('appointmentWordingText2 should return In Shop text in expected format', () => { + // Arrange + const testSessionStorage = { + schedule: { + date: '2019-01-01', + startTime: '09:00', + endTime: '10:00' + }, + serviceLocation: { + provider: { + address: { + streetAddress: '123 Safelite Street', + city: 'Mesa', + state: 'AZ', + zipCode: '12345' + } + }, + appointmentType: 'Inshop' + }, + insuranceCoverage: { + coverageStatus: coverageStatuses.VERIFIED, + coverageType: coverageType.Deductible + }, + payment: { + isPayInAdvance: false + }, + lineItems: { + vaps: [] + }, + policy: {}, + damage: {} + }; + window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage)); + const { wrapper } = getMountedComponent(); + + // Act + const testValue = wrapper.vm.appointmentWordingText2; + const expected = wrapper.vm.getBodyText2FromCms('Test Widget'); + + // Assert + expect(testValue).toEqual(expected); + }); }); }); + describe('Methods', () => { + describe('formatDate', () => { + // TODO test cases confirm day of week + test.each([ + ['', '2020-04-22'], // Monday, April 22 + ['', '2018-02-01'], // Tuesday, February 1 + ['', '2026-12-30'] // Wednesday, December 30 + ])('returns "%p" given "%p"', (expected, date) => { + + }); + }); + }) }); diff --git a/src/layouts/order-confirmation/order-confirmation.vue b/src/layouts/order-confirmation/order-confirmation.vue index 2374e995..bdd1d5ea 100644 --- a/src/layouts/order-confirmation/order-confirmation.vue +++ b/src/layouts/order-confirmation/order-confirmation.vue @@ -7,7 +7,7 @@
- +
@@ -21,13 +21,13 @@

{{ formatDate(schedule.date) }}

-

{{ appointmentTimeFormatted }}

+

{{ appointmentTimeText }}

${city}, ${state} ${zipCode}`; - - return `${this.serviceLocation.address}, ${ - this.serviceLocation.address2 - ? `${this.serviceLocation.address2},` - : '' - }
${this.serviceLocation.city}, ${this.serviceLocation.state} ${ - this.serviceLocation.zipCode - }`; + appointmentTimeText() { + const { startTime, endTime } = this.schedule; + if (this.isDropOffAppointment){ + return 'Drop off before 9:30 AM'; + } + if (this.isInShopAppointment){ + const formattedStartTime = get12HourTimeFormat(startTime); + return `at ${formattedStartTime}` + } + if (this.isMobileAppointment) { + const mobileStartTime = get12HourTimeMobileFormat(startTime); + const mobileEndTime = get12HourTimeMobileFormat(endTime); + return `Between ${mobileStartTime} - ${mobileEndTime}`; + } + return null; }, - titleCaseProviderAddress() { - return toTitleCase(this.providerAddress?.streetAddress); - }, - titleCaseProviderCity() { - return toTitleCase(this.providerAddress?.city); - }, - appointmentAddress() { + appointmentLocation() { if (this.isMobileAppointment){ return this.serviceLocationFullAddress; } @@ -269,31 +250,33 @@ export default { } return null }, + serviceLocationFullAddress() { + var { address, address2, city, state, zipCode } = this.serviceLocation; + return `${address}, ${address2 ? `${address2},` : ''}
${city}, ${state} ${zipCode}`; + }, providerFullAddress() { - var { state, zipCode } = this.providerAddress; - return this.titleCaseProviderAddress - ? `${this.titleCaseProviderAddress},
${this.titleCaseProviderCity}, ${state} ${zipCode}` + var { streetAddress, city, state, zipCode } = this.providerAddress; + return streetAddress + ? `${toTitleCase(streetAddress)},
${toTitleCase(city)}, ${state} ${zipCode}` : ''; }, appointmentWordingText() { - var wording = null; if (this.isMobileAppointment){ - wording = this.mobileWordingText; + return this.mobileWordingText; } if (this.isInShopAppointment || this.isDropOffAppointment){ - wording = this.dropOffAndInShopWordingText; + return this.nonMobileWordingText; } - return wording; + return null; }, appointmentWordingText2() { - var wording = null; if (this.isMobileAppointment){ - wording = this.mobileWordingText2; + return this.mobileWordingText2; } if (this.isInShopAppointment || this.isDropOffAppointment){ - wording = this.dropOffAndInShopWordingText2; + return this.nonMobileWordingText2; } - return wording; + return null; }, isMobileAppointment() { const mobileAppointmentTypes = [ @@ -398,7 +381,9 @@ export default { 'custom', (v) => { return this.customValueMap[v] } ) - return getStringWithCustomValues(processedIfStatements, this.customValueMap); + const x = getStringWithCustomValues(processedIfStatements, this.customValueMap); + console.log(JSON.stringify(x)); + return x; }, formatDate(date) { // This conversion ensures we don't get get GMT induced date changes