Fixing merge conflicts

This commit is contained in:
Michaela Brydon 2024-03-01 17:39:22 -05:00
commit da720e87c1
18 changed files with 1169 additions and 546 deletions

View file

@ -1,204 +1,204 @@
const baseContentUrl = '/content/api/v1/content';
const baseLocationUrl = '/location/api/v1/location';
const baseScheduleUrl = '/schedule/api/v1/schedule';
const basePartsUrl = '/parts/api/v1/parts';
const baseVehicleUrl = '/vehicle/api/v1/vehicle';
const basePriceUrl = '/price/api/v1/price';
const baseAnalyticsUrl = '/analytics/api/v1/analytics';
const baseExperimentsUrl = '/experiments/api/v1/experiments';
const baseClientAuthUrl = '/clientauth/api/v1/clientauth';
const baseOrderUrl = '/order/api/v1/order';
const baseCoverageUrl = '/coverage/api/v1/coverage';
const baseAccountUrl = '/account/api/v1/account/';
const CONTENT_BASE_URL = '/content/api/v1/content';
const LOCATION_BASE_URL = '/location/api/v1/location';
const SCHEDULE_BASE_URL = '/schedule/api/v1/schedule';
const PARTS_BASE_URL = '/parts/api/v1/parts';
const VEHICLE_BASE_URL = '/vehicle/api/v1/vehicle';
const PRICE_BASE_URL = '/price/api/v1/price';
const ACCOUNT_BASE_URL = '/account/api/v1/account';
const EXPERIMENTS_BASE_URL = '/experiments/api/v1/experiments';
const ANALYTICS_BASE_URL = '/analytics/api/v1/analytics';
const CLIENT_AUTH_BASE_URL = '/clientauth/api/v1/clientauth';
const COVERAGE_BASE_URL = '/coverage/api/v1/coverage';
const ORDER_BASE_URL = '/order/api/v1/order';
const endpoints = Object.freeze({
GetRouteInfo: {
url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/RouteInfo`,
url: (applicationAbbreviation) => `${CONTENT_BASE_URL}/${applicationAbbreviation}/RouteInfo`,
method: 'POST'
},
GetHomepageInfo: {
url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/HomepageInfo`,
url: (applicationAbbreviation) => `${CONTENT_BASE_URL}/${applicationAbbreviation}/HomepageInfo`,
method: 'GET'
},
GetPageData: {
url: (applicationAbbreviation, pageName) => `${baseContentUrl}/${applicationAbbreviation}/${pageName}`,
url: (applicationAbbreviation, pageName) => `${CONTENT_BASE_URL}/${applicationAbbreviation}/${pageName}`,
method: 'GET'
},
GetAlertReasons: {
url: `${baseLocationUrl}/alert-reasons`,
url: `${LOCATION_BASE_URL}/alert-reasons`,
method: 'GET'
},
GetShopTimeSlots: {
url: `${baseScheduleUrl}/shop-time-slots`,
url: `${SCHEDULE_BASE_URL}/shop-time-slots`,
method: 'POST'
},
GetMobileTimeSlots: {
url: `${baseScheduleUrl}/mobile-time-slots`,
url: `${SCHEDULE_BASE_URL}/mobile-time-slots`,
method: 'POST'
},
GetMobilePremiumFee: {
url: `${basePartsUrl}/mobile-premium-fee`,
url: `${PARTS_BASE_URL}/mobile-premium-fee`,
method: 'GET'
},
GetVehicleYears: {
url: `${baseVehicleUrl}/years`,
url: `${VEHICLE_BASE_URL}/years`,
method: 'GET'
},
GetVehicleMakes: {
url: `${baseVehicleUrl}/makes/`,
url: `${VEHICLE_BASE_URL}/makes/`,
method: 'GET'
},
GetVehicleModels: {
url: `${baseVehicleUrl}/models`,
url: `${VEHICLE_BASE_URL}/models`,
method: 'GET'
},
GetVehicleStyles: {
url: `${baseVehicleUrl}/styles`,
url: `${VEHICLE_BASE_URL}/styles`,
method: 'GET'
},
GetDamageOptions: {
url: `${basePartsUrl}/damage-options`,
url: `${PARTS_BASE_URL}/damage-options`,
method: 'GET'
},
GetPartsOrQuestions: {
url: `${basePartsUrl}/parts-or-questions`,
url: `${PARTS_BASE_URL}/parts-or-questions`,
method: 'POST'
},
GetParts: {
url: `${basePartsUrl}/parts`,
url: `${PARTS_BASE_URL}/parts`,
method: 'POST'
},
// TODO finish
GetInsurancePriceOrderItems: {
url: () => `${basePriceUrl}/order-items-with-insurance-pricing`,
url: `${PRICE_BASE_URL}/order-items-with-insurance-pricing`,
method: 'GET'
},
GetPriceOrderItems: {
url: `${basePriceUrl}/order-items`,
url: `${PRICE_BASE_URL}/order-items`,
method: 'GET'
},
GetProviders: {
url: `${baseLocationUrl}/providers`,
url: `${LOCATION_BASE_URL}/providers`,
method: 'GET'
},
GetCapabilityQuestions: {
url: `${basePartsUrl}/capability-questions`,
url: `${PARTS_BASE_URL}/capability-questions`,
method: 'GET'
},
GetPartFromCapabilityAnswer: {
url: `${basePartsUrl}/part-from-capability-answer`,
url: `${PARTS_BASE_URL}/part-from-capability-answer`,
method: 'POST'
},
GetWipers: {
url: `${basePartsUrl}/wipers`,
url: `${PARTS_BASE_URL}/wipers`,
method: 'GET'
},
GetRainDefense: {
url: `${basePartsUrl}/rain-defense`,
url: `${PARTS_BASE_URL}/rain-defense`,
method: 'GET'
},
GetSupportingItems: {
url: `${basePartsUrl}/supporting-items`,
url: `${PARTS_BASE_URL}/supporting-items`,
method: 'POST'
},
GetMobileFeePart: {
url: `${basePartsUrl}/mobile-fee`,
url: `${PARTS_BASE_URL}/mobile-fee`,
method: 'GET'
},
GetServiceabilityDetails: {
url: `${baseLocationUrl}/serviceability-details`,
url: `${LOCATION_BASE_URL}/serviceability-details`,
method: 'GET'
},
GetVehicle: {
url: `${baseVehicleUrl}/lookup`,
url: `${VEHICLE_BASE_URL}/lookup`,
method: 'GET'
},
GetAccountInfo: {
url: baseAccountUrl,
url: `${ACCOUNT_BASE_URL}/`,
method: 'GET'
},
LogExperimentExposureIfAssigned: {
url: `${baseExperimentsUrl}/log-exposure`,
url: `${EXPERIMENTS_BASE_URL}/log-exposure`,
method: 'POST'
},
LogPageView: {
url: `${baseAnalyticsUrl}/log-page-view`,
url: `${ANALYTICS_BASE_URL}/log-page-view`,
method: 'POST'
},
LogCustomEvent: {
url: `${baseAnalyticsUrl}/log-custom-event`,
url: `${ANALYTICS_BASE_URL}/log-custom-event`,
method: 'POST'
},
LookupVehicleByVin: {
url: `${baseVehicleUrl}/lookup`,
url: `${VEHICLE_BASE_URL}/lookup`,
method: 'POST'
},
LookupVinByAddress: {
url: `${baseVehicleUrl}/lookup-vin-by-address`,
url: `${VEHICLE_BASE_URL}/lookup-vin-by-address`,
method: 'POST'
},
LookupVinByPlate: {
url: `${baseVehicleUrl}/lookup-vin-by-plate`,
url: `${VEHICLE_BASE_URL}/lookup-vin-by-plate`,
method: 'POST'
},
InitializeSession: {
url: `${baseAnalyticsUrl}/initialize`,
url: `${ANALYTICS_BASE_URL}/initialize`,
method: 'POST'
},
GetExperimentsByUser: {
url: `${baseAnalyticsUrl}/get-experiments`,
url: `${ANALYTICS_BASE_URL}/get-experiments`,
method: 'GET'
},
RunExperimentsForTrigger: {
url: `${baseExperimentsUrl}/run`,
url: `${EXPERIMENTS_BASE_URL}/run`,
method: 'POST'
},
ValidateZip: {
url: `${baseLocationUrl}/zip`,
url: `${LOCATION_BASE_URL}/zip`,
method: 'GET'
},
GooglePlaces: {
url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`
},
ValidateClientTag: {
url: `${baseClientAuthUrl}/validate-client-tag`,
url: `${CLIENT_AUTH_BASE_URL}/validate-client-tag`,
method: 'GET'
},
ValidateClientSignature: {
url: `${baseClientAuthUrl}/validate-client-signature`,
url: `${CLIENT_AUTH_BASE_URL}/validate-client-signature`,
method: 'POST'
},
IsVinbyAddressPermissible: {
url: `${baseVehicleUrl}/is-vin-by-address-permissible`,
url: `${VEHICLE_BASE_URL}/is-vin-by-address-permissible`,
method: 'Get'
},
CoveragePolicyInfo: {
url: `${baseCoverageUrl}/policy-information`,
url: `${COVERAGE_BASE_URL}/policy-information`,
method: 'POST'
},
RegisterClaim: {
url: `${baseCoverageUrl}/register-claim`,
url: `${COVERAGE_BASE_URL}/register-claim`,
method: 'POST'
},
SaveSession: {
url: `${baseOrderUrl}/save-session/iss`,
url: `${ORDER_BASE_URL}/save-session/iss`,
method: 'POST'
},
LoadSession: {
url: `${baseOrderUrl}/load-session`,
url: `${ORDER_BASE_URL}/load-session/iss`,
method: 'POST'
},
DuplicateSearch: {
// eslint-disable-next-line max-len
url: (accountNumber, policyNumber, dateOfLoss) => `${baseOrderUrl}/duplicate-check/${accountNumber}/${policyNumber}/${dateOfLoss}`,
url: (accountNumber, policyNumber, dateOfLoss) => `${ORDER_BASE_URL}/duplicate-check/${accountNumber}/${policyNumber}/${dateOfLoss}`,
method: 'GET'
},
FinalDeductible: {
url: `${baseCoverageUrl}/final-deductible`,
url: `${COVERAGE_BASE_URL}/final-deductible`,
method: 'POST'
},
GetPaymentSignature: {
url: `${baseOrderUrl}/sign`,
url: `${ORDER_BASE_URL}/sign`,
method: 'POST'
}
});

View file

@ -72,3 +72,35 @@ export function sumDateString(dateString, daysToAdd) {
date.setDate(date.getDate() + daysToAdd);
return convertDateToDateString(date);
}
export function get12HourTimeMobileFormat(time) {
// Check correct time format and split into components
let timeString = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)?$/) || [time];
if (timeString.length > 1) {
// If time format correct
const min = timeString[3];
timeString = timeString.slice(1); // Remove full string match value
if (Number(min) === 0) {
timeString = timeString.slice(0, 1); // Remove minute value
timeString[1] = +timeString[0] < 12 ? ' AM' : ' PM'; // Set AM/PM
} else {
timeString[5] = +timeString[0] < 12 ? ' AM' : ' PM'; // Set AM/PM
}
timeString[0] = +timeString[0] % 12 || 12; // Adjust hours
}
return timeString.join(''); // return adjusted time or original string
}
export function get12HourTimeFormat(time) {
// Check correct time format and split into components
let timeString = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)?$/) || [time];
if (timeString.length > 1) {
// If time format correct
timeString = timeString.slice(1); // Remove full string match value
timeString[5] = +timeString[0] < 12 ? ' AM' : ' PM'; // Set AM/PM
timeString[0] = +timeString[0] % 12 || 12; // Adjust hours
}
return timeString.join(''); // return adjusted time or original string
}

View file

@ -24,6 +24,8 @@ export async function saveSession({ shouldAwaitSaveSessionQueue = false }) {
*/
async function saveSessionHelper(store) {
const savedSessionInfo = await store.saveSession();
store.setSaveSessionInfo(savedSessionInfo.data);
if (savedSessionInfo) {
store.setSaveSessionInfo(savedSessionInfo.data);
}
updateOrCreateISSCookie();
}

View file

@ -0,0 +1,23 @@
import endorsementOptions from '@/constants/endorsement-options';
export function noCoverageForSelectedVehicle(vehicle) {
return (vehicle?.coverages?.length ?? 0) === 0;
}
export function deductibleForSelectedVehicle(vehicle) {
if (!vehicle) {
return undefined;
}
return vehicle.coverages?.length ?? false
? vehicle?.coverages[0].deductible
: 0;
}
export function endorsementsForSelectedVehicle(vehicle) {
if (vehicle?.endorsements?.length > 0) {
return vehicle.endorsements;
}
return [];
}
export function repairWaivedForSelectedVehicle(vehicle) {
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
}

View file

@ -0,0 +1,205 @@
import {
deductibleForSelectedVehicle,
endorsementsForSelectedVehicle,
noCoverageForSelectedVehicle,
repairWaivedForSelectedVehicle
} from '@/helpers/policy-vehicle-helper';
import { getRandomInt, getRandomString } from '@/helpers/data-generation';
import endorsementOptions from '@/constants/endorsement-options';
describe('policy vehicle helper', () => {
describe('noCoverageForSelectedVehicle function', () => {
it('Null vehicle => returns true', async () => {
// Arrange
const vehicle = null;
// Act
const result = noCoverageForSelectedVehicle(vehicle);
// Assert
expect(result).toBeTruthy();
});
it('Empty vehicle coverages list => returns true', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
coverages: []
};
// Act
const result = noCoverageForSelectedVehicle(vehicle);
// Assert
expect(result).toBeTruthy();
});
it('Non-empty vehicle coverages list => returns false', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
coverages: [
{
deductible: 0
}
]
};
// Act
const result = deductibleForSelectedVehicle(vehicle);
// Assert
expect(result).toBeFalsy();
});
});
describe('deductibleForSelectedVehicle function', () => {
it('Null vehicle => returns undefined', async () => {
// Arrange
const vehicle = null;
// Act
const result = deductibleForSelectedVehicle(vehicle);
// Assert
expect(result).toBe(undefined);
});
it('Vehicle match with empty coverages list => 0 returned', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
coverages: []
};
// Act
const result = deductibleForSelectedVehicle(vehicle);
// Assert
expect(result).toBe(0);
});
it('Coverages list non empty => deductible from first coverage returned', async () => {
// Arrange
const firstDeductible = getRandomInt(1, 1000);
const vehicle = {
vin: getRandomString(17, 17),
coverages: [
{
deductible: firstDeductible
},
{
deductible: getRandomInt(1, 1000)
}
]
};
// Act
const result = deductibleForSelectedVehicle(vehicle);
// Assert
expect(result).toBe(firstDeductible);
});
});
describe('repairWaivedForSelectedVehicle function', () => {
it('Null vehicle => returns false', async () => {
// Arrange
const vehicle = null;
// Act
const result = repairWaivedForSelectedVehicle(vehicle);
// Assert
expect(result).toBeFalsy();
});
it('Endorsements list empty => false returned', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
endorsements: []
};
// Act
const result = repairWaivedForSelectedVehicle(vehicle);
// Assert
expect(result).toBeFalsy();
});
it('Endorsements list non-empty, not containing repair waived => false returned', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]
};
// Act
const result = repairWaivedForSelectedVehicle(vehicle);
// Assert
expect(result).toBeFalsy();
});
it('Endorsements list contains repair waived => true returned', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
endorsements: [
endorsementOptions.EDUCATOR,
endorsementOptions.REPAIR_WAIVED,
endorsementOptions.PARKING_GUARD
]
};
// Act
const result = repairWaivedForSelectedVehicle(vehicle);
// Assert
expect(result).toBeTruthy();
});
});
describe('endorsementsForSelectedVehicle function', () => {
it('Null vehicle => returns empty array', async () => {
// Arrange
const vehicle = null;
// Act
const result = endorsementsForSelectedVehicle(vehicle);
// Assert
expect(result).toStrictEqual([]);
});
it('Null endorsements => returns empty array', async () => {
// Arrange
const vehicle = {
vin: getRandomString(17, 17),
endorsements: null
};
// Act
const result = endorsementsForSelectedVehicle(vehicle);
// Assert
expect(result).toStrictEqual([]);
});
it('Endorsements list non-empty, not containing repair waived => false returned', async () => {
// Arrange
const endorsements = [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD];
const vehicle = {
vin: getRandomString(17, 17),
endorsements
};
// Act
const result = endorsementsForSelectedVehicle(vehicle);
// Assert
expect(result).toStrictEqual(endorsements);
});
});
});

View file

@ -829,7 +829,7 @@ describe.skip('coverageStatement.vue', () => {
describe('coverageStatement.vue-working', () => {
describe('ITAC flag', () => {
test('ITAC flag updated once component is initialized', () => {
test('ITAC flag updated once component is initialized', async () => {
// Arrange
const mainInitialState = {
order: {
@ -838,7 +838,10 @@ describe('coverageStatement.vue-working', () => {
}
}
};
const { wrapper } = getMountedComponent(mainInitialState);
const mockStoreActions = () => {
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([]));
};
const { wrapper } = getMountedComponent(mainInitialState, {}, mockStoreActions);
// Act
wrapper.vm.initializeComponent();
@ -847,5 +850,57 @@ describe('coverageStatement.vue-working', () => {
expect(wrapper.vm.mainStore.updatePolicyITACFlag)
.toHaveBeenCalledTimes(1);
});
it('Loaded duplicate with previously registered claim => claim registration is not called', async () => {
// Arrange
const sellingPrice = getRandomInt(50, 100);
const deductible = sellingPrice - 1;
const initialStore = {
order: {
policy: {
policyLookupSuccessful: true,
noCoverage: false,
deductible: {
repair: deductible
}
},
damage: {
isRepair: false
},
payment: {
insuranceCoverage: {
claimNumber: getRandomString(10, 10)
}
}
},
issConfig: {
isClaimRegistrationRequired: true
}
};
const mockStoreActions = () => {
useMainStore().getWipers = jest.fn().mockImplementation(() => Promise.resolve());
useMainStore().getRainDefense = jest.fn().mockImplementation(() => Promise.resolve());
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve());
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([
{
sellingPrice,
kitPrice: 0,
laborAmount: 0
}
]));
};
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
const next = (method) => { method(wrapper.vm); };
// Act
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
for (let i = 0; i < 7; i++) {
// eslint-disable-next-line no-await-in-loop
await nextTick();
}
// Assert
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalledTimes(0);
});
});
});

View file

@ -367,9 +367,10 @@ export default {
: coverageStatuses.PENDING;
useMainStore().updateCoverageStatus(coverageStatus);
if (this.policyLookupSuccessful
&& useMainStore().order.vehicle.policyVehicleId >= 0
&& useMainStore().isClaimRegistrationRequired
&& (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC)) {
&& useMainStore().order.vehicle.policyVehicleId >= 0
&& useMainStore().isClaimRegistrationRequired
&& !useMainStore().isClaimAlreadyRegistered
&& (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC)) {
await useMainStore().registerClaim()?.catch(() => {});
}
this.$refs.loadingModal.hideModal();

View file

@ -519,6 +519,110 @@ describe('duplicateCheck.vue', () => {
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
});
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
// Arrange
const mountOptions = getMountOptions({
router: { navigate: jest.fn() }
});
const vin = getRandomString(17, 17);
const mainInitialState = {
order: {
policy: {
policyLookupSuccessful: true,
vehicles: [{ vin }]
},
vehicle: {
vin
},
loadedFromDupeCheck: true
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
});
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
// Arrange
const mountOptions = getMountOptions({
router: { navigate: jest.fn() }
});
const vin = getRandomString(17, 17);
const mainInitialState = {
order: {
policy: {
policyLookupSuccessful: true,
vehicles: [{ vin }]
},
vehicle: {
vin: null
},
loadedFromDupeCheck: true
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
});
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
// Arrange
const mountOptions = getMountOptions({
router: { navigate: jest.fn() }
});
const mainInitialState = {
order: {
policy: {
policyLookupSuccessful: true,
vehicles: []
},
vehicle: {
vin: null
},
loadedFromDupeCheck: true
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES, undefined);
});
});
});
});

View file

@ -135,9 +135,17 @@ export default {
}
},
navigateForward() {
if (useMainStore().order.policy.policyLookupSuccessful) {
const policyVehicles = useMainStore().order.policy.vehicles ?? [];
if (policyVehicles.length > 0) {
if (!this.mainStore.order.policy.policyLookupSuccessful) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.$route
);
return;
}
const policyVehicles = useMainStore().order.policy.vehicles ?? [];
if (!this.mainStore.order.loadedFromDupeCheck) {
if (policyVehicles.length !== 0) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
this.$route
@ -148,9 +156,22 @@ export default {
this.$route
);
}
return;
}
if (this.mainStore.order.vehicle.vin) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE,
this.$route
);
} else if (policyVehicles.length !== 0) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE,
this.$route
);
} else {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES,
this.$route
);
}

View file

@ -14,10 +14,11 @@ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
jest.mock('@/helpers/cms-content-helper', () => ({
fetchCmsContentForPage: jest.fn()
}));
const wordingText = 'wording Text {custom:address}';
const mockMixin = {
methods: {
getCmsContent: jest.fn().mockImplementation(() => ''),
getCmsContent: jest.fn().mockImplementation(() => wordingText),
setCmsContent: jest.fn()
}
};
@ -33,6 +34,32 @@ const headerStub = {
render: () => {}
};
const initialStore = {
order: {
schedule: {
date: '2024-03-01',
startTime: '09:00',
endTime: '10:00'
},
serviceLocation: {
address: '123 Test Way',
address2: '#1',
city: 'Mesa',
state: 'AZ',
zipCode: '12345',
appointmentType: 'Inshop',
provider: {
address: {
streetAddress: '123 Safelite Street',
city: 'Mesa',
state: 'AZ',
zipCode: '12345'
}
}
}
}
};
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
const mountOptions = getMountOptions({
router: {
@ -75,7 +102,7 @@ describe('OrderConfirmation.vue', () => {
describe('Rendering', () => {
test('Should render Site Header', () => {
// Arrange
const { wrapper } = getMountedComponent({});
const { wrapper } = getMountedComponent(initialStore);
// Act
const siteHeader = wrapper.findComponent(headerStub);
@ -85,13 +112,21 @@ describe('OrderConfirmation.vue', () => {
});
test('If Advanced flow, should display Site Footer', () => {
// Arrange
const carrierReturnUrl = 'testURL';
const initialStore = {
const testStore = {
order: {
schedule: {
date: '2019-01-01',
startTime: '09:00'
},
serviceLocation: {
appointmentType: 'Inshop'
}
},
issConfig: {
successReturnURL: carrierReturnUrl
successReturnURL: 'testURL'
}
};
const { wrapper } = getMountedComponent(initialStore);
const { wrapper } = getMountedComponent(testStore);
// Act
const siteFooter = wrapper.findComponent({ ref: 'siteFooter' });
@ -101,7 +136,7 @@ describe('OrderConfirmation.vue', () => {
});
test('If Essential flow, should not display Site Footer', () => {
// Arrange
const { wrapper } = getMountedComponent();
const { wrapper } = getMountedComponent(initialStore);
// Act
const siteFooter = wrapper.findComponent({ ref: 'siteFooter' });
@ -114,12 +149,21 @@ describe('OrderConfirmation.vue', () => {
test('If Advanced flow, forward button action navigates to carrier URL', () => {
// Arrange
const carrierReturnUrl = 'testURL';
const initialStore = {
const testStore = {
order: {
schedule: {
date: '2019-01-01',
startTime: '09:00'
},
serviceLocation: {
appointmentType: 'Inshop'
}
},
issConfig: {
successReturnURL: carrierReturnUrl
}
};
const { wrapper } = getMountedComponent(initialStore);
const { wrapper } = getMountedComponent(testStore);
// Act
wrapper.vm.forwardButtonAction();
@ -128,4 +172,157 @@ describe('OrderConfirmation.vue', () => {
expect(wrapper.vm.$router.navigateToExternalUrl).toHaveBeenCalledWith(carrierReturnUrl);
});
});
describe('Computed properties', () => {
test('appointmentDateFormatted should return date in expected format', () => {
// Arrange
const { wrapper } = getMountedComponent(initialStore);
// Act
const testValue = wrapper.vm.appointmentDateFormatted;
// Assert
expect(testValue).toEqual('Friday, March 1');
});
test('appointmentTimeFormatted should return Mobile time in expected format', () => {
// Arrange
const testStore = {
order: {
schedule: {
date: '2019-01-01',
startTime: '09:00',
endTime: '10:00'
},
serviceLocation: {
appointmentType: 'Mobile'
}
}
};
const { wrapper } = getMountedComponent(testStore);
// Act
const testValue = wrapper.vm.appointmentTimeFormatted;
// Assert
expect(testValue).toEqual('Between 9 AM - 10 AM');
});
test('appointmentTimeFormatted should return Drop Off time in expected format', () => {
// Arrange
const testStore = {
order: {
schedule: {
date: '2019-01-01',
startTime: '09:00',
endTime: '10:00'
},
serviceLocation: {
appointmentType: 'Drop Off'
}
}
};
const { wrapper } = getMountedComponent(testStore);
// Act
const testValue = wrapper.vm.appointmentTimeFormatted;
// Assert
expect(testValue).toEqual('Drop off before 9:30 AM');
});
test('appointmentTimeFormatted should return In Shop time in expected format', () => {
// Arrange
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 testStore = {
order: {
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'
}
}
};
const { wrapper } = getMountedComponent(testStore);
// Act
const testValue = wrapper.vm.appointmentWordingText;
// Assert
expect(testValue).toEqual('wording Text <br/>123 Test Way, #1,<br/> Mesa, AZ 12345<br/>');
});
test('appointmentWordingText should return Drop Off text in expected format', () => {
// Arrange
const testStore = {
order: {
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: 'Drop Off'
}
}
};
const { wrapper } = getMountedComponent(testStore);
// Act
const testValue = wrapper.vm.appointmentWordingText;
// Assert
expect(testValue).toEqual('wording Text <br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
});
test('appointmentWordingText should return In Shop text in expected format', () => {
// Arrange
const { wrapper } = getMountedComponent(initialStore);
// Act
const testValue = wrapper.vm.appointmentWordingText;
// Assert
expect(testValue).toEqual('wording Text <br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
});
test('serviceLocationFullAddress should return text in expected format', () => {
// Arrange
const { wrapper } = getMountedComponent(initialStore);
// Act
const testValue = wrapper.vm.serviceLocationFullAddress;
// Assert
expect(testValue).toEqual('<br/>123 Test Way, #1,<br/> Mesa, AZ 12345<br/>');
});
test('providerFullAddress should return text in expected format', () => {
// Arrange
const { wrapper } = getMountedComponent(initialStore);
// Act
const testValue = wrapper.vm.providerFullAddress;
// Assert
expect(testValue).toEqual('<br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
});
});
});

View file

@ -7,12 +7,34 @@
<div class="page-container-grouped-styles">
<div class="fade-on-route-transition position-relative">
<siteHeader cmsWidgetName="SiteHeaderWidget" />
<div class="container-fluid pb-2">
<p>Placeholder for order confirmation page</p>
<div class="main-content-container">
<div class="text-center text-color--black pt-5 pb-5 fs-5">
<img :src="orderConfirmationImage" />
<span
class="ms-2"
v-html="orderConfirmationHeaderText"></span>
</div>
<div class="appointment-details">
<div>
<vehicleBanner
cmsWidgetName="VehicleBannerWidget"
:displayGenericVehicleImage="false">
</vehicleBanner>
</div>
<div class="appointment-date-time text-center">
<p>{{ appointmentDateFormatted }}</p>
<p>{{ appointmentTimeFormatted }}</p>
</div>
<div
class="appointment-text text-center text-color--black lh-base"
v-html="appointmentWordingText">
</div>
</div>
<siteFooter
v-if="carrierUrl"
ref="siteFooter"
cmsWidgetName="SiteFooterWidget"
:isStackedVertically="true"
:isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction"
@backClicked="navigateBack" />
@ -24,6 +46,7 @@
<script>
// Components
import siteHeader from '@/iss-components/site-header/site-header.vue';
import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
@ -31,11 +54,14 @@ import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
import { get12HourTimeFormat, get12HourTimeMobileFormat, convertDateStringToDate } from '@/helpers/date-helper.js';
import { toTitleCase } from '@/helpers/text-helper.js';
export default {
name: 'order-confirmation',
components: {
siteHeader,
vehicleBanner,
siteFooter,
// eslint-disable-next-line vue/no-reserved-component-names
Form
@ -66,6 +92,82 @@ export default {
},
carrierUrl() {
return this.mainStore.issConfig.successReturnURL;
},
orderConfirmationHeaderText() {
return this.getCmsContent('OrderConfirmationContent', 'HeaderText');
},
orderConfirmationImage() {
return this.getCmsContent('OrderConfirmationContent', 'Image');
},
appointmentType() {
return this.mainStore.order.serviceLocation.appointmentType.toUpperCase();
},
appointmentDate() {
return this.mainStore.order.schedule.date;
},
appointmentStartTime() {
return this.mainStore.order.schedule.startTime;
},
appointmentEndTime() {
return this.mainStore.order.schedule.endTime;
},
appointmentDateFormatted() {
// This conversion ensures we don't get get GMT induced date changes
const dateObject = convertDateStringToDate(this.appointmentDate);
// Ex: Tuesday, April 22
return dateObject.toLocaleDateString('en-us', {
weekday: 'long',
month: 'long',
day: 'numeric'
});
},
appointmentTimeFormatted() {
const formattedTime = this.formatAppointmentTime(this.appointmentType);
return formattedTime;
},
mobileWordingText() {
return this.getCmsContent('MobileWordingWidget', 'BodyText');
},
dropOffAndInShopWordingText() {
return this.getCmsContent('DropOffAndInShopWordingWidget', 'BodyText');
},
serviceLocationAddress() {
return this.mainStore.order.serviceLocation.address;
},
serviceLocationAddress2() {
return this.mainStore.order.serviceLocation.address2;
},
serviceLocationCity() {
return this.mainStore.order.serviceLocation.city;
},
serviceLocationState() {
return this.mainStore.order.serviceLocation.state;
},
serviceLocationZipCode() {
return this.mainStore.order.serviceLocation.zipCode;
},
serviceLocationFullAddress() {
// eslint-disable-next-line max-len
return `<br/>${this.serviceLocationAddress}, ${this.serviceLocationAddress2 ? `${this.serviceLocationAddress2},` : ''}<br/> ${this.serviceLocationCity}, ${this.serviceLocationState} ${this.serviceLocationZipCode}<br/>`;
},
providerAddress() {
return toTitleCase(this.mainStore.order.serviceLocation.provider.address.streetAddress);
},
providerCity() {
return toTitleCase(this.mainStore.order.serviceLocation.provider.address.city);
},
providerState() {
return this.mainStore.order.serviceLocation.provider.address.state;
},
providerZipCode() {
return this.mainStore.order.serviceLocation.provider.address.zipCode;
},
providerFullAddress() {
// eslint-disable-next-line max-len
return `<br/>${this.providerAddress},<br/> ${this.providerCity}, ${this.providerState} ${this.providerZipCode}<br/>`;
},
appointmentWordingText() {
return this.formatWordingText(this.appointmentType);
}
},
mounted() {
@ -76,7 +178,82 @@ export default {
methods: {
forwardButtonAction() {
this.$router.navigateToExternalUrl(this.carrierUrl);
},
formatAppointmentTime(appointmentType) {
switch (appointmentType) {
case 'MOBILE':
// eslint-disable-next-line max-len
return `Between ${get12HourTimeMobileFormat(this.appointmentStartTime)} - ${get12HourTimeMobileFormat(this.appointmentEndTime)}`;
case 'DROP OFF':
return 'Drop off before 9:30 AM';
case 'INSHOP':
return `at ${get12HourTimeFormat(this.appointmentStartTime)}`;
default:
return null;
}
},
formatWordingText(appointmentType) {
switch (appointmentType) {
case 'MOBILE':
return this.mobileWordingText?.replaceAll(
'{custom:address}',
this.serviceLocationFullAddress
);
case 'DROP OFF':
return this.dropOffAndInShopWordingText?.replaceAll(
'{custom:address}',
this.providerFullAddress
);
case 'INSHOP':
return this.dropOffAndInShopWordingText?.replaceAll(
'{custom:address}',
this.providerFullAddress
);
default:
return null;
}
}
}
};
</script>
<style lang="scss" scoped>
$page-side-padding: 1.5rem;
.page-container-grouped-styles {
overflow: auto;
.main-content-container {
padding: 0 1.5rem !important;
}
}
.text-color--black {
color: $black;
}
.appointment-details {
margin-bottom: 1.5rem;
padding: 1rem 1.5rem 1.5rem;
box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
border-radius: 5px;
}
.appointment-date-time P {
color: $black;
font-size: $h5-font-size;
line-height: map-get($spacers, 6);
margin-bottom: 0.5rem;
+ p {
font-size: map-get($spacers, 4);
line-height: 1.625rem;
font-weight: $font-weight-bold;
}
}
.appointment-text {
:deep(strong) {
font-weight: $font-weight-bold;
}
}
</style>

View file

@ -102,10 +102,12 @@ describe('policy-vehicles.vue', () => {
const { wrapper } = setupMocks({});
const vin = getRandomString(17, 17);
const policyVehicle = { vin };
await wrapper.setData({
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{ vin }
policyVehicle
],
policyVinFound: true
});
@ -202,13 +204,15 @@ describe('policy-vehicles.vue', () => {
const vin = getRandomString(17, 17);
const endorsements = ['Parking Guard'];
const policyVehicle = {
vin,
endorsements
};
await wrapper.setData({
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements
}
policyVehicle
]
});
@ -342,12 +346,14 @@ describe('policy-vehicles.vue', () => {
// Arrange
const selectedVin = getRandomString(17, 17);
const otherVin = getRandomString(17, 17);
const policyVehicle = {
vin: otherVin
};
const testValues = {
selectedVehicleVin: selectedVin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin: otherVin
}
policyVehicle
]
};
@ -361,13 +367,15 @@ describe('policy-vehicles.vue', () => {
it('Coverages list empty => true', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: []
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
coverages: []
}
policyVehicle
]
};
@ -381,17 +389,19 @@ describe('policy-vehicles.vue', () => {
it('Coverages list non-empty => false', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: [
{
deductible: 0
}
]
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
coverages: [
{
deductible: 0
}
]
}
policyVehicle
]
};
@ -410,6 +420,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17);
const testValues = {
selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [
{
vin: otherVin
@ -427,13 +438,15 @@ describe('policy-vehicles.vue', () => {
it('Vehicle match with empty coverages list => 0 returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: []
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
coverages: []
}
policyVehicle
]
};
@ -449,20 +462,22 @@ describe('policy-vehicles.vue', () => {
const vin = getRandomString(17, 17);
const firstDeductible = getRandomInt(1, 1000);
const secondDeductible = getRandomInt(1, 1000);
const policyVehicle = {
vin,
coverages: [
{
deductible: firstDeductible
},
{
deductible: secondDeductible
}
]
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
coverages: [
{
deductible: firstDeductible
},
{
deductible: secondDeductible
}
]
}
policyVehicle
]
};
@ -481,6 +496,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17);
const testValues = {
selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [
{
vin: otherVin
@ -498,13 +514,15 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list empty => false returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: []
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements: []
}
policyVehicle
]
};
@ -518,13 +536,15 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list non-empty, not containing repair waived => false returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]
}
policyVehicle
]
};
@ -538,17 +558,19 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list contains repair waived => true returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: [
endorsementOptions.EDUCATOR,
endorsementOptions.REPAIR_WAIVED,
endorsementOptions.PARKING_GUARD
]
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements: [
endorsementOptions.EDUCATOR,
endorsementOptions.REPAIR_WAIVED,
endorsementOptions.PARKING_GUARD
]
}
policyVehicle
]
};
@ -564,6 +586,7 @@ describe('policy-vehicles.vue', () => {
it('policyVehicles is null => empty endorsements array returned', () => {
// Arrange
const testValues = {
selectedPolicyVehicle: null,
policyVehicles: null
};
@ -578,6 +601,7 @@ describe('policy-vehicles.vue', () => {
it('policyVehicles is empty => empty endorsements array returned', () => {
// Arrange
const testValues = {
selectedPolicyVehicle: null,
policyVehicles: []
};
@ -595,6 +619,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17);
const testValues = {
selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [
{
vin: otherVin
@ -613,13 +638,15 @@ describe('policy-vehicles.vue', () => {
it('vehicle VIN match with endorsements null => empty endorsements array returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: null
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements: null
}
policyVehicle
]
};
@ -634,13 +661,15 @@ describe('policy-vehicles.vue', () => {
it('vehicle VIN match with empty endorsements => empty endorsements array returned', () => {
// Arrange
const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: []
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements: []
}
policyVehicle
]
};
@ -656,13 +685,15 @@ describe('policy-vehicles.vue', () => {
// Arrange
const vin = getRandomString(17, 17);
const endorsements = [getRandomString(10, 20)];
const policyVehicle = {
vin,
endorsements
};
const testValues = {
selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [
{
vin,
endorsements
}
policyVehicle
]
};
@ -680,6 +711,9 @@ describe('policy-vehicles.vue', () => {
useMainStore().order = {
policy: {
vehicles: [{ vin }]
},
vehicle: {
vin: null
}
};

View file

@ -53,8 +53,12 @@ import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js';
import endorsementOptions from '@/constants/endorsement-options.js';
import globalRules from '@/constants/global-rules.js';
import { useMainStore } from '@/store/index.js';
import bailoutCode from '@/constants/bailoutCode';
import bailoutMessage from '@/constants/bailoutMessage';
import {
deductibleForSelectedVehicle, endorsementsForSelectedVehicle,
noCoverageForSelectedVehicle,
repairWaivedForSelectedVehicle
} from '@/helpers/policy-vehicle-helper';
export default {
name: 'policy-vehicles',
@ -82,6 +86,7 @@ export default {
return {
policyVehicles,
selectedVehicleVin: '',
selectedPolicyVehicle: null,
displayGeneric: true,
policyVinFound: true,
rules: {
@ -108,33 +113,16 @@ export default {
return mappedData;
},
noCoverageForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) =>
policyVehicle.vin === this.selectedVehicleVin);
return (vehicle?.coverages?.length ?? 0) === 0;
return noCoverageForSelectedVehicle(this.selectedPolicyVehicle);
},
deductibleForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) =>
policyVehicle?.vin === this.selectedVehicleVin);
if (!vehicle) {
return undefined;
}
return vehicle.coverages?.length ?? false
? vehicle?.coverages[0].deductible
: 0;
return deductibleForSelectedVehicle(this.selectedPolicyVehicle);
},
endorsementsForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) =>
policyVehicle?.vin === this.selectedVehicleVin);
if (vehicle?.endorsements?.length > 0) {
return vehicle.endorsements;
}
return [];
return endorsementsForSelectedVehicle(this.selectedPolicyVehicle);
},
repairWaivedForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) =>
policyVehicle.vin === this.selectedVehicleVin);
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle);
},
selectedVehicle() {
const vehicle = this.mainStore.lookupVehicleByVin(this.selectedVehicleVin);
@ -147,6 +135,7 @@ export default {
// clear previously selected vehicle and image
this.mainStore.resetVehicleState();
this.displayGeneric = true;
this.selectedPolicyVehicle = null;
} else {
// get vehicle details from selected VIN
const vehicle = await this.lookupVehicleByVin(value);
@ -155,18 +144,22 @@ export default {
if (vehicle?.error === true) {
this.mainStore.resetVehicleState();
this.displayGeneric = true;
this.selectedPolicyVehicle = null;
return;
}
if (vehicle) {
// save selected vehicle to the store
this.mainStore.updateVehicle(vehicle.data);
this.displayGeneric = false;
this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value);
}
}
}
},
beforeMount() {
if (this.policyVehicles?.length === 1) {
if (this.mainStore.order.vehicle.vin) {
this.selectedVehicleVin = this.mainStore.order.vehicle.vin;
} else if (this.policyVehicles?.length === 1) {
this.selectedVehicleVin = this.policyVehicles[0]?.vin;
}
},

View file

@ -57,6 +57,7 @@
v-if="carrierUrl"
ref="siteFooter"
cmsWidgetName="SiteFooterWidget"
:isStackedVertically="true"
:isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction"
@backClicked="navigateBack" />

View file

@ -14,6 +14,11 @@ const navigationScenarios = Object.freeze({
CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES: 'CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES',
SAVE_SESSION_FAILED: 'SAVE_SESSION_FAILED',
// Duplicate Check
CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE: 'CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE',
CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES: 'CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES',
CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE: 'CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE',
// YMMS
SELECTED_YEAR: 'SELECTED_YEAR',
SELECTED_MAKE: 'SELECTED_MAKE',

View file

@ -420,6 +420,18 @@ const routingTable = () => [
{
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
destinationIssPageValue: issPageValues.POLICY_VEHICLES
},
{
scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE,
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE
},
{
scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE,
destinationIssPageValue: issPageValues.VEHICLE_SELECTION
},
{
scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES,
destinationIssPageValue: issPageValues.VEHICLE_SELECTION
}
]
},

View file

@ -14,6 +14,11 @@ import coverageStatuses from '@/constants/coverage-statuses';
import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants';
import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper';
import { paymentMethods } from '@/constants/payment-method-constants';
import {
deductibleForSelectedVehicle, endorsementsForSelectedVehicle,
noCoverageForSelectedVehicle,
repairWaivedForSelectedVehicle
} from '@/helpers/policy-vehicle-helper';
const storeId = 'main';
@ -176,7 +181,9 @@ const getDefaultState = () => ({
workOrderNumber: null,
originalDeductible: null,
currentDeductible: null,
carrierPhoneNumber: null
carrierPhoneNumber: null,
loadedFromDupeCheck: null,
loadedSessionClearedPreviousData: null
},
applicationUser: {
experiments: [],
@ -231,6 +238,7 @@ export const useMainStore = defineStore({
|| state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP,
isDropOffAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF,
isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired,
isClaimAlreadyRegistered: (state) => state.order.payment.insuranceCoverage.claimNumber !== null,
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
isNoComp: (state) => state.order.policy.coverageStatus === coverageStatuses.NO_COMP,
isVerifiedCoverageStatus: (state) => state.order.policy.coverageStatus === coverageStatuses.VERIFIED,
@ -1065,6 +1073,14 @@ export const useMainStore = defineStore({
saveSession() {
const { vehicle, damage, policy, customer, contactInfo, payment,
lineItems, serviceLocation, schedule } = this.order;
// We don't want to save the session for a loaded session until the car ID is set
if (this.order.loadedFromDupeCheck && !vehicle.carId) {
return Promise.resolve(null);
}
const loadedFromDupeCheck = !!(this.order.loadedFromDupeCheck && !this.order.loadedSessionClearedPreviousData);
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace);
return new Promise((resolve, reject) => {
globalMethods.callHttpClient({
@ -1125,7 +1141,7 @@ export const useMainStore = defineStore({
state: customer.address?.state,
zipCode: customer.address?.zipCode?.toString()
},
emailAddress: contactInfo.emailAddress,
emailAddress: contactInfo.emailAddress || customer.emailAddress,
firstName: contactInfo.firstName || customer.firstName,
lastName: contactInfo.lastName || customer.lastName,
phoneNumber: contactInfo.phoneNumber,
@ -1182,19 +1198,26 @@ export const useMainStore = defineStore({
referralCorrelationId: this.order.referralCorrelationId,
referralSequenceNumber: this.order.referralSequenceNumber,
eon: this.order.eon,
submitToMainframe: !!this.order.referralNumber
submitToMainframe: !!this.order.referralNumber,
loadedFromDupeCheck
},
additionalSuccessEventDataHandler: (response) =>
`Email provided: ${customer.emailAddress ? 'true' : 'false'}`
}).then((response) => resolve(response), (error) => reject(error));
}).then((response) => {
if (loadedFromDupeCheck) {
this.order.loadedSessionClearedPreviousData = true;
}
resolve(response);
}, (error) => reject(error));
});
},
loadSession() {
async loadSession() {
const { applicationUser, order, issConfig } = this;
// TODO how to get savedSessionId for a duplicate referral?
return new Promise((resolve, reject) => {
globalMethods.callHttpClient({
try {
const response = await globalMethods.callHttpClient({
method: endpoints.LoadSession.method,
endpoint: endpoints.LoadSession.url,
payload: {
@ -1204,118 +1227,81 @@ export const useMainStore = defineStore({
parentAccountNumber: issConfig.parentAccountNumber,
referralCorrelationId: order.referralCorrelationId
}
}).then((response) => {
const { data } = response;
if (!data) {
// TODO how should we handle this case?
return resolve(data);
}
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
applicationUser.experiments = data.applicationUser?.experiments ?? [];
applicationUser.lastPageVisited = data.applicationUser?.lastPage;
applicationUser.pageData = data.applicationUser?.pageData ?? {};
applicationUser.savedSessionId = data.applicationUser?.savedSessionId; // TODO this might just be what is passed
applicationUser.hasSentSaveQuoteEmail = data.applicationUser?.hasSentSaveQuoteEmail;
order.vehicle.registration.licensePlate = data.order?.vehicle?.registration?.licensePlateNumber;
order.vehicle.imageUrl = data.order?.vehicle?.imageUrl;
order.vehicle.imageColor = data.order?.vehicle?.imageVifColor;
order.vehicle.imageVifNumber = data.order?.vehicle?.imageVifNumber;
order.vehicle.year = data.order?.vehicle?.year;
order.vehicle.make = data.order?.vehicle?.make;
order.vehicle.model = data.order?.vehicle?.model;
order.vehicle.style = data.order?.vehicle?.style;
order.vehicle.carId = data.order?.vehicle?.carId;
order.vehicle.category = data.order?.vehicle?.category;
order.vehicle.vin = data.order?.vehicle?.vin;
order.customer.emailAddress = data.order?.customer?.emailAddress;
order.customer.firstName = data.order?.policy?.policyHolder?.policyFirstName;
order.customer.lastName = data.order?.policy?.policyHolder?.policyLastName;
order.customer.phoneNumber = data.order?.policy?.policyHolder?.policyPhoneNumber;
order.customer.address.streetAddress = data.order?.customer?.address?.streetAddress;
order.customer.address.streetAddress2 = data.order?.customer?.address?.streetAddress2;
order.customer.address.city = data.order?.customer?.address?.city;
order.customer.address.state = data.order?.customer?.address?.state;
order.customer.address.zipCode = data.order?.customer?.address?.zipCode;
order.damage.isRepair = data.order?.damage?.isRepair;
order.damage.numberOfChips = data.order?.damage?.numberOfChips;
order.damage.glassToReplace = data.order?.damage?.glassToReplace;
order.damage.capabilityQuestionAnswers = data.order?.damage?.capabilityQuestionAnswers;
order.damage.moldingQuestionAnswers = data.order?.damage?.moldingQuestionAnswers;
order.damage.partQuestionAnswers = data.order?.damage?.partQuestionAnswers;
order.policy.policyNumber = data.order?.policy?.policyNumber;
order.policy.policyZipCode = data.order?.policy?.policyZipCode;
order.policy.noCoverage = data.order?.policy?.noCoverage;
order.policy.policyLookupSuccessful = data.order?.policy?.policyLookupSuccessful; // TODO probably don't need to load this
order.policy.dateOfLoss = data.order?.damage?.dateOfLoss;
order.policy.damageCause = data.order?.damage?.damageCause;
order.policy.damageState = data.order?.damage?.damageState;
order.policy.damageCity = data.order?.damage?.damageCity;
order.policy.isDamageGlassOnly = data.order?.damage?.isDamageGlassOnly;
order.originalDeductible = data.order?.policy?.originalDeductible;
order.currentDeductible = data.order?.policy?.currentDeductible;
order.lineItems.glassParts = data.order?.lineItems?.glassParts;
// TODO otherParts
order.lineItems.supportingItems = data.order?.lineItems?.supportingItems;
order.lineItems.vaps = data.order?.lineItems?.vaps;
order.payment.insuranceCoverage.isVerified = data.order?.payment?.insuranceCoverage?.isVerified;
this.updateCoverageStatus(data.order?.payment?.insuranceCoverage?.coverageStatus ?? coverageStatuses.PENDING);
const parentAccountNumber = Number.isNaN(data.order?.payment?.parentAccountNumber)
? 0
: data.order?.payment?.parentAccountNumber;
order.payment.parentAccountNumber = parentAccountNumber;
issConfig.parentAccountNumber = parentAccountNumber;
order.payment.insuranceCoverage.claimNumber = data.order?.payment?.insuranceCoverage?.claimNumber;
order.serviceLocation.address = data.order?.serviceLocation?.streetAddress;
order.serviceLocation.address2 = data.order?.serviceLocation?.streetAddress2;
order.serviceLocation.city = data.order?.serviceLocation?.city;
order.serviceLocation.state = data.order?.serviceLocation?.state;
order.serviceLocation.zipCode = data.order?.serviceLocation?.zipCode;
order.serviceLocation.zipCodeCtu = data.order?.serviceLocation?.zipCodeCtu;
order.serviceLocation.appointmentType = data.order?.serviceLocation?.appointmentType;
order.serviceLocation.isVehicleProtected = data.order?.serviceLocation?.isVehicleProtected;
order.serviceLocation.provider.providerNumber = data.order?.serviceLocation?.provider?.providerNumber;
order.serviceLocation.provider.address.streetAddress = data.order?.serviceLocation?.provider?.address?.streetAddress;
order.serviceLocation.provider.address.city = data.order?.serviceLocation?.provider?.address?.city;
order.serviceLocation.provider.address.state = data.order?.serviceLocation?.provider?.address?.state;
order.serviceLocation.provider.address.zipCode = data.order?.serviceLocation?.provider?.address?.zipCode;
order.serviceLocation.provider.address.zipCodeCtu = data.order?.serviceLocation?.provider?.address?.zipCodeCtu;
order.contactInfo.firstName = data.order?.customer?.firstName;
order.contactInfo.lastName = data.order?.customer?.lastName;
order.contactInfo.emailAddress = data.order?.customer?.emailAddress;
order.contactInfo.phoneNumber = data.order?.customer?.phoneNumber;
order.contactInfo.requestTextUpdates = data.order?.customer?.isSmsOptIn; // TODO confirm
order.contactInfo.notesForTechnician = data.order?.serviceLocation?.techNotes;
// TODO service phone number ??
// TODO isSmsOptIn service ??
order.schedule.date = data.order?.schedule?.date;
order.schedule.startTime = data.order?.schedule?.startTime;
order.schedule.endTime = data.order?.schedule?.endTime;
order.schedule.routeCode = data.order?.schedule?.routeCode;
order.schedule.jobMaxMinutes = data.order?.schedule?.jobMaxMinutes;
order.schedule.jobMinMinutes = data.order?.schedule?.jobMinMinutes;
order.referralNumber = data.order?.referralNumber;
order.referralDate = data.order?.referralDate;
order.referralCorrelationId = data.order?.referralCorrelationId;
order.referralSequenceNumber = data.order?.referralSequenceNumber;
order.eon = data.order?.eon;
// TODO order.workOrderNumber not set, but this likely is not an issue since WON => will not return
return resolve(data);
}, (error) => {
reject(error);
});
});
const { data } = response;
if (!data) {
// TODO how should we handle this case?
return response;
}
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
applicationUser.experiments = data.applicationUser?.experiments ?? [];
applicationUser.savedSessionId = data.applicationUser?.savedSessionId;
if (order.policy.policyLookupSuccessful) {
order.customer.emailAddress = data.customer?.emailAddress;
order.customer.firstName = data.customer?.firstName;
order.customer.lastName = data.customer?.lastName;
order.customer.phoneNumber = data?.customer?.phoneNumber;
order.customer.address.streetAddress = data.customer?.address?.streetAddress;
order.customer.address.streetAddress2 = data.customer?.address?.streetAddress2;
order.customer.address.city = data.customer?.address?.city;
order.customer.address.state = data.customer?.address?.state;
order.customer.address.zipCode = data.customer?.address?.zipCode;
order.contactInfo.firstName = data?.customer?.firstName;
order.contactInfo.lastName = data?.customer?.lastName;
order.contactInfo.emailAddress = data?.customer?.emailAddress;
order.contactInfo.phoneNumber = data?.customer?.phoneNumber;
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus;
order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber;
if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) {
order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber;
if (data.vehicle.vin) {
const vehicle = order.policy.vehicles.find((v) => v.vin === data.vehicle.vin);
if (vehicle) {
const vehicleResponse = await this.lookupVehicleByVin(vehicle.vin);
if (vehicleResponse) {
Object.assign(
vehicleResponse.data,
{
policyVehicleId: vehicle.id,
vin: vehicle.vin,
noCoverage: noCoverageForSelectedVehicle(vehicle),
deductible: deductibleForSelectedVehicle(vehicle),
repairWaived: repairWaivedForSelectedVehicle(vehicle),
endorsements: endorsementsForSelectedVehicle(vehicle)
}
);
this.updateVehicle(vehicleResponse.data);
}
}
}
order.vehicle.year = data.vehicle.year;
order.vehicle.make = data.vehicle.make;
order.vehicle.model = data.vehicle.model;
order.vehicle.style = data.vehicle.style;
}
}
order.referralNumber = data?.referralNumber;
order.referralDate = data?.referralDate;
order.referralCorrelationId = data?.referralCorrelationId;
order.referralSequenceNumber = data?.referralSequenceNumber;
order.eon = data?.eon;
order.loadedFromDupeCheck = true;
order.loadedSessionClearedPreviousData = false;
return data;
} catch (ex) {
// TODO how should we handle this case?
throw ex;
}
},
setSaveSessionPromise(promise) {
@ -1443,6 +1429,12 @@ export const useMainStore = defineStore({
});
},
resetInsurance() {
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
this.order.payment.insuranceCoverage.claimNumber = null;
this.order.payment.insuranceCoverage.isVerified = false;
},
updateSupportingItems(partsData) {
this.order.lineItems.supportingItems = partsData;
},
@ -2151,8 +2143,11 @@ export const useMainStore = defineStore({
this.order.customer.address.zipCode = null;
this.order.customer.address.streetAddress = null;
this.order.customer.address.streetAddress2 = null;
this.order.loadedFromDupeCheck = null;
this.order.loadedSessionClearedPreviousData = null;
this.resetVehicleState();
this.resetDamageState();
this.resetInsurance();
this.resetBailout();
},

View file

@ -217,6 +217,8 @@ describe('Store', () => {
noCoverage: expectedNoCoverage
};
store.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
// Act
store.updateVehicle(vehicle);
@ -961,10 +963,8 @@ describe('Store', () => {
const applicationUser = {
crmCustomerId: getRandomString(6, 6),
experiments: getRandomString(6, 6),
lastPage: getRandomString(6, 6),
pageData: getRandomString(6, 6),
savedSessionId: getRandomString(6, 6),
hasSentSaveQuoteEmail: getRandomBoolean()
savedSessionId: getRandomString(6, 6)
};
const vehicle = {
year: getRandomString(6, 6),
@ -973,40 +973,7 @@ describe('Store', () => {
style: getRandomString(6, 6),
vin: getRandomString(6, 6),
carId: getRandomString(6, 6),
category: getRandomString(6, 6),
registration: {
licensePlateNumber: getRandomString(6, 6)
},
imageUrl: getRandomString(6, 6),
imageVifNumber: getRandomString(6, 6),
imageVifColor: getRandomString(6, 6)
};
const damage = {
numberOfChips: getRandomString(6, 6),
isRepair: getRandomBoolean(),
glassToReplace: getRandomString(6, 6),
capabilityQuestionAnswers: getRandomString(6, 6),
moldingQuestionAnswers: getRandomString(6, 6),
partQuestionAnswers: getRandomString(6, 6),
dateOfLoss: getRandomString(6, 6),
damageCause: getRandomString(6, 6),
damageState: getRandomString(6, 6),
damageCity: getRandomString(6, 6),
isDamageGlassOnly: getRandomBoolean()
};
const policy = {
policyNumber: getRandomString(6, 6),
policyZipCode: getRandomBoolean(),
noCoverage: getRandomString(6, 6),
policyLookupSuccessful: getRandomBoolean(),
policyHolder: {
policyFirstName: getRandomString(6, 6),
policyLastName: getRandomString(6, 6),
policyPhoneNumber: getRandomString(6, 6),
policyState: getRandomString(6, 6)
},
originalDeductible: getRandomString(6, 6),
currentDeductible: getRandomString(6, 6)
licensePlateNumber: getRandomString(6, 6)
};
const customer = {
firstName: getRandomString(6, 6),
@ -1023,76 +990,22 @@ describe('Store', () => {
zipCodeCtu: getRandomString(6, 6)
}
};
const provider = {
providerNumber: getRandomString(6, 6),
address: {
streetAddress: getRandomString(6, 6),
streetAddress2: getRandomString(6, 6),
city: getRandomString(6, 6),
state: getRandomString(6, 6),
zipCode: getRandomString(6, 6),
zipCodeCtu: getRandomString(6, 6)
}
};
const serviceLocation = {
streetAddress: getRandomString(6, 6),
streetAddress2: getRandomString(6, 6),
city: getRandomString(6, 6),
state: getRandomString(6, 6),
zipCode: getRandomString(6, 6),
zipCodeCtu: getRandomString(6, 6),
appointmentType: getRandomString(6, 6),
isVehicleProtected: getRandomBoolean(),
provider,
techNotes: getRandomString(6, 6),
phoneNumber: getRandomString(6, 6),
isSmsOptIn: getRandomBoolean()
};
const lineItems = {
glassParts: getRandomString(6, 6),
supportingItems: getRandomString(6, 6),
vaps: getRandomString(6, 6),
serverData: getRandomString(6, 6)
};
const payment = {
insuranceCoverage: {
isVerified: getRandomBoolean(),
coverageStatus: getRandomString(6, 6),
claimNumber: getRandomString(6, 6)
},
parentAccountNumber: getRandomString(6, 6)
};
const schedule = {
date: getRandomString(6, 6),
startTime: getRandomString(6, 6),
endTime: getRandomString(6, 6),
routeCode: getRandomString(6, 6),
jobMaxMinutes: getRandomString(6, 6),
jobMinMinutes: getRandomString(6, 6)
};
const fullApiResponse = {
data: {
applicationUser,
order: {
vehicle,
damage,
policy,
customer,
serviceLocation,
lineItems,
payment,
schedule,
referralNumber: getRandomString(6, 6),
referralDate: getRandomString(6, 6),
referralCorrelationId: getRandomString(6, 6),
referralSequenceNumber: getRandomString(6, 6),
eon: getRandomString(6, 6)
}
vehicle,
customer,
referralNumber: getRandomString(6, 6),
referralDate: getRandomString(6, 6),
referralCorrelationId: getRandomString(6, 6),
referralSequenceNumber: getRandomString(6, 6),
eon: getRandomString(6, 6)
}
};
it('calls load session api endpoint', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({ data: {} }));
// Act
store.loadSession();
@ -1105,7 +1018,7 @@ describe('Store', () => {
});
it('Returns expected response object', async () => {
// Arrange
const response = { data: {ReferralNumber: getRandomString(6, 6)} };
const response = { data: { ReferralNumber: getRandomString(6, 6) } };
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
// Act
@ -1117,37 +1030,21 @@ describe('Store', () => {
it('sets expected application user data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const originalSavedSessionTimeout = store.applicationUser.savedSessionTimeout;
const originalEventBus = store.applicationUser.eventBus;
const originalSaveSessionPromise = store.applicationUser.saveSessionPromise;
const originalTriggeredSiteEntry = store.applicationUser.triggeredSiteEntry;
const originalDuplicateOrders = store.applicationUser.duplicateOrders;
// Act
await store.loadSession();
// Asserts
expect(store.applicationUser.experiments).toEqual(applicationUser.experiments);
expect(store.applicationUser.pageData).toBe(applicationUser.pageData);
expect(store.applicationUser.savedSessionId).toBe(applicationUser.savedSessionId);
expect(store.applicationUser.crmCustomerId).toBe(applicationUser.crmCustomerId);
expect(store.applicationUser.lastPageVisited).toBe(applicationUser.lastPage);
expect(store.applicationUser.hasSentSaveQuoteEmail).toBe(applicationUser.hasSentSaveQuoteEmail);
expect(store.applicationUser.eventBus).toEqual(originalEventBus);
expect(store.applicationUser.savedSessionTimeout).toBe(originalSavedSessionTimeout);
expect(store.applicationUser.saveSessionPromise).toBe(originalSaveSessionPromise);
expect(store.applicationUser.triggeredSiteEntry).toBe(originalTriggeredSiteEntry);
expect(store.applicationUser.duplicateOrders).toEqual(originalDuplicateOrders);
});
it('sets expected vehicle data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const originalRegistrationAddress = store.vehicle.registration.address;
const originalRegistrationCity = store.vehicle.registration.city;
const originalRegistrationState = store.vehicle.registration.state;
const originalRegistrationZipCode = store.vehicle.registration.zipCode;
const originalRegistrationFirstName = store.vehicle.registration.firstName;
const originalRegistrationLastName = store.vehicle.registration.lastName;
store.order.policy.policyLookupSuccessful = true;
store.policy.vehicles = [{ vin: vehicle.vin }];
// Act
await store.loadSession();
@ -1157,65 +1054,16 @@ describe('Store', () => {
expect(store.vehicle.make).toBe(vehicle.make);
expect(store.vehicle.model).toBe(vehicle.model);
expect(store.vehicle.style).toBe(vehicle.style);
expect(store.vehicle.carId).toBe(vehicle.carId);
expect(store.vehicle.category).toBe(vehicle.category);
expect(store.vehicle.vin).toBe(vehicle.vin);
expect(store.vehicle.imageUrl).toBe(vehicle.imageUrl);
expect(store.vehicle.imageVifNumber).toBe(vehicle.imageVifNumber);
expect(store.vehicle.imageColor).toBe(vehicle.imageVifColor);
expect(store.vehicle.registration.licensePlate).toBe(vehicle.registration.licensePlateNumber);
expect(store.vehicle.registration.address).toBe(originalRegistrationAddress);
expect(store.vehicle.registration.city).toBe(originalRegistrationCity);
expect(store.vehicle.registration.state).toBe(originalRegistrationState);
expect(store.vehicle.registration.zipCode).toBe(originalRegistrationZipCode);
expect(store.vehicle.registration.firstName).toBe(originalRegistrationFirstName);
expect(store.vehicle.registration.lastName).toBe(originalRegistrationLastName);
});
it('sets expected damage data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
// Act
await store.loadSession();
// Asserts
expect(store.damage.isRepair).toBe(damage.isRepair);
expect(store.damage.numberOfChips).toBe(damage.numberOfChips);
expect(store.damage.glassToReplace).toBe(damage.glassToReplace);
expect(store.damage.partQuestionAnswers).toBe(damage.partQuestionAnswers);
expect(store.damage.moldingQuestionAnswers).toBe(damage.moldingQuestionAnswers);
expect(store.damage.capabilityQuestionAnswers).toBe(damage.capabilityQuestionAnswers);
});
it('sets expected policy data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const originalRepairDeductible = store.policy.deductible.repair;
const originalReplaceDeductible = store.policy.deductible.replace;
const originalVehicles = store.policy.vehicles;
const originalEndorsementQuestionAnswers = store.policy.endorsementQuestionAnswers;
// Act
await store.loadSession();
// Asserts
expect(store.policy.policyNumber).toBe(policy.policyNumber);
expect(store.policy.policyZipCode).toBe(policy.policyZipCode);
expect(store.policy.dateOfLoss).toBe(damage.dateOfLoss);
expect(store.policy.damageCause).toBe(damage.damageCause);
expect(store.policy.damageState).toBe(damage.damageState);
expect(store.policy.damageCity).toBe(damage.damageCity);
expect(store.policy.isDamageGlassOnly).toBe(damage.isDamageGlassOnly);
expect(store.policy.policyLookupSuccessful).toBe(policy.policyLookupSuccessful);
expect(store.policy.noCoverage).toBe(policy.noCoverage);
expect(store.policy.deductible.repair).toBe(originalRepairDeductible);
expect(store.policy.deductible.replace).toBe(originalReplaceDeductible);
expect(store.policy.vehicles).toEqual(originalVehicles);
expect(store.policy.endorsementQuestionAnswers).toBe(originalEndorsementQuestionAnswers);
expect(store.vehicle.registration.licensePlate).toBe(vehicle.licensePlateNumber);
});
it('sets expected customer data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
store.order.policy.policyLookupSuccessful = true;
store.policy.vehicles = [{ vin: vehicle.vin }];
// Act
await store.loadSession();
@ -1225,90 +1073,10 @@ describe('Store', () => {
expect(store.order.customer.address.city).toBe(customer.address.city);
expect(store.order.customer.address.state).toBe(customer.address.state);
expect(store.order.customer.address.zipCode).toBe(customer.address.zipCode);
expect(store.order.customer.firstName).toBe(policy.policyHolder.policyFirstName);
expect(store.order.customer.lastName).toBe(policy.policyHolder.policyLastName);
expect(store.order.customer.firstName).toBe(customer.firstName);
expect(store.order.customer.lastName).toBe(customer.lastName);
expect(store.order.customer.emailAddress).toBe(customer.emailAddress);
expect(store.order.customer.phoneNumber).toBe(policy.policyHolder.policyPhoneNumber);
});
it('sets expected serviceLocation data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
// Act
await store.loadSession();
// Asserts
expect(store.order.serviceLocation.address).toBe(serviceLocation.streetAddress);
expect(store.order.serviceLocation.address2).toBe(serviceLocation.streetAddress2);
expect(store.order.serviceLocation.city).toBe(serviceLocation.city);
expect(store.order.serviceLocation.state).toBe(serviceLocation.state);
expect(store.order.serviceLocation.zipCode).toBe(serviceLocation.zipCode);
expect(store.order.serviceLocation.zipCodeCtu).toBe(serviceLocation.zipCodeCtu);
expect(store.order.serviceLocation.appointmentType).toBe(serviceLocation.appointmentType);
expect(store.order.serviceLocation.isVehicleProtected).toBe(serviceLocation.isVehicleProtected);
expect(store.order.serviceLocation.provider.providerNumber).toBe(provider.providerNumber);
expect(store.order.serviceLocation.provider.address.streetAddress).toBe(provider.address.streetAddress);
expect(store.order.serviceLocation.provider.address.city).toBe(provider.address.city);
expect(store.order.serviceLocation.provider.address.state).toBe(provider.address.state);
expect(store.order.serviceLocation.provider.address.zipCode).toBe(provider.address.zipCode);
expect(store.order.serviceLocation.provider.address.zipCodeCtu).toBe(provider.address.zipCodeCtu);
});
it('sets expected lineItems data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const originalOtherParts = store.order.lineItems.otherParts;
// Act
await store.loadSession();
// Asserts
expect(store.order.lineItems.glassParts).toBe(lineItems.glassParts);
expect(store.order.lineItems.otherParts).toBe(originalOtherParts);
expect(store.order.lineItems.supportingItems).toBe(lineItems.supportingItems);
expect(store.order.lineItems.vaps).toBe(lineItems.vaps);
});
it('sets expected payment data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
// Act
await store.loadSession();
// Asserts
expect(store.order.payment.insuranceCoverage.isVerified).toBe(payment.insuranceCoverage.isVerified);
expect(store.order.payment.insuranceCoverage.coverageStatus).toBe(payment.insuranceCoverage.coverageStatus);
expect(store.order.payment.parentAccountNumber).toBe(payment.parentAccountNumber);
expect(store.issConfig.parentAccountNumber).toBe(payment.parentAccountNumber);
expect(store.order.payment.insuranceCoverage.claimNumber).toBe(payment.insuranceCoverage.claimNumber);
});
it('sets expected contactInfo data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
// Act
await store.loadSession();
// Asserts
expect(store.order.contactInfo.firstName).toBe(customer.firstName);
expect(store.order.contactInfo.lastName).toBe(customer.lastName);
expect(store.order.contactInfo.emailAddress).toBe(customer.emailAddress);
expect(store.order.contactInfo.phoneNumber).toBe(customer.phoneNumber);
expect(store.order.contactInfo.requestTextUpdates).toBe(customer.isSmsOptIn);
expect(store.order.contactInfo.notesForTechnician).toBe(serviceLocation.techNotes);
});
it('sets expected schedule data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
// Act
await store.loadSession();
// Asserts
expect(store.order.schedule.date).toBe(schedule.date);
expect(store.order.schedule.startTime).toBe(schedule.startTime);
expect(store.order.schedule.endTime).toBe(schedule.endTime);
expect(store.order.schedule.routeCode).toBe(schedule.routeCode);
expect(store.order.schedule.jobMaxMinutes).toBe(schedule.jobMaxMinutes);
expect(store.order.customer.phoneNumber).toBe(customer.phoneNumber);
});
it('sets expected remaining order data', async () => {
// Arrange
@ -1319,14 +1087,12 @@ describe('Store', () => {
await store.loadSession();
// Asserts
expect(store.order.referralNumber).toBe(fullApiResponse.data.order.referralNumber);
expect(store.order.referralDate).toBe(fullApiResponse.data.order.referralDate);
expect(store.order.referralCorrelationId).toBe(fullApiResponse.data.order.referralCorrelationId);
expect(store.order.referralSequenceNumber).toBe(fullApiResponse.data.order.referralSequenceNumber);
expect(store.order.eon).toBe(fullApiResponse.data.order.eon);
expect(store.order.referralNumber).toBe(fullApiResponse.data.referralNumber);
expect(store.order.referralDate).toBe(fullApiResponse.data.referralDate);
expect(store.order.referralCorrelationId).toBe(fullApiResponse.data.referralCorrelationId);
expect(store.order.referralSequenceNumber).toBe(fullApiResponse.data.referralSequenceNumber);
expect(store.order.eon).toBe(fullApiResponse.data.eon);
expect(store.order.workOrderNumber).toBe(originalWorkOrderNumber);
expect(store.order.originalDeductible).toBe(policy.originalDeductible);
expect(store.order.currentDeductible).toBe(policy.currentDeductible);
});
});
it('api call throws exception', async () => {