In progress
This commit is contained in:
parent
23de2db48e
commit
93ed73da31
2 changed files with 640 additions and 471 deletions
|
|
@ -5,19 +5,22 @@ import orderConfirmation from '@/layouts/order-confirmation/order-confirmation.v
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { useMainStore } from '@/store/index.js';
|
import { useMainStore } from '@/store/index.js';
|
||||||
import settleAllPromises from '@/helpers/layout-helper.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 { mount } from '@vue/test-utils';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import coverageStatuses from '@/constants/coverage-statuses';
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
import coverageType from '@/constants/coverage-type';
|
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/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
fetchCmsContentForPage: jest.fn(),
|
fetchCmsContentForPage: jest.fn(),
|
||||||
processIfStatements: jest.fn(),
|
processIfStatements: jest.fn(),
|
||||||
splitCopyOnCMSPlaceHolder: jest.fn()
|
splitCopyOnCMSPlaceHolder: jest.fn(),
|
||||||
|
getStringWithCustomValues: jest.fn()
|
||||||
}));
|
}));
|
||||||
const wordingText = 'wording text {custom:address}';
|
const wordingText = 'wording text {custom:address}';
|
||||||
|
|
||||||
|
|
@ -124,7 +127,14 @@ const sessionStorage = {
|
||||||
vaps: []
|
vaps: []
|
||||||
},
|
},
|
||||||
policy: {},
|
policy: {},
|
||||||
damage: {}
|
damage: {},
|
||||||
|
vehicle: {
|
||||||
|
year: 2000,
|
||||||
|
make: 'Honda',
|
||||||
|
model: 'Civic'
|
||||||
|
},
|
||||||
|
customer: {},
|
||||||
|
customerPortalLoginToken: 'token'
|
||||||
};
|
};
|
||||||
|
|
||||||
const sessionStorageMock = (() => {
|
const sessionStorageMock = (() => {
|
||||||
|
|
@ -199,10 +209,13 @@ describe('OrderConfirmation.vue', () => {
|
||||||
window.sessionStorage.removeItem('submittedOrder');
|
window.sessionStorage.removeItem('submittedOrder');
|
||||||
});
|
});
|
||||||
describe('Page pre-requisites', () => {
|
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
|
// Arrange
|
||||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
const mockStoreActions = () => {
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage);
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -301,18 +314,183 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Computed properties', () => {
|
describe('Computed properties', () => {
|
||||||
test('appointmentDateFormatted should return date in expected format', () => {
|
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
|
// Arrange
|
||||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
const mockStoreActions = () => {
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage);
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentDateFormatted;
|
const keyExists = key in wrapper.vm.customValueMap;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('Friday, March 1');
|
expect(keyExists).toBeTruthy();
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return Mobile time in expected format', () => {
|
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`, 't<e<st'],
|
||||||
|
// [`${greaterId}t${lessId}${lessId}e st${greaterId}`, '>t<<e st>']
|
||||||
|
])('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 >', () => {});
|
||||||
|
});
|
||||||
|
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.appointmentTimeText;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
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', () => {});
|
||||||
|
});
|
||||||
|
describe('serviceLocationFullAddress', () => {
|
||||||
|
// TODO
|
||||||
|
test('serviceLocationFullAddress should return text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testSessionStorage = {
|
const testSessionStorage = {
|
||||||
schedule: {
|
schedule: {
|
||||||
|
|
@ -321,6 +499,11 @@ describe('OrderConfirmation.vue', () => {
|
||||||
endTime: '10:00'
|
endTime: '10:00'
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
serviceLocation: {
|
||||||
|
address: '123 Test Way',
|
||||||
|
address2: '#1',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345',
|
||||||
appointmentType: 'Mobile'
|
appointmentType: 'Mobile'
|
||||||
},
|
},
|
||||||
insuranceCoverage: {
|
insuranceCoverage: {
|
||||||
|
|
@ -340,12 +523,15 @@ describe('OrderConfirmation.vue', () => {
|
||||||
const { wrapper } = getMountedComponent();
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentTimeFormatted;
|
const testValue = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('Between 9 AM - 10 AM');
|
expect(testValue).toEqual('123 Test Way, #1,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return Drop Off time in expected format', () => {
|
});
|
||||||
|
describe('providerFullAddress', () => {
|
||||||
|
// TODO
|
||||||
|
test('providerFullAddress should return text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testSessionStorage = {
|
const testSessionStorage = {
|
||||||
schedule: {
|
schedule: {
|
||||||
|
|
@ -354,7 +540,6 @@ describe('OrderConfirmation.vue', () => {
|
||||||
endTime: '10:00'
|
endTime: '10:00'
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
serviceLocation: {
|
||||||
appointmentType: 'Dropoff',
|
|
||||||
provider: {
|
provider: {
|
||||||
address: {
|
address: {
|
||||||
streetAddress: '123 Safelite Street',
|
streetAddress: '123 Safelite Street',
|
||||||
|
|
@ -362,7 +547,8 @@ describe('OrderConfirmation.vue', () => {
|
||||||
state: 'AZ',
|
state: 'AZ',
|
||||||
zipCode: '12345'
|
zipCode: '12345'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
appointmentType: 'Inshop'
|
||||||
},
|
},
|
||||||
insuranceCoverage: {
|
insuranceCoverage: {
|
||||||
coverageStatus: coverageStatuses.VERIFIED,
|
coverageStatus: coverageStatuses.VERIFIED,
|
||||||
|
|
@ -381,22 +567,85 @@ describe('OrderConfirmation.vue', () => {
|
||||||
const { wrapper } = getMountedComponent();
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentTimeFormatted;
|
const testValue = wrapper.vm.providerFullAddress;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('Drop off before 9:30 AM');
|
expect(testValue).toEqual('123 Safelite Street,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return In Shop time in expected format', () => {
|
});
|
||||||
|
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
|
// Arrange
|
||||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentTimeFormatted;
|
const testValue = wrapper.vm.appointmentDateFormatted;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('at 9:00 AM');
|
expect(testValue).toEqual('Friday, March 1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('appointmentWordingText should return Mobile text in expected format', () => {
|
test('appointmentWordingText should return Mobile text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testSessionStorage = {
|
const testSessionStorage = {
|
||||||
|
|
@ -517,85 +766,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('wording text 123 Safelite Street,<br/> Mesa, AZ 12345');
|
expect(testValue).toEqual('wording text 123 Safelite Street,<br/> 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,<br/> 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'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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,<br/> Mesa, AZ 12345');
|
|
||||||
});
|
|
||||||
test('appointmentWordingText2 should return Mobile text in expected format', () => {
|
test('appointmentWordingText2 should return Mobile text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testSessionStorage = {
|
const testSessionStorage = {
|
||||||
|
|
@ -720,3 +891,16 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
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) => {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="container-fluid fade-on-route-transition">
|
<div class="container-fluid fade-on-route-transition">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-6 px-0 px-md-2">
|
<div class="col-md-6 px-0 px-md-2">
|
||||||
<siteHeader cmsWidgetName="SiteHeaderWidget" />
|
<siteHeader :cmsWidgetName="widgets.siteHeader" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
<div class="appointment-details">
|
<div class="appointment-details">
|
||||||
<div>
|
<div>
|
||||||
<vehicleBanner
|
<vehicleBanner
|
||||||
cmsWidgetName="VehicleBannerWidget"
|
:cmsWidgetName="widgets.vehicleBanner"
|
||||||
:displayGenericVehicleImage="false">
|
:displayGenericVehicleImage="false">
|
||||||
</vehicleBanner>
|
</vehicleBanner>
|
||||||
</div>
|
</div>
|
||||||
<div class="appointment-date-time text-center mt-4">
|
<div class="appointment-date-time text-center mt-4">
|
||||||
<p>{{ formatDate(schedule.date) }}</p>
|
<p>{{ formatDate(schedule.date) }}</p>
|
||||||
<p class="mt-2">{{ appointmentTimeFormatted }}</p>
|
<p class="mt-2">{{ appointmentTimeText }}</p>
|
||||||
</div>
|
</div>
|
||||||
<addToCalendar
|
<addToCalendar
|
||||||
mobileWidgetName="AddToCalendar_Mobile"
|
mobileWidgetName="AddToCalendar_Mobile"
|
||||||
|
|
@ -36,9 +36,7 @@
|
||||||
overnightDropOffWidgetName="AddToCalendar_OvernightDropOff"
|
overnightDropOffWidgetName="AddToCalendar_OvernightDropOff"
|
||||||
allDayDropOffWidgetName="AddToCalendar_AllDayDropOff"
|
allDayDropOffWidgetName="AddToCalendar_AllDayDropOff"
|
||||||
sameDayDropOffWidgetName="AddToCalendar_SameDayDropOff"
|
sameDayDropOffWidgetName="AddToCalendar_SameDayDropOff"
|
||||||
:serviceLocationFullAddress="
|
:serviceLocationFullAddress="serviceLocationFullAddress"
|
||||||
serviceLocationFullAddress
|
|
||||||
"
|
|
||||||
:providerFullAddress="providerFullAddress"
|
:providerFullAddress="providerFullAddress"
|
||||||
:appointmentType="appointmentType"
|
:appointmentType="appointmentType"
|
||||||
:scheduleDate="schedule.date"
|
:scheduleDate="schedule.date"
|
||||||
|
|
@ -69,7 +67,7 @@
|
||||||
<siteFooter
|
<siteFooter
|
||||||
v-if="carrierUrl"
|
v-if="carrierUrl"
|
||||||
ref="siteFooter"
|
ref="siteFooter"
|
||||||
cmsWidgetName="SiteFooterWidget"
|
:cmsWidgetName="widgets.siteFooter"
|
||||||
:isStackedVertically="true"
|
:isStackedVertically="true"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
@ForwardClicked="forwardButtonAction"
|
@ForwardClicked="forwardButtonAction"
|
||||||
|
|
@ -154,7 +152,7 @@ export default {
|
||||||
var { issConfig } = this.mainStore;
|
var { issConfig } = this.mainStore;
|
||||||
return {
|
return {
|
||||||
vehicle,
|
vehicle,
|
||||||
customerEmail: customer.emailAddress,
|
customerEmail: customer?.emailAddress,
|
||||||
payment,
|
payment,
|
||||||
schedule,
|
schedule,
|
||||||
serviceLocation,
|
serviceLocation,
|
||||||
|
|
@ -164,10 +162,13 @@ export default {
|
||||||
carrierName: issConfig.clientName,
|
carrierName: issConfig.clientName,
|
||||||
carrierUrl: issConfig.successReturnURL,
|
carrierUrl: issConfig.successReturnURL,
|
||||||
widgets: {
|
widgets: {
|
||||||
|
siteHeader: 'SiteHeaderWidget',
|
||||||
|
vehicleBanner: 'VehicleBannerWidget',
|
||||||
emailConfirmation: 'EmailConfirmationWordingWidget',
|
emailConfirmation: 'EmailConfirmationWordingWidget',
|
||||||
orderConfirmation: 'OrderConfirmationContent',
|
orderConfirmation: 'OrderConfirmationContent',
|
||||||
mobile: 'MobileWordingWidget',
|
mobile: 'MobileWordingWidget',
|
||||||
dropOffAndInShop: 'DropOffAndInShopWordingWidget'
|
dropOffAndInShop: 'DropOffAndInShopWordingWidget',
|
||||||
|
siteFooter: 'SiteFooterWidget'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -176,10 +177,10 @@ export default {
|
||||||
return {
|
return {
|
||||||
inShopAppointment: this.isInShopAppointment,
|
inShopAppointment: this.isInShopAppointment,
|
||||||
dropOffAppointment: this.isDropOffAppointment,
|
dropOffAppointment: this.isDropOffAppointment,
|
||||||
vehicleYear: this.vehicle.year,
|
vehicleYear: this.vehicle?.year,
|
||||||
vehicleMake: this.vehicle.make,
|
vehicleMake: this.vehicle?.make,
|
||||||
vehicleModel: this.vehicle.model,
|
vehicleModel: this.vehicle?.model,
|
||||||
address: this.appointmentAddress,
|
address: this.appointmentLocation,
|
||||||
inShopDuration: this.inShopAppointmentDuration,
|
inShopDuration: this.inShopAppointmentDuration,
|
||||||
email: this.customerEmail,
|
email: this.customerEmail,
|
||||||
CUSTOMER_PORTAL_URL: applicationConfig.CUSTOMER_PORTAL_URL,
|
CUSTOMER_PORTAL_URL: applicationConfig.CUSTOMER_PORTAL_URL,
|
||||||
|
|
@ -204,23 +205,6 @@ export default {
|
||||||
this.widgets.orderConfirmation,
|
this.widgets.orderConfirmation,
|
||||||
widgetFields.CONTENT_GROUP_WIDGET.IMAGE);
|
widgetFields.CONTENT_GROUP_WIDGET.IMAGE);
|
||||||
},
|
},
|
||||||
appointmentTimeFormatted() {
|
|
||||||
const { startTime, endTime } = this.schedule;
|
|
||||||
var appointmentTime = null;
|
|
||||||
if (this.isDropOffAppointment){
|
|
||||||
appointmentTime = 'Drop off before 9:30 AM';
|
|
||||||
}
|
|
||||||
if (this.isInShopAppointment){
|
|
||||||
const formattedStartTime = get12HourTimeFormat(startTime);
|
|
||||||
appointmentTime = `at ${formattedStartTime}`
|
|
||||||
}
|
|
||||||
if (this.isMobileAppointment) {
|
|
||||||
const mobileStartTime = get12HourTimeMobileFormat(startTime);
|
|
||||||
const mobileEndTime = get12HourTimeMobileFormat(endTime);
|
|
||||||
appointmentTime = `Between ${mobileStartTime} - ${mobileEndTime}`;
|
|
||||||
}
|
|
||||||
return appointmentTime;
|
|
||||||
},
|
|
||||||
mobileWordingText() {
|
mobileWordingText() {
|
||||||
return this.getCmsContentWithCustomValues(
|
return this.getCmsContentWithCustomValues(
|
||||||
this.widgets.mobile,
|
this.widgets.mobile,
|
||||||
|
|
@ -231,36 +215,33 @@ export default {
|
||||||
this.widgets.mobile,
|
this.widgets.mobile,
|
||||||
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
||||||
},
|
},
|
||||||
dropOffAndInShopWordingText() {
|
nonMobileWordingText() {
|
||||||
return this.getCmsContentWithCustomValues(
|
return this.getCmsContentWithCustomValues(
|
||||||
this.widgets.dropOffAndInShop,
|
this.widgets.dropOffAndInShop,
|
||||||
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT);
|
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT);
|
||||||
},
|
},
|
||||||
dropOffAndInShopWordingText2() {
|
nonMobileWordingText2() {
|
||||||
return this.getCmsContentWithCustomValues(
|
return this.getCmsContentWithCustomValues(
|
||||||
this.widgets.dropOffAndInShop,
|
this.widgets.dropOffAndInShop,
|
||||||
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
||||||
},
|
},
|
||||||
serviceLocationFullAddress() {
|
appointmentTimeText() {
|
||||||
// var { address, address2, city, state, zipCode } = this.serviceLocation;
|
const { startTime, endTime } = this.schedule;
|
||||||
// console.log(JSON.stringify(this.serviceLocation));
|
if (this.isDropOffAppointment){
|
||||||
// return `${address}, ${address2 ? `${address2},` : ''}<br/> ${city}, ${state} ${zipCode}`;
|
return 'Drop off before 9:30 AM';
|
||||||
|
}
|
||||||
return `${this.serviceLocation.address}, ${
|
if (this.isInShopAppointment){
|
||||||
this.serviceLocation.address2
|
const formattedStartTime = get12HourTimeFormat(startTime);
|
||||||
? `${this.serviceLocation.address2},`
|
return `at ${formattedStartTime}`
|
||||||
: ''
|
}
|
||||||
}<br/> ${this.serviceLocation.city}, ${this.serviceLocation.state} ${
|
if (this.isMobileAppointment) {
|
||||||
this.serviceLocation.zipCode
|
const mobileStartTime = get12HourTimeMobileFormat(startTime);
|
||||||
}`;
|
const mobileEndTime = get12HourTimeMobileFormat(endTime);
|
||||||
|
return `Between ${mobileStartTime} - ${mobileEndTime}`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
titleCaseProviderAddress() {
|
appointmentLocation() {
|
||||||
return toTitleCase(this.providerAddress?.streetAddress);
|
|
||||||
},
|
|
||||||
titleCaseProviderCity() {
|
|
||||||
return toTitleCase(this.providerAddress?.city);
|
|
||||||
},
|
|
||||||
appointmentAddress() {
|
|
||||||
if (this.isMobileAppointment){
|
if (this.isMobileAppointment){
|
||||||
return this.serviceLocationFullAddress;
|
return this.serviceLocationFullAddress;
|
||||||
}
|
}
|
||||||
|
|
@ -269,31 +250,33 @@ export default {
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
serviceLocationFullAddress() {
|
||||||
|
var { address, address2, city, state, zipCode } = this.serviceLocation;
|
||||||
|
return `${address}, ${address2 ? `${address2},` : ''}<br/> ${city}, ${state} ${zipCode}`;
|
||||||
|
},
|
||||||
providerFullAddress() {
|
providerFullAddress() {
|
||||||
var { state, zipCode } = this.providerAddress;
|
var { streetAddress, city, state, zipCode } = this.providerAddress;
|
||||||
return this.titleCaseProviderAddress
|
return streetAddress
|
||||||
? `${this.titleCaseProviderAddress},<br/> ${this.titleCaseProviderCity}, ${state} ${zipCode}`
|
? `${toTitleCase(streetAddress)},<br/> ${toTitleCase(city)}, ${state} ${zipCode}`
|
||||||
: '';
|
: '';
|
||||||
},
|
},
|
||||||
appointmentWordingText() {
|
appointmentWordingText() {
|
||||||
var wording = null;
|
|
||||||
if (this.isMobileAppointment){
|
if (this.isMobileAppointment){
|
||||||
wording = this.mobileWordingText;
|
return this.mobileWordingText;
|
||||||
}
|
}
|
||||||
if (this.isInShopAppointment || this.isDropOffAppointment){
|
if (this.isInShopAppointment || this.isDropOffAppointment){
|
||||||
wording = this.dropOffAndInShopWordingText;
|
return this.nonMobileWordingText;
|
||||||
}
|
}
|
||||||
return wording;
|
return null;
|
||||||
},
|
},
|
||||||
appointmentWordingText2() {
|
appointmentWordingText2() {
|
||||||
var wording = null;
|
|
||||||
if (this.isMobileAppointment){
|
if (this.isMobileAppointment){
|
||||||
wording = this.mobileWordingText2;
|
return this.mobileWordingText2;
|
||||||
}
|
}
|
||||||
if (this.isInShopAppointment || this.isDropOffAppointment){
|
if (this.isInShopAppointment || this.isDropOffAppointment){
|
||||||
wording = this.dropOffAndInShopWordingText2;
|
return this.nonMobileWordingText2;
|
||||||
}
|
}
|
||||||
return wording;
|
return null;
|
||||||
},
|
},
|
||||||
isMobileAppointment() {
|
isMobileAppointment() {
|
||||||
const mobileAppointmentTypes = [
|
const mobileAppointmentTypes = [
|
||||||
|
|
@ -398,7 +381,9 @@ export default {
|
||||||
'custom',
|
'custom',
|
||||||
(v) => { return this.customValueMap[v] }
|
(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) {
|
formatDate(date) {
|
||||||
// This conversion ensures we don't get get GMT induced date changes
|
// This conversion ensures we don't get get GMT induced date changes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue