Merge branch 'develop' into feature/humphries/INSR-7775.1
This commit is contained in:
commit
fd4434f48d
37 changed files with 520 additions and 835 deletions
|
|
@ -94,10 +94,11 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.response.status !== 404) {
|
if (error.response.status !== 404) {
|
||||||
global.$logger.logError(`${method}: ${endpoint}: ${error.message}`, error.response);
|
const errorData = { method, url, payload, error };
|
||||||
|
global.$logger.logError(`${method}: ${endpoint}`, errorData);
|
||||||
if (bailoutOnError && global.bailoutOnAxiosError !== undefined)
|
if (bailoutOnError && global.bailoutOnAxiosError !== undefined)
|
||||||
{
|
{
|
||||||
global.bailoutOnAxiosError({ url, error });
|
global.bailoutOnAxiosError(errorData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reject(error.response);
|
return reject(error.response);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ global.$logger = {
|
||||||
function setupMocksForHttpClient({
|
function setupMocksForHttpClient({
|
||||||
endpoint = null,
|
endpoint = null,
|
||||||
isError = false,
|
isError = false,
|
||||||
additionalData = null
|
additionalData = null,
|
||||||
|
bailoutOnError = false
|
||||||
}) {
|
}) {
|
||||||
// Clear node module
|
// Clear node module
|
||||||
axios.mockClear();
|
axios.mockClear();
|
||||||
|
|
@ -57,7 +58,8 @@ function setupMocksForHttpClient({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
endpoint,
|
endpoint,
|
||||||
logApiCall: true
|
logApiCall: true,
|
||||||
|
bailoutOnError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,3 +94,21 @@ it('Global Methods - Call Http Client - Should Reject Promise', () => {
|
||||||
expect(err.status).toEqual(500);
|
expect(err.status).toEqual(500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Global Methods - Call Http Client - Rejected Promised - bailoutOnError: true - Calls global.bailoutOnAxiosError', () => {
|
||||||
|
// Arrange
|
||||||
|
const endpoint = 'https://mock.safelite.com';
|
||||||
|
const httpArgs = setupMocksForHttpClient({
|
||||||
|
endpoint,
|
||||||
|
isError: true,
|
||||||
|
bailoutOnError: true
|
||||||
|
});
|
||||||
|
analyticsMixIn.methods.pushEventToGA = jest.fn();
|
||||||
|
global.bailoutOnAxiosError = jest.fn();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
globalMethods.callHttpClient(httpArgs).catch((err) => {
|
||||||
|
// Assert
|
||||||
|
expect(global.bailoutOnAxiosError).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -4,8 +4,8 @@ import submitType from '@/constants/submit-type';
|
||||||
/*
|
/*
|
||||||
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
||||||
*/
|
*/
|
||||||
async function saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA }) {
|
async function saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA, bailoutOnError }) {
|
||||||
const savedSessionInfo = await store.saveSession({ submitAfterSave, createWorkOrderNumberForPIA });
|
const savedSessionInfo = await store.saveSession({ submitAfterSave, createWorkOrderNumberForPIA, bailoutOnError });
|
||||||
if (savedSessionInfo) {
|
if (savedSessionInfo) {
|
||||||
store.setSaveSessionInfo(savedSessionInfo.data);
|
store.setSaveSessionInfo(savedSessionInfo.data);
|
||||||
}
|
}
|
||||||
|
|
@ -16,11 +16,11 @@ async function saveSessionHelper(store, { submitAfterSave, createWorkOrderNumber
|
||||||
This will also set Referral information in the store after saving, and then
|
This will also set Referral information in the store after saving, and then
|
||||||
update the cookie. To force synchronous behavior pass in 'true' for shouldAwaitSaveSessionQueue
|
update the cookie. To force synchronous behavior pass in 'true' for shouldAwaitSaveSessionQueue
|
||||||
*/
|
*/
|
||||||
export async function saveSession({ shouldAwaitSaveSessionQueue = false, submitAfterSave = false, createWorkOrderNumberForPIA = false }) {
|
export async function saveSession({ shouldAwaitSaveSessionQueue = false, submitAfterSave = false, createWorkOrderNumberForPIA = false, bailoutOnError = false }) {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
const saveSessionPromise = store.applicationUser.saveSessionPromise
|
const saveSessionPromise = store.applicationUser.saveSessionPromise
|
||||||
? store.applicationUser.saveSessionPromise.then(() => saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA }))
|
? store.applicationUser.saveSessionPromise.then(() => saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA, bailoutOnError }))
|
||||||
: saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA });
|
: saveSessionHelper(store, { submitAfterSave, createWorkOrderNumberForPIA, bailoutOnError });
|
||||||
|
|
||||||
store.setSaveSessionPromise(saveSessionPromise);
|
store.setSaveSessionPromise(saveSessionPromise);
|
||||||
|
|
||||||
|
|
@ -38,7 +38,8 @@ export async function submitWorkOrder({ submitType }) {
|
||||||
store.resetSubmittedOrder();
|
store.resetSubmittedOrder();
|
||||||
await saveSession({
|
await saveSession({
|
||||||
shouldAwaitSaveSessionQueue: true,
|
shouldAwaitSaveSessionQueue: true,
|
||||||
submitAfterSave: true
|
submitAfterSave: true,
|
||||||
|
bailoutOnError: true
|
||||||
});
|
});
|
||||||
await store.createSubmittedOrder(submitType);
|
await store.createSubmittedOrder(submitType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,7 @@ export default {
|
||||||
this.navigateForward(this.partsOrQuestionsData, null);
|
this.navigateForward(this.partsOrQuestionsData, null);
|
||||||
},
|
},
|
||||||
requestCallbackBailout() {
|
requestCallbackBailout() {
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT, this.$route);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ const loadingModalStub = {
|
||||||
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn(),
|
||||||
|
navigateBailout: jest.fn()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -690,7 +691,7 @@ describe('coverageStatement.vue', () => {
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
test('If Verified ITAC, selected Cancel, navigate forward w/ CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP', () => {
|
test('If Verified ITAC, selected Cancel, navigateBailout', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const deductible = servicePrice + 1;
|
const deductible = servicePrice + 1;
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -716,11 +717,7 @@ describe('coverageStatement.vue', () => {
|
||||||
wrapper.vm.cancelClaim();
|
wrapper.vm.cancelClaim();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigateBailout).toHaveBeenCalled();
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -753,7 +750,7 @@ describe('coverageStatement.vue', () => {
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
test('If No comp and selected other shop, navigate forward with CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP ', () => {
|
test('If No comp and selected other shop, navigateBailout ', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
order: {
|
order: {
|
||||||
|
|
@ -778,11 +775,7 @@ describe('coverageStatement.vue', () => {
|
||||||
wrapper.vm.cancelClaim();
|
wrapper.vm.cancelClaim();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigateBailout).toHaveBeenCalled();
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('openCancelClaimModal', () => {
|
describe('openCancelClaimModal', () => {
|
||||||
|
|
|
||||||
|
|
@ -397,18 +397,7 @@ export default {
|
||||||
|
|
||||||
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
|
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
|
||||||
if (!this.isRepair || this.mainStore.isNoComp) {
|
if (!this.isRepair || this.mainStore.isNoComp) {
|
||||||
const pricingResults = await useMainStore().getITACPriceOrderItems(availableLineItems)
|
const pricingResults = await useMainStore().getITACPriceOrderItems(availableLineItems);
|
||||||
.catch((err) => {
|
|
||||||
useMainStore().setBailout(bailoutMessage.pricingResponseError(
|
|
||||||
availableLineItems.map((li) => li.partNumber),
|
|
||||||
{
|
|
||||||
code: err.code,
|
|
||||||
message: err.message,
|
|
||||||
data: err.data
|
|
||||||
}
|
|
||||||
));
|
|
||||||
this.navigateWithScenario(navigationScenarios.PRICING_LOOKUP_ERROR);
|
|
||||||
});
|
|
||||||
this.setBaseServiceLineItems(pricingResults);
|
this.setBaseServiceLineItems(pricingResults);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -419,8 +408,7 @@ export default {
|
||||||
this.mainStore.updateIsSafeliteProvider(true);
|
this.mainStore.updateIsSafeliteProvider(true);
|
||||||
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE);
|
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE);
|
||||||
} else {
|
} else {
|
||||||
this.mainStore.setBailout(bailoutMessage.coverageStatementInvalidState());
|
this.$router.navigateBailout(bailoutMessage.coverageStatementInvalidState());
|
||||||
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateWithScenario(scenario) {
|
navigateWithScenario(scenario) {
|
||||||
|
|
@ -474,8 +462,7 @@ export default {
|
||||||
},
|
},
|
||||||
cancelClaim() {
|
cancelClaim() {
|
||||||
this.mainStore.updateIsSafeliteProvider(false);
|
this.mainStore.updateIsSafeliteProvider(false);
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -357,11 +357,15 @@ describe('duplicateCheck.vue', () => {
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
expect.assertions(2);
|
||||||
|
try {
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
} catch (e) {
|
||||||
|
expect(e).toMatch(error);
|
||||||
|
}
|
||||||
expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1);
|
expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1);
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
});
|
||||||
test('coverageType deductible and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
test('coverageType deductible and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -140,18 +140,14 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const selectedReferral =
|
||||||
const selectedReferral =
|
this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||||
this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
|
||||||
|
|
||||||
if (selectedReferral) {
|
if (selectedReferral) {
|
||||||
await this.mainStore.loadSession(selectedReferral);
|
await this.mainStore.loadSession(selectedReferral);
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error on loading session from duplicate check ${err}`);
|
|
||||||
} finally {
|
|
||||||
this.navigateForward();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.navigateForward();
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
this.mainStore.updateDuplicateCheckVisited(true);
|
this.mainStore.updateDuplicateCheckVisited(true);
|
||||||
|
|
|
||||||
|
|
@ -34,44 +34,51 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const queryStringParams = this.parseQueryParms();
|
|
||||||
|
|
||||||
const { isAuthorized, clientData, decryptedParams } = await this.validateClientTagOnEntry(queryStringParams);
|
|
||||||
|
|
||||||
this.unauthorized = !isAuthorized;
|
|
||||||
if (!isAuthorized) {
|
|
||||||
// Remove the loading animation if client tag validation fails so users can see the Unauthorized Access message.
|
|
||||||
showIssLoadingModal(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.populateISSConfigValues(clientData);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check cookie
|
const queryStringParams = this.parseQueryParms();
|
||||||
const issCookie = getISSCookie();
|
|
||||||
if (issCookie !== null && issCookie.VehicleMake && issCookie.VehicleModel) {
|
|
||||||
const clientParentAccountNumber = clientData.parentAccountNumber;
|
|
||||||
const cookieParentAccountNumber = issCookie.ReferralParentAccountNumber;
|
|
||||||
|
|
||||||
if (clientParentAccountNumber === cookieParentAccountNumber) {
|
const { isAuthorized, clientData, decryptedParams } = await this.validateClientTagOnEntry(queryStringParams);
|
||||||
const savedSessionTimeStamp = new Date(issCookie.SavedSessionTimeoutDate);
|
|
||||||
const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp;
|
|
||||||
|
|
||||||
if (!isSavedSessionTimedOut) {
|
this.unauthorized = !isAuthorized;
|
||||||
this.mainStore.issConfig.enableContinueFromCookie = true;
|
if (!isAuthorized) {
|
||||||
|
// Remove the loading animation if client tag validation fails so users can see the Unauthorized Access message.
|
||||||
|
showIssLoadingModal(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.populateISSConfigValues(clientData);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check cookie
|
||||||
|
const issCookie = getISSCookie();
|
||||||
|
if (issCookie !== null && issCookie.VehicleMake && issCookie.VehicleModel) {
|
||||||
|
const clientParentAccountNumber = clientData.parentAccountNumber;
|
||||||
|
const cookieParentAccountNumber = issCookie.ReferralParentAccountNumber;
|
||||||
|
|
||||||
|
if (clientParentAccountNumber === cookieParentAccountNumber) {
|
||||||
|
const savedSessionTimeStamp = new Date(issCookie.SavedSessionTimeoutDate);
|
||||||
|
const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp;
|
||||||
|
|
||||||
|
if (!isSavedSessionTimedOut) {
|
||||||
|
this.mainStore.issConfig.enableContinueFromCookie = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
updateOrCreateISSCookie(true);
|
||||||
}
|
}
|
||||||
} else {
|
} catch {
|
||||||
updateOrCreateISSCookie(true);
|
updateOrCreateISSCookie(true);
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
updateOrCreateISSCookie(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clientData.parameters?.length > 0) {
|
if (clientData.parameters?.length > 0) {
|
||||||
const finalParams = this.combineClientParameters(clientData.parameters, { ...queryStringParams, ...decryptedParams });
|
const finalParams = this.combineClientParameters(clientData.parameters, { ...queryStringParams, ...decryptedParams });
|
||||||
this.populateStoreItemsFromParams(finalParams);
|
this.populateStoreItemsFromParams(finalParams);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
global.$logger.logError('[Entry Page] Client Setup Error:', e);
|
||||||
|
this.unauthorized = true;
|
||||||
|
showIssLoadingModal(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mainStore.applicationUser.coverageAttempts = 0;
|
this.mainStore.applicationUser.coverageAttempts = 0;
|
||||||
|
|
@ -151,37 +158,33 @@ export default {
|
||||||
this.mainStore.issConfig.isCoverageEnabled = data.coverageEnabled;
|
this.mainStore.issConfig.isCoverageEnabled = data.coverageEnabled;
|
||||||
this.mainStore.issConfig.siteType = data.siteType;
|
this.mainStore.issConfig.siteType = data.siteType;
|
||||||
|
|
||||||
try {
|
if (data.clientFlags) {
|
||||||
if (data.clientFlags) {
|
const clientFlags = JSON.parse(data.clientFlags);
|
||||||
const clientFlags = JSON.parse(data.clientFlags);
|
|
||||||
|
|
||||||
if (clientFlags.TPAEnabled) {
|
if (clientFlags.TPAEnabled) {
|
||||||
this.mainStore.issConfig.enableTPAFlow = true;
|
this.mainStore.issConfig.enableTPAFlow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientFlags.ClientFullName != null) {
|
if (clientFlags.ClientFullName != null) {
|
||||||
this.mainStore.issConfig.clientFullName = clientFlags.ClientFullName;
|
this.mainStore.issConfig.clientFullName = clientFlags.ClientFullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientFlags.ClientDisplayName != null) {
|
if (clientFlags.ClientDisplayName != null) {
|
||||||
this.mainStore.issConfig.clientDisplayName = clientFlags.ClientDisplayName;
|
this.mainStore.issConfig.clientDisplayName = clientFlags.ClientDisplayName;
|
||||||
this.mainStore.issConfig.clientPossessiveName = toPossessive(clientFlags.ClientDisplayName);
|
this.mainStore.issConfig.clientPossessiveName = toPossessive(clientFlags.ClientDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientFlags.ClientPossessiveName != null) {
|
if (clientFlags.ClientPossessiveName != null) {
|
||||||
this.mainStore.issConfig.clientPossessiveName = clientFlags.ClientPossessiveName;
|
this.mainStore.issConfig.clientPossessiveName = clientFlags.ClientPossessiveName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientFlags.ClaimRegistrationRequired) {
|
if (clientFlags.ClaimRegistrationRequired) {
|
||||||
this.mainStore.issConfig.isClaimRegistrationRequired = true;
|
this.mainStore.issConfig.isClaimRegistrationRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientFlags.EnableNoCompQuote) {
|
if (clientFlags.EnableNoCompQuote) {
|
||||||
this.mainStore.issConfig.enableNoCompQuote = true;
|
this.mainStore.issConfig.enableNoCompQuote = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
console.error(`Error parsing client flags: ${e}`);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
combineClientParameters(configParams, queryStringParams) {
|
combineClientParameters(configParams, queryStringParams) {
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,7 @@ export default {
|
||||||
this.navigateForward(partsOrQuestions, null);
|
this.navigateForward(partsOrQuestions, null);
|
||||||
},
|
},
|
||||||
requestCallbackBailout() {
|
requestCallbackBailout() {
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT, this.$route);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,7 @@ export default {
|
||||||
this.navigateForward(glassPartsForStore, null);
|
this.navigateForward(glassPartsForStore, null);
|
||||||
},
|
},
|
||||||
requestCallbackBailout() {
|
requestCallbackBailout() {
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT, this.$route);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -260,25 +260,16 @@ export default {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
useMainStore().savePaymentMethodChoice(this.paymentMethod);
|
useMainStore().savePaymentMethodChoice(this.paymentMethod);
|
||||||
if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) {
|
if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) {
|
||||||
try {
|
await submitWorkOrder({ submitType: submitType.SAFELITE });
|
||||||
await submitWorkOrder({ submitType: submitType.SAFELITE });
|
this.$router.navigate(
|
||||||
this.$router.navigate(
|
this.navigationScenarios.CLICKED_FORWARD,
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
this.$route
|
||||||
this.$route
|
);
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
useMainStore().setBailout(bailoutMessage.saveSessionError(error.data));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
this.$route,
|
|
||||||
{ issPage: issPageValues.PAYMENT_METHOD }
|
|
||||||
);
|
|
||||||
console.error(`error: response from submit work order:${error.message}`);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
await saveSession({
|
await saveSession({
|
||||||
createWorkOrderNumberForPIA: true,
|
createWorkOrderNumberForPIA: true,
|
||||||
shouldAwaitSaveSessionQueue: true
|
shouldAwaitSaveSessionQueue: true,
|
||||||
|
bailoutOnError: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,7 @@ export default {
|
||||||
},
|
},
|
||||||
async saveAndSubmitWorkOrder() {
|
async saveAndSubmitWorkOrder() {
|
||||||
// Final work order submit after returning from pay in advance.
|
// Final work order submit after returning from pay in advance.
|
||||||
try {
|
await submitWorkOrder({ submitType: submitType.SAFELITE });
|
||||||
await submitWorkOrder({ submitType: submitType.SAFELITE });
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`error: response from submit work order:${error.message}`);
|
|
||||||
this.navigateOnPayInAdvanceError();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS,
|
this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS,
|
||||||
|
|
|
||||||
|
|
@ -252,12 +252,12 @@ describe('policy-vehicles.vue', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'Error in lookupVehicleByVin call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario.',
|
'Error in lookupVehicleByVin call => error thrown in forwardButtonAction.',
|
||||||
async () => {
|
async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
const lookupReturnValue = { error: true, status: 500, data: 'error' };
|
const lookupReturnValue = { error: true, status: 500, data: 'error' };
|
||||||
wrapper.vm.lookupVehicleByVin = jest.fn().mockReturnValue(lookupReturnValue);
|
wrapper.vm.lookupVehicleByVin = jest.fn().mockReturnValue(Promise.reject(lookupReturnValue));
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
|
|
@ -270,21 +270,14 @@ describe('policy-vehicles.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.mainStore.applicationUser.pageData[issPageValues.BAILOUT_PAGE] = {
|
|
||||||
'bailout-page': {
|
|
||||||
bailoutCode: bailoutCode.VehicleVinLookupError
|
|
||||||
}
|
|
||||||
};
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.mainStore.setBailout).toHaveBeenCalledWith(bailoutMessage.vehicleVinLookupError(vin, lookupReturnValue.data));
|
expect.assertions(1);
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
try {
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
await wrapper.vm.forwardButtonAction();
|
||||||
undefined,
|
} catch (e) {
|
||||||
{},
|
expect(e).toBe(lookupReturnValue);
|
||||||
{}
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -292,7 +285,7 @@ describe('policy-vehicles.vue', () => {
|
||||||
async () => {
|
async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.lookupVehicleByVin = jest.fn().mockReturnValue({ error: true, status: 404 });
|
wrapper.vm.lookupVehicleByVin = jest.fn().mockRejectedValue({ isAxiosError: true, status: 404 });
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js';
|
||||||
import endorsementOptions from '@/constants/endorsement-options.js';
|
import endorsementOptions from '@/constants/endorsement-options.js';
|
||||||
import globalRules from '@/constants/global-rules.js';
|
import globalRules from '@/constants/global-rules.js';
|
||||||
import { useMainStore } from '@/store/index.js';
|
import { useMainStore } from '@/store/index.js';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
|
||||||
import {
|
import {
|
||||||
deductibleForSelectedVehicle,
|
deductibleForSelectedVehicle,
|
||||||
endorsementsForSelectedVehicle,
|
endorsementsForSelectedVehicle,
|
||||||
|
|
@ -144,10 +143,6 @@ export default {
|
||||||
},
|
},
|
||||||
repairWaivedForSelectedVehicle() {
|
repairWaivedForSelectedVehicle() {
|
||||||
return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle);
|
return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle);
|
||||||
},
|
|
||||||
selectedVehicle() {
|
|
||||||
const vehicle = this.mainStore.lookupVehicleByVin(this.selectedVehicleVin);
|
|
||||||
return vehicle;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -156,15 +151,12 @@ export default {
|
||||||
if (value === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
if (value === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
||||||
// clear previously selected vehicle and image
|
// clear previously selected vehicle and image
|
||||||
this.mainStore.resetVehicleState();
|
this.mainStore.resetVehicleState();
|
||||||
} else {
|
return;
|
||||||
// get vehicle details from selected VIN
|
}
|
||||||
const vehicle = await this.lookupVehicleByVin(value);
|
|
||||||
|
|
||||||
// handle error in case vehicle info doesn't come back for selected VIN
|
// get vehicle details from selected VIN
|
||||||
if (vehicle?.error === true) {
|
try {
|
||||||
this.mainStore.resetVehicleState();
|
const vehicle = await this.lookupVehicleByVin(value);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!vehicle?.data.canSafeliteService) {
|
if (!vehicle?.data.canSafeliteService) {
|
||||||
this.displayNoServiceAlert = true;
|
this.displayNoServiceAlert = true;
|
||||||
return;
|
return;
|
||||||
|
|
@ -177,6 +169,8 @@ export default {
|
||||||
vin: value
|
vin: value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.mainStore.resetVehicleState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -196,33 +190,16 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.selectedVehicleVin !== vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
if (this.selectedVehicleVin === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
||||||
|
useMainStore().updateCoverageType(coverageType.NONE);
|
||||||
|
useMainStore().updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
||||||
|
this.navigateForward();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vehicle = this.policyVehicles.find((pv) => pv.vin === this.selectedVehicleVin);
|
||||||
|
try {
|
||||||
const vehicleLookupResponse = await this.lookupVehicleByVin(this.selectedVehicleVin);
|
const vehicleLookupResponse = await this.lookupVehicleByVin(this.selectedVehicleVin);
|
||||||
const vehicle = this.policyVehicles.find((pv) => pv.vin === this.selectedVehicleVin);
|
|
||||||
|
|
||||||
if (vehicleLookupResponse.error) {
|
|
||||||
if (vehicleLookupResponse.status === 404) {
|
|
||||||
this.mainStore.resetVehicleState();
|
|
||||||
useMainStore().updateVehicle({
|
|
||||||
policyVehicleId: vehicle.id,
|
|
||||||
carId: '0',
|
|
||||||
category: '',
|
|
||||||
year: vehicle.vehicleYear || '',
|
|
||||||
make: vehicle.vehicleMake || '',
|
|
||||||
model: vehicle.vehicleModel || '',
|
|
||||||
style: vehicle.vehicleStyle || '',
|
|
||||||
vin: vehicle.vin
|
|
||||||
});
|
|
||||||
this.policyVinFound = false;
|
|
||||||
return this.navigateForward();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleVinLookupError(
|
|
||||||
vehicle.vin,
|
|
||||||
vehicleLookupResponse.data
|
|
||||||
));
|
|
||||||
return this.navigateForward();
|
|
||||||
}
|
|
||||||
|
|
||||||
useMainStore().updateVehicle({
|
useMainStore().updateVehicle({
|
||||||
...vehicleLookupResponse.data,
|
...vehicleLookupResponse.data,
|
||||||
|
|
@ -235,21 +212,30 @@ export default {
|
||||||
repairWaived: this.repairWaivedForSelectedVehicle,
|
repairWaived: this.repairWaivedForSelectedVehicle,
|
||||||
endorsements: this.endorsementsForSelectedVehicle
|
endorsements: this.endorsementsForSelectedVehicle
|
||||||
});
|
});
|
||||||
} else {
|
this.navigateForward();
|
||||||
useMainStore().updateCoverageType(coverageType.NONE);
|
} catch (e) {
|
||||||
useMainStore().updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
if (e.isAxiosError && e.status === 404) {
|
||||||
|
this.mainStore.resetVehicleState();
|
||||||
|
useMainStore().updateVehicle({
|
||||||
|
policyVehicleId: vehicle.id,
|
||||||
|
carId: '0',
|
||||||
|
category: '',
|
||||||
|
year: vehicle.vehicleYear || '',
|
||||||
|
make: vehicle.vehicleMake || '',
|
||||||
|
model: vehicle.vehicleModel || '',
|
||||||
|
style: vehicle.vehicleStyle || '',
|
||||||
|
vin: vehicle.vin
|
||||||
|
});
|
||||||
|
this.policyVinFound = false;
|
||||||
|
this.navigateForward();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
return this.navigateForward();
|
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
if (this.mainStore.isBailout) {
|
if (this.selectedVehicleVin === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
} else if (this.selectedVehicleVin === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
|
this.navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
|
||||||
this.$route,
|
this.$route,
|
||||||
|
|
@ -281,15 +267,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async lookupVehicleByVin(vin) {
|
async lookupVehicleByVin(vin) {
|
||||||
try {
|
return useMainStore().lookupVehicleByVin(vin);
|
||||||
return await useMainStore().lookupVehicleByVin(vin);
|
|
||||||
} catch (responseError) {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
status: responseError.status,
|
|
||||||
data: responseError.data
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async addAnotherVehicle() {
|
async addAnotherVehicle() {
|
||||||
this.selectedVehicleVin = vehicleSelectionOptions.VEHICLE_NOT_LISTED;
|
this.selectedVehicleVin = vehicleSelectionOptions.VEHICLE_NOT_LISTED;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
function setupMocks(mockApiResponses) {
|
function setupMocks(mockApiResponses) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn(),
|
||||||
|
navigateBailout: jest.fn()
|
||||||
},
|
},
|
||||||
route: 'provider-preference'
|
route: 'provider-preference'
|
||||||
});
|
});
|
||||||
|
|
@ -43,7 +44,7 @@ function setupMocks(mockApiResponses) {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('provider-preference.vue', () => {
|
describe('provider-preference.vue', () => {
|
||||||
test('Should navigate to tpa disabled route page when TPAOption selected and TPA Flow disabled', () => {
|
test('Should navigateBailout when TPAOption selected and TPA Flow disabled', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks();
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ describe('provider-preference.vue', () => {
|
||||||
wrapper.vm.findAnotherShopClicked();
|
wrapper.vm.findAnotherShopClicked();
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED, 'provider-preference');
|
expect(wrapper.vm.$router.navigateBailout).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Should navigate to safelite flow when navigateWithTPARecalAnswer is called with SafeliteOption', () => {
|
test('Should navigate to safelite flow when navigateWithTPARecalAnswer is called with SafeliteOption', () => {
|
||||||
|
|
|
||||||
|
|
@ -186,9 +186,7 @@ export default {
|
||||||
this.scheduleWithTPA();
|
this.scheduleWithTPA();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.mainStore.setBailout(bailoutMessage.TPANotEnabled());
|
this.$router.navigateBailout(bailoutMessage.TPANotEnabled());
|
||||||
const scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED;
|
|
||||||
this.navigateForward(scenario);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openStateSteeringModal() {
|
openStateSteeringModal() {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ const loaderStub = {
|
||||||
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn(),
|
||||||
|
navigateBailout: jest.fn()
|
||||||
},
|
},
|
||||||
route: {
|
route: {
|
||||||
query: { issPage: 'tpa-search' }
|
query: { issPage: 'tpa-search' }
|
||||||
|
|
@ -787,7 +788,7 @@ describe('tpa-search.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('needHelpLinkClick', () => {
|
describe('needHelpLinkClick', () => {
|
||||||
test('sets bailout and navigates', () => {
|
test('navigatesBailout', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent();
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
|
|
@ -795,11 +796,7 @@ describe('tpa-search.vue', () => {
|
||||||
wrapper.vm.needHelpLinkClick();
|
wrapper.vm.needHelpLinkClick();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.mainStore.setBailout).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigateBailout).toBeCalled();
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_NEED_HELP,
|
|
||||||
expect.anything()
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -360,11 +360,7 @@ export default {
|
||||||
return getTpaProvidersResult?.data ?? [];
|
return getTpaProvidersResult?.data ?? [];
|
||||||
},
|
},
|
||||||
needHelpLinkClick() {
|
needHelpLinkClick() {
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_NEED_HELP,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
async searchClick() {
|
async searchClick() {
|
||||||
if (isNaN(this.tpaSearchValue)) {
|
if (isNaN(this.tpaSearchValue)) {
|
||||||
|
|
|
||||||
|
|
@ -315,20 +315,8 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
try {
|
await submitWorkOrder({ submitType: submitType.TPA })
|
||||||
await submitWorkOrder({ submitType: submitType.TPA }).then(() => {
|
this.navigate(this.navigationScenarios.CLICKED_FORWARD);
|
||||||
this.navigate(this.navigationScenarios.CLICKED_FORWARD);
|
|
||||||
}).catch((submitError) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.saveSessionError(submitError.data));
|
|
||||||
this.navigate(
|
|
||||||
this.navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
this.$route,
|
|
||||||
{ issPage: this.issPageValues.TPA_SUBMIT }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`error: response from submit work order:${error.message}`);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
navigate(scenario) {
|
navigate(scenario) {
|
||||||
this.$router.navigate(scenario, this.$route);
|
this.$router.navigate(scenario, this.$route);
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ describe('vehicle-damage.vue', () => {
|
||||||
expect(vehicleQuestionsMixin.methods.getPartsOrQuestions).toHaveBeenCalledTimes(1);
|
expect(vehicleQuestionsMixin.methods.getPartsOrQuestions).toHaveBeenCalledTimes(1);
|
||||||
expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalledTimes(1);
|
expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
test('Error in getPartsOrQuestions call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario', async () => {
|
test('Error in getPartsOrQuestions call => error thrown in forwardButtonAction', async () => {
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
main: {
|
main: {
|
||||||
|
|
@ -154,23 +154,21 @@ describe('vehicle-damage.vue', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})];
|
})];
|
||||||
mountOptions.data = () => ({
|
mountOptions.data = () => ({});
|
||||||
hasBailedOut: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const wrapper = mount(VehicleDamageComponent, mountOptions);
|
const wrapper = mount(VehicleDamageComponent, mountOptions);
|
||||||
const siteFooterWrapper = wrapper.getComponent({ ref: 'siteFooter' });
|
|
||||||
const partsQuestionsErrorResponse = {
|
const partsQuestionsErrorResponse = {
|
||||||
error: 'Error getting parts'
|
error: 'Error getting parts'
|
||||||
};
|
};
|
||||||
vehicleQuestionsMixin.methods.getPartsOrQuestions.mockImplementation(() => (
|
vehicleQuestionsMixin.methods.getPartsOrQuestions.mockImplementation(() => (
|
||||||
partsQuestionsErrorResponse
|
Promise.reject(partsQuestionsErrorResponse)
|
||||||
));
|
));
|
||||||
siteFooterWrapper.vm.$emit('forwardClicked');
|
|
||||||
|
|
||||||
await flushPromises();
|
expect.assertions(1);
|
||||||
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
|
try {
|
||||||
expect(mockRouter.navigate)
|
await wrapper.vm.forwardButtonAction();
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, mockRoute);
|
} catch (e) {
|
||||||
|
expect(e).toBe(partsQuestionsErrorResponse);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,7 @@ export default {
|
||||||
this.getPassengerSideReplaceOptionsFromStore()
|
this.getPassengerSideReplaceOptionsFromStore()
|
||||||
},
|
},
|
||||||
selectedWindshieldOptions: this.getWindshieldOptionsFromStore(),
|
selectedWindshieldOptions: this.getWindshieldOptionsFromStore(),
|
||||||
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore()
|
||||||
hasBailedOut: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -429,23 +428,12 @@ export default {
|
||||||
// If vin already exists or not replacing windshield, get parts/questions and navigate forward
|
// If vin already exists or not replacing windshield, get parts/questions and navigate forward
|
||||||
|
|
||||||
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
||||||
if (partsOrQuestionsResponse.error) {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.PartsServiceError(partsOrQuestionsResponse.error.data));
|
|
||||||
window.console.error('Error on retrieving PartsOrQuestions');
|
|
||||||
this.hasBailedOut = true;
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comes from vehicleQuestionsMixin.navigateForward()
|
// Comes from vehicleQuestionsMixin.navigateForward()
|
||||||
if (!this.hasBailedOut) {
|
await this.navigateForward(
|
||||||
await this.navigateForward(
|
partsOrQuestionsResponse.data.partsOrQuestions,
|
||||||
partsOrQuestionsResponse.data.partsOrQuestions,
|
this
|
||||||
this
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
|
|
|
||||||
|
|
@ -113,21 +113,10 @@ export default {
|
||||||
break;
|
break;
|
||||||
case vinLookupMethodSelections.NOVIN:
|
case vinLookupMethodSelections.NOVIN:
|
||||||
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
||||||
if (partsOrQuestionsResponse.error) {
|
await this.navigateForward(
|
||||||
this.mainStore.setBailout(bailoutMessage.PartsServiceError(partsOrQuestionsResponse.error.data));
|
partsOrQuestionsResponse.data.partsOrQuestions,
|
||||||
window.console.error('Error on retrieving PartsOrQuestions');
|
this
|
||||||
this.hasBailedOut = true;
|
);
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await this.navigateForward(
|
|
||||||
partsOrQuestionsResponse.data.partsOrQuestions,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import widgetFields from '@/constants/cms-widget-fields';
|
import widgetFields from '@/constants/cms-widget-fields';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'vehicle-parts',
|
name: 'vehicle-parts',
|
||||||
|
|
@ -215,8 +214,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
requestCallbackBailout() {
|
requestCallbackBailout() {
|
||||||
this.mainStore.setBailout(bailoutMessage.RequestCallback());
|
this.$router.navigateBailout(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT, this.$route);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -163,16 +163,18 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectedStyle(value) {
|
selectedStyle(value) {
|
||||||
this.resetAlert();
|
if (value) {
|
||||||
this.mainStore.updateVehicleStyle(value);
|
this.resetAlert();
|
||||||
this.mainStore.setVehicle(
|
this.mainStore.updateVehicleStyle(value);
|
||||||
this.selectedYear,
|
this.mainStore.setVehicle(
|
||||||
this.selectedMake,
|
this.selectedYear,
|
||||||
this.selectedModel,
|
this.selectedMake,
|
||||||
this.selectedStyle
|
this.selectedModel,
|
||||||
).then((result) => {
|
this.selectedStyle
|
||||||
this.displayNoServiceAlert = !result.data.canSafeliteService;
|
).then((result) => {
|
||||||
});
|
this.displayNoServiceAlert = !result.data.canSafeliteService;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
@ -206,77 +208,25 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
this.mainStore.setVehicle().then(
|
this.mainStore.setVehicle().then(() => {
|
||||||
() => {
|
|
||||||
if (this.mainStore.isBailout) {
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
this.navigationScenarios.CLICKED_FORWARD,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, this.mainStore.vehicle.make, this.mainStore.vehicle.model, this.mainStore.vehicle.style, error));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async updateYearValues() {
|
async updateYearValues() {
|
||||||
return this.mainStore.getVehicleYears().then(
|
return this.mainStore.getVehicleYears();
|
||||||
(response) => response,
|
|
||||||
(error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(null, null, null, null, error));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
async updateMakeValues() {
|
async updateMakeValues() {
|
||||||
return this.mainStore.getVehicleMakes().then(
|
return this.mainStore.getVehicleMakes();
|
||||||
(response) => response,
|
|
||||||
(error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, null, null, null, error));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
async updateModelValues() {
|
async updateModelValues() {
|
||||||
return this.mainStore.getVehicleModels().then(
|
return this.mainStore.getVehicleModels();
|
||||||
(response) => response,
|
|
||||||
(error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, this.mainStore.vehicle.make, null, null, error));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
async updateStyleValues() {
|
async updateStyleValues() {
|
||||||
return this.mainStore.getVehicleStyles().then(
|
return this.mainStore.getVehicleStyles();
|
||||||
(response) => response,
|
|
||||||
(error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, this.mainStore.vehicle.make, this.mainStore.vehicle.model, null, error));
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
resetAlert() {
|
resetAlert() {
|
||||||
this.displayNoServiceAlert = false;
|
this.displayNoServiceAlert = false;
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,8 @@ const mockRoute = {
|
||||||
};
|
};
|
||||||
const mockRouter = {
|
const mockRouter = {
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
navigateWithSpinner: jest.fn()
|
navigateWithSpinner: jest.fn(),
|
||||||
|
navigateBailout: jest.fn()
|
||||||
};
|
};
|
||||||
const maska = jest.fn();
|
const maska = jest.fn();
|
||||||
jest.mock('@/helpers/damage-helper', () => ({
|
jest.mock('@/helpers/damage-helper', () => ({
|
||||||
|
|
@ -553,45 +554,6 @@ describe('vin-lookup.vue', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test(
|
|
||||||
'Error in getPartsOrQuestions call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario',
|
|
||||||
async () => {
|
|
||||||
const user = userEvent.setup();
|
|
||||||
mountOptions.global.stubs.vinQuestion = false;
|
|
||||||
|
|
||||||
mountOptions.data = () => ({
|
|
||||||
vinWithNonMatchingCarId: false,
|
|
||||||
isCarIdDifferentFromTheStore: false,
|
|
||||||
vin: mockValidVin,
|
|
||||||
hasBailedOut: true
|
|
||||||
});
|
|
||||||
|
|
||||||
getPartsOrQuestions.mockResponse = partsOrQuestionsErrorMockResponse;
|
|
||||||
|
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
|
||||||
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
|
||||||
|
|
||||||
const { container } = render(VinLookupComponent, mountOptions);
|
|
||||||
|
|
||||||
const vinInput = container.querySelector(vinInputSelector);
|
|
||||||
await user.type(vinInput, mockValidVin);
|
|
||||||
|
|
||||||
const continueButton = container.querySelector(continueButtonQuerySelector);
|
|
||||||
await user.click(continueButton);
|
|
||||||
|
|
||||||
await flushPromises();
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
|
|
||||||
expect(mockRouter.navigate)
|
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
mockRoute
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,7 @@ export default {
|
||||||
vinWithNonMatchingCarId: vin?.length > 0 && !this.hasValidCarId(),
|
vinWithNonMatchingCarId: vin?.length > 0 && !this.hasValidCarId(),
|
||||||
vin,
|
vin,
|
||||||
forwardButtonCarStyle: '',
|
forwardButtonCarStyle: '',
|
||||||
vinPopulatedOnPageLoad: vin?.length > 0 && this.hasValidCarId(),
|
vinPopulatedOnPageLoad: vin?.length > 0 && this.hasValidCarId()
|
||||||
hasBailedOut: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -176,35 +175,37 @@ export default {
|
||||||
showIssLoadingModal(true);
|
showIssLoadingModal(true);
|
||||||
|
|
||||||
if (this.needToLookupVehicle) {
|
if (this.needToLookupVehicle) {
|
||||||
const vehicleLookupResponse = await this.lookupVehicleByVin(this.vin);
|
try {
|
||||||
|
const vehicleLookupResponse = await this.lookupVehicleByVin(this.vin);
|
||||||
|
|
||||||
if (vehicleLookupResponse.error) {
|
if (!vehicleLookupResponse.data.canSafeliteService) {
|
||||||
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
|
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NO_SERVICE;
|
||||||
this.mainStore.setBailout(bailoutMessage.vehicleNotFound(this.vin));
|
this.resetVehicleFromLookup();
|
||||||
this.resetVehicleFromLookup();
|
this.$refs.siteFooter.disableForwardButton();
|
||||||
// Temp solution to turn on 'disabled' style on the Continue button
|
showIssLoadingModal(false);
|
||||||
// because the form itself actually passes its client-side validation.
|
return;
|
||||||
// SSR-189 Scenario #4.
|
|
||||||
this.$refs.siteFooter.enableForwardAction();
|
|
||||||
showIssLoadingModal(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vehicleLookupResponse.data.canSafeliteService) {
|
|
||||||
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NO_SERVICE;
|
|
||||||
this.resetVehicleFromLookup();
|
|
||||||
this.$refs.siteFooter.disableForwardButton();
|
|
||||||
showIssLoadingModal(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add vin bcs the response from the service doesn't contain vin
|
|
||||||
this.vehicleFromLookup = Object.assign(
|
|
||||||
vehicleLookupResponse.data,
|
|
||||||
{
|
|
||||||
vin: this.vin
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
// Add vin bcs the response from the service doesn't contain vin
|
||||||
|
this.vehicleFromLookup = Object.assign(
|
||||||
|
vehicleLookupResponse.data,
|
||||||
|
{
|
||||||
|
vin: this.vin
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.status === 404) {
|
||||||
|
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
|
||||||
|
this.resetVehicleFromLookup();
|
||||||
|
// Temp solution to turn on 'disabled' style on the Continue button
|
||||||
|
// because the form itself actually passes its client-side validation.
|
||||||
|
// SSR-189 Scenario #4.
|
||||||
|
this.$refs.siteFooter.enableForwardAction();
|
||||||
|
showIssLoadingModal(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.needToLookupVehicle && this.isCarIdDifferentFromTheStore) {
|
if (this.needToLookupVehicle && this.isCarIdDifferentFromTheStore) {
|
||||||
|
|
@ -259,34 +260,15 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
||||||
if (partsOrQuestionsResponse.error) {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.PartsServiceError(partsOrQuestionsResponse.error.data));
|
|
||||||
window.console.error('Error on retrieving PartsOrQuestions');
|
|
||||||
this.hasBailedOut = true;
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comes from vehicleQuestionsMixin.navigateForward()
|
// Comes from vehicleQuestionsMixin.navigateForward()
|
||||||
if (!this.hasBailedOut) {
|
await this.navigateForward(
|
||||||
await this.navigateForward(
|
partsOrQuestionsResponse.data.partsOrQuestions,
|
||||||
partsOrQuestionsResponse.data.partsOrQuestions,
|
this
|
||||||
this
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async lookupVehicleByVin(vin) {
|
async lookupVehicleByVin(vin) {
|
||||||
try {
|
return this.mainStore.lookupVehicleByVin(vin);
|
||||||
return await this.mainStore.lookupVehicleByVin(vin);
|
|
||||||
} catch (responseError) {
|
|
||||||
return {
|
|
||||||
error: {
|
|
||||||
status: responseError.status
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
resetActiveAlert() {
|
resetActiveAlert() {
|
||||||
this.activeVehicleLookupAlertType = null;
|
this.activeVehicleLookupAlertType = null;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ function setupMocks({
|
||||||
const mockDataMountOptions = {
|
const mockDataMountOptions = {
|
||||||
...mountOptionsMockData,
|
...mountOptionsMockData,
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn(),
|
||||||
|
navigateBailout: jest.fn()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -166,7 +167,7 @@ describe('navigation', () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.mainStore.getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
wrapper.vm.mainStore.getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
wrapper.vm.mainStore.applicationUser.duplicateOrders = [{ test: 'a' }];
|
wrapper.vm.mainStore.applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.reject());
|
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.reject({ isAxiosError: false }));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -316,10 +317,14 @@ describe('navigation', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
expect.assertions(1);
|
||||||
|
try {
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
} catch (e) {
|
||||||
|
expect(e).toMatch(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ import { getPropertyCaseInsensitive } from '@/helpers/object-helper';
|
||||||
import { saveSession } from '@/helpers/order-helper';
|
import { saveSession } from '@/helpers/order-helper';
|
||||||
import { getISSCookie } from '@/helpers/cookie-helper.js';
|
import { getISSCookie } from '@/helpers/cookie-helper.js';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
|
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||||
|
|
||||||
// define validation rules
|
// define validation rules
|
||||||
defineRule(
|
defineRule(
|
||||||
|
|
@ -303,54 +304,46 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
try {
|
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
|
||||||
const promises = [];
|
|
||||||
promises.push(this.configureZip().then(async () => await this.mainStore.getBillToInfo()));
|
|
||||||
|
|
||||||
// Clear duplicate orders if navigating away from the welcome page after visiting duplicate check page.
|
// We want to await this separately. It's quick and if this has an invalid zip we don't want to be waiting on the slower API calls
|
||||||
if (this.mainStore.order.visitedDuplicateCheckPage) {
|
await this.configureZip();
|
||||||
this.mainStore.clearDuplicateOrders();
|
if (this.displayInvalidZipAlert) {
|
||||||
}
|
showIssLoadingModal(false);
|
||||||
|
return;
|
||||||
// Skip duplicate check if loaded from cookie or already visited duplicate check page.
|
|
||||||
if (!this.mainStore.order.loadedFromCookie && !this.mainStore.order.visitedDuplicateCheckPage) {
|
|
||||||
promises.push(this.mainStore.getDuplicateReferrals());
|
|
||||||
}
|
|
||||||
promises.push(this.mainStore.getCoveragePolicyInfo());
|
|
||||||
await Promise.allSettled(promises);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
// TODO: Bailout?
|
|
||||||
} finally {
|
|
||||||
if (!this.displayInvalidZipAlert) {
|
|
||||||
await saveSession({ shouldAwaitSaveSessionQueue: true })
|
|
||||||
.catch((error) => {
|
|
||||||
this.mainStore.setBailout(bailoutMessage.saveSessionError(error.data));
|
|
||||||
})
|
|
||||||
.finally(() => this.navigateForward());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear duplicate orders if navigating away from the welcome page after visiting duplicate check page.
|
||||||
|
if (this.mainStore.order.visitedDuplicateCheckPage) {
|
||||||
|
this.mainStore.clearDuplicateOrders();
|
||||||
|
}
|
||||||
|
|
||||||
|
const promises = [
|
||||||
|
// Suppress error from API call we can try again later in the flow
|
||||||
|
this.mainStore.getBillToInfo()
|
||||||
|
];
|
||||||
|
// Skip duplicate check if loaded from cookie or already visited duplicate check page.
|
||||||
|
if (!this.mainStore.order.loadedFromCookie && !this.mainStore.order.visitedDuplicateCheckPage) {
|
||||||
|
promises.push(this.mainStore.getDuplicateReferrals());
|
||||||
|
}
|
||||||
|
promises.push(this.mainStore.getCoveragePolicyInfo());
|
||||||
|
await Promise.all(promises);
|
||||||
|
await saveSession({ shouldAwaitSaveSessionQueue: true, bailoutOnError: true })
|
||||||
|
this.navigateForward();
|
||||||
},
|
},
|
||||||
async configureZip() {
|
async configureZip() {
|
||||||
try {
|
try {
|
||||||
this.displayInvalidZipAlert = false;
|
this.displayInvalidZipAlert = false;
|
||||||
await this.mainStore.validateZip({ zip: this.welcomePageModel.policyZipCode });
|
await this.mainStore.validateZip({ zip: this.welcomePageModel.policyZipCode });
|
||||||
return Promise.resolve();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (e.isAxiosError) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
this.displayInvalidZipAlert = true;
|
this.displayInvalidZipAlert = true;
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
if (this.mainStore.isBailout) {
|
if ((this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false)
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
|
||||||
);
|
|
||||||
} else if ((this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false)
|
|
||||||
&& !this.answeredContinueModal) {
|
&& !this.answeredContinueModal) {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
||||||
|
|
@ -445,12 +438,7 @@ export default {
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.answeredContinueModal = true;
|
this.answeredContinueModal = true;
|
||||||
if (response && !response.provider?.isSafeliteProvider) {
|
if (response && !response.provider?.isSafeliteProvider) {
|
||||||
this.mainStore.setBailout(bailoutMessage.SafeliteNotTheProvider());
|
this.$router.navigateBailout(bailoutMessage.SafeliteNotTheProvider());
|
||||||
this.hasBailedOut = true;
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this.updateWelcomePageModel(response);
|
this.updateWelcomePageModel(response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ function getPageName(vm) {
|
||||||
// Vue Error Handling
|
// Vue Error Handling
|
||||||
vueApp.config.errorHandler = (err, vm, info) => {
|
vueApp.config.errorHandler = (err, vm, info) => {
|
||||||
const pageName = getPageName(vm);
|
const pageName = getPageName(vm);
|
||||||
global.$logger.logError(`Page Name - ${pageName} - ${info}: ${err.message}\n${err.stack}`);
|
global.$logger.logError(`[${pageName}] ${info}`, err);
|
||||||
if (applicationConfig.BAILOUT_ON_APPLICATION_ERROR) {
|
if (applicationConfig.BAILOUT_ON_APPLICATION_ERROR) {
|
||||||
router.navigateBailout(bailoutMessage.applicationError(`[${pageName}] ${info}: ${err.message}\n${err.stack}`));
|
router.navigateBailout(bailoutMessage.applicationError(`[${pageName}] ${info}: ${err.message}\n${err.stack}`));
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ vueApp.config.errorHandler = (err, vm, info) => {
|
||||||
|
|
||||||
// Vue Router Error Handling
|
// Vue Router Error Handling
|
||||||
router.onError((err) => {
|
router.onError((err) => {
|
||||||
global.$logger.logError(err.message, err.cause);
|
global.$logger.logError('Router Error:', err);
|
||||||
if (applicationConfig.BAILOUT_ON_ROUTER_ERROR) {
|
if (applicationConfig.BAILOUT_ON_ROUTER_ERROR) {
|
||||||
router.navigateBailout(bailoutMessage.routerError(`${err.message}\n${err.stack}`));
|
router.navigateBailout(bailoutMessage.routerError(`${err.message}\n${err.stack}`));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -353,16 +353,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async getPartsOrQuestions() {
|
async getPartsOrQuestions() {
|
||||||
try {
|
return useMainStore().getPartsOrQuestions();
|
||||||
return await useMainStore().getPartsOrQuestions();
|
|
||||||
} catch (responseError) {
|
|
||||||
return {
|
|
||||||
error: {
|
|
||||||
status: responseError.status,
|
|
||||||
data: responseError.data
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Can't use `this` because navigateForward is also called from vin-pages-mixin
|
// Can't use `this` because navigateForward is also called from vin-pages-mixin
|
||||||
|
|
|
||||||
|
|
@ -25,100 +25,95 @@ const routes = [
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'root',
|
name: 'root',
|
||||||
async beforeEnter(to, from, next) {
|
async beforeEnter(to, from, next) {
|
||||||
try {
|
const issPageToUse = !to.query.issPage ? issPageValues.WELCOME_PAGE : to.query.issPage;
|
||||||
const issPageToUse = !to.query.issPage ? issPageValues.WELCOME_PAGE : to.query.issPage;
|
const fromQueryPage = from.query?.issPage;
|
||||||
const fromQueryPage = from.query?.issPage;
|
|
||||||
|
|
||||||
if ((issPageToUse === issPageValues.ACCESS_DENIED
|
if ((issPageToUse === issPageValues.ACCESS_DENIED
|
||||||
|| (issPageToUse !== issPageValues.ENTRY_PAGE && !useMainStore().issConfig.parentAccountNumber))
|
|| (issPageToUse !== issPageValues.ENTRY_PAGE && !useMainStore().issConfig.parentAccountNumber))
|
||||||
&& process.env.VUE_APP_CURRENT_ENVIRONMENT !== 'Localhost'
|
&& process.env.VUE_APP_CURRENT_ENVIRONMENT !== 'Localhost'
|
||||||
) {
|
) {
|
||||||
return await GoToAccessIsDenied(next);
|
return await GoToAccessIsDenied(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not run these for the main entry page - as it is not part of the user flow.
|
||||||
|
if (issPageToUse !== issPageValues.ENTRY_PAGE) {
|
||||||
|
if (analyticsMixin.methods.noSession()) {
|
||||||
|
await analyticsMixin.methods.initSession();
|
||||||
|
} else {
|
||||||
|
updateSessionIdCookie();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not run these for the main entry page - as it is not part of the user flow.
|
await runExperiments(issPageToUse); // fmg has this further down
|
||||||
if (issPageToUse !== issPageValues.ENTRY_PAGE) {
|
}
|
||||||
if (analyticsMixin.methods.noSession()) {
|
|
||||||
await analyticsMixin.methods.initSession();
|
|
||||||
} else {
|
|
||||||
updateSessionIdCookie();
|
|
||||||
}
|
|
||||||
|
|
||||||
await runExperiments(issPageToUse); // fmg has this further down
|
// Intercept all navigation if a submitted order exists in storage
|
||||||
|
if (useMainStore().hasSubmittedOrder()) {
|
||||||
|
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
||||||
|
return await GoToConfirmationPage(next, useMainStore().getSubmittedOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the saved session has timed out, clear the session, execute 404 logic.
|
||||||
|
if (getISSCookie() !== null && !isSavedSessionStillActive()) {
|
||||||
|
// await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
||||||
|
await GoToStartOn404(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process ISS cookie.
|
||||||
|
// Skip if Entry Page or Refreshing Welcome page
|
||||||
|
if (issPageToUse !== issPageValues.ENTRY_PAGE
|
||||||
|
&& !(issPageToUse === issPageValues.WELCOME_PAGE && fromQueryPage === undefined)) {
|
||||||
|
updateOrCreateISSCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (router.hasRoute(issPageToUse)) {
|
||||||
|
// Since our route is already in scope, we can grab the component and call the arePagePrerequisitesValid function.
|
||||||
|
let component = router.getRoutes().filter((x) => x.name === issPageToUse)[0].components;
|
||||||
|
|
||||||
|
// If the component hasn't been loaded fully, load it before we check prerequisites.
|
||||||
|
if (component.default.methods === undefined) {
|
||||||
|
component = await component.default();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intercept all navigation if a submitted order exists in storage
|
if (!arePagePrerequisitesValid(component)) {
|
||||||
if (useMainStore().hasSubmittedOrder()) {
|
|
||||||
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
|
||||||
return await GoToConfirmationPage(next, useMainStore().getSubmittedOrder());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the saved session has timed out, clear the session, execute 404 logic.
|
|
||||||
if (getISSCookie() !== null && !isSavedSessionStillActive()) {
|
|
||||||
// await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
|
||||||
await GoToStartOn404(next);
|
await GoToStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process ISS cookie.
|
return next({name: issPageToUse, query: to.query, params: to.params});
|
||||||
// Skip if Entry Page or Refreshing Welcome page
|
|
||||||
if (issPageToUse !== issPageValues.ENTRY_PAGE
|
|
||||||
&& !(issPageToUse === issPageValues.WELCOME_PAGE && fromQueryPage === undefined)) {
|
|
||||||
updateOrCreateISSCookie();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (router.hasRoute(issPageToUse)) {
|
|
||||||
// Since our route is already in scope, we can grab the component and call the arePagePrerequisitesValid function.
|
|
||||||
let component = router.getRoutes().filter((x) => x.name === issPageToUse)[0].components;
|
|
||||||
|
|
||||||
// If the component hasn't been loaded fully, load it before we check prerequisites.
|
|
||||||
if (component.default.methods === undefined) {
|
|
||||||
component = await component.default();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arePagePrerequisitesValid(component)) {
|
|
||||||
await GoToStartOn404(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
return next({ name: issPageToUse, query: to.query, params: to.params });
|
|
||||||
}
|
|
||||||
|
|
||||||
const routeData = await GetRouteInfoFromPageName(issPageToUse);
|
|
||||||
|
|
||||||
if (routeData[0].name.toLowerCase() === 'error') {
|
|
||||||
throw new Error('Page not found!');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add our dynamic route.
|
|
||||||
router.addRoute({
|
|
||||||
path: routeData[0].path, // Always the same path, because we control it with query strings.
|
|
||||||
name: routeData[0].name,
|
|
||||||
component: routeData[0].component
|
|
||||||
});
|
|
||||||
|
|
||||||
// Call the next components arePagePrerequisitesValid method before load.
|
|
||||||
// If it returns false, use the 404 logic.
|
|
||||||
const nextComponent = await router
|
|
||||||
.getRoutes()
|
|
||||||
.filter((x) => x.name === routeData[0].name)[0]
|
|
||||||
.components.default();
|
|
||||||
|
|
||||||
if (!arePagePrerequisitesValid(nextComponent)) {
|
|
||||||
const tempMsgCopy = 'Pre Requisites failed, need to handle. Default is Welcome Page.';
|
|
||||||
const tempMsgHeadline = `${issPageToUse}: pre-req failed...`;
|
|
||||||
await GoToStartOn404(next, tempMsgCopy, tempMsgHeadline);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign current query string parameters, as well as our issPage one.
|
|
||||||
next({
|
|
||||||
name: routeData[0].name,
|
|
||||||
query: Object.assign(to.query, { issPage: routeData[0].name }),
|
|
||||||
params: to.params
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
window.console.warn(error);
|
|
||||||
await GoToStartOn404(next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const routeData = await GetRouteInfoFromPageName(issPageToUse);
|
||||||
|
|
||||||
|
if (routeData[0].name.toLowerCase() === 'error') {
|
||||||
|
throw new Error('Page not found!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add our dynamic route.
|
||||||
|
router.addRoute({
|
||||||
|
path: routeData[0].path, // Always the same path, because we control it with query strings.
|
||||||
|
name: routeData[0].name,
|
||||||
|
component: routeData[0].component
|
||||||
|
});
|
||||||
|
|
||||||
|
// Call the next components arePagePrerequisitesValid method before load.
|
||||||
|
// If it returns false, use the 404 logic.
|
||||||
|
const nextComponent = await router
|
||||||
|
.getRoutes()
|
||||||
|
.filter((x) => x.name === routeData[0].name)[0]
|
||||||
|
.components.default();
|
||||||
|
|
||||||
|
if (!arePagePrerequisitesValid(nextComponent)) {
|
||||||
|
const tempMsgCopy = 'Pre Requisites failed, need to handle. Default is Welcome Page.';
|
||||||
|
const tempMsgHeadline = `${issPageToUse}: pre-req failed...`;
|
||||||
|
await GoToStartOn404(next, tempMsgCopy, tempMsgHeadline);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign current query string parameters, as well as our issPage one.
|
||||||
|
next({
|
||||||
|
name: routeData[0].name,
|
||||||
|
query: Object.assign(to.query, {issPage: routeData[0].name}),
|
||||||
|
params: to.params
|
||||||
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +172,7 @@ router.afterEach(async (to, from) => {
|
||||||
|
|
||||||
const skipSaveSession = !!router.options.history.state[routerParams.SKIP_SAVE_SESSION];
|
const skipSaveSession = !!router.options.history.state[routerParams.SKIP_SAVE_SESSION];
|
||||||
if (from.name !== undefined && !skipSaveSession && !store.hasSubmittedOrder()) {
|
if (from.name !== undefined && !skipSaveSession && !store.hasSubmittedOrder()) {
|
||||||
await saveSession({});
|
await saveSession({ bailoutOnError: from.name === issPageValues.ENTRY_PAGE});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
||||||
|
|
@ -350,17 +345,12 @@ router.navigateBailout = (bailoutData = null) => {
|
||||||
// Get navigation map depending on the scenario and the current 'page' you're on.
|
// Get navigation map depending on the scenario and the current 'page' you're on.
|
||||||
function getNavigationMap(scenario, currentRoute) {
|
function getNavigationMap(scenario, currentRoute) {
|
||||||
const issPageValue = currentRoute.query.issPage;
|
const issPageValue = currentRoute.query.issPage;
|
||||||
try {
|
const matchedQueryValue = routingTable(useMainStore())
|
||||||
const matchedQueryValue = routingTable(useMainStore())
|
.filter((item) => item.issPageValue === issPageValue && item.maps.filter((map) => map.scenario === scenario).length > 0);
|
||||||
.filter((item) => item.issPageValue === issPageValue && item.maps.filter((map) => map.scenario === scenario).length > 0);
|
|
||||||
|
|
||||||
const maps = matchedQueryValue ? matchedQueryValue.map((m) => m.maps.filter((map) => map.scenario === scenario))[0] : undefined;
|
const maps = matchedQueryValue ? matchedQueryValue.map((m) => m.maps.filter((map) => map.scenario === scenario))[0] : undefined;
|
||||||
|
|
||||||
return maps ? maps.filter((x) => x.filter === true || x.filter === undefined)[0] : undefined;
|
return maps ? maps.filter((x) => x.filter === true || x.filter === undefined)[0] : undefined;
|
||||||
} catch (e) {
|
|
||||||
window.console.error(e);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GoToAccessIsDenied(next) {
|
async function GoToAccessIsDenied(next) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ const navigationScenarios = Object.freeze({
|
||||||
CLICKED_FORWARD_POLICY_UNVERIFIED: 'CLICKED_FORWARD_POLICY_UNVERIFIED',
|
CLICKED_FORWARD_POLICY_UNVERIFIED: 'CLICKED_FORWARD_POLICY_UNVERIFIED',
|
||||||
CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES: 'CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES',
|
CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES: 'CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES',
|
||||||
CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES: 'CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES',
|
CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES: 'CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES',
|
||||||
SAVE_SESSION_FAILED: 'SAVE_SESSION_FAILED',
|
|
||||||
|
|
||||||
// Duplicate Check
|
// Duplicate Check
|
||||||
CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE: 'CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE',
|
CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE: 'CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE',
|
||||||
|
|
@ -70,11 +69,8 @@ const navigationScenarios = Object.freeze({
|
||||||
|
|
||||||
// Coverage Statement
|
// Coverage Statement
|
||||||
CLICKED_BACK_WITH_REPAIR: 'CLICKED_BACK_WITH_REPAIR',
|
CLICKED_BACK_WITH_REPAIR: 'CLICKED_BACK_WITH_REPAIR',
|
||||||
CLICKED_FORWARD_WITH_INVALID_STATE: 'CLICKED_FORWARD_WITH_INVALID_STATE',
|
|
||||||
PRICING_LOOKUP_ERROR: 'PRICING_LOOKUP_ERROR',
|
|
||||||
|
|
||||||
// TPA Search
|
// TPA Search
|
||||||
CLICKED_NEED_HELP: 'CLICKED_NEED_HELP',
|
|
||||||
CLICKED_FORWARD_WITH_SAFELITE_SHOP: 'CLICKED_FORWARD_WITH_SAFELITE_SHOP',
|
CLICKED_FORWARD_WITH_SAFELITE_SHOP: 'CLICKED_FORWARD_WITH_SAFELITE_SHOP',
|
||||||
CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP: 'CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP',
|
CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP: 'CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP',
|
||||||
|
|
||||||
|
|
@ -88,7 +84,6 @@ const navigationScenarios = Object.freeze({
|
||||||
// Provider Preference
|
// Provider Preference
|
||||||
CLICKED_FORWARD_WITH_SAFELITE: 'CLICKED_FORWARD_WITH_SAFELITE',
|
CLICKED_FORWARD_WITH_SAFELITE: 'CLICKED_FORWARD_WITH_SAFELITE',
|
||||||
CLICKED_FORWARD_WITH_TPA_ENABLED: 'CLICKED_FORWARD_WITH_TPA_ENABLED',
|
CLICKED_FORWARD_WITH_TPA_ENABLED: 'CLICKED_FORWARD_WITH_TPA_ENABLED',
|
||||||
CLICKED_FORWARD_WITH_TPA_DISABLED: 'CLICKED_FORWARD_WITH_TPA_DISABLED',
|
|
||||||
CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES: 'CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES',
|
CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES: 'CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES',
|
||||||
|
|
||||||
// Service Package
|
// Service Package
|
||||||
|
|
@ -112,8 +107,6 @@ const navigationScenarios = Object.freeze({
|
||||||
PAY_IN_ADVANCE_SUCCESS: 'PAY_IN_ADVANCE_SUCCESS',
|
PAY_IN_ADVANCE_SUCCESS: 'PAY_IN_ADVANCE_SUCCESS',
|
||||||
|
|
||||||
// Bailout
|
// Bailout
|
||||||
CLICKED_FORWARD_WITH_BAILOUT: 'CLICKED_FORWARD_WITH_BAILOUT',
|
|
||||||
CLICKED_NEED_HELP_WITH_BAILOUT: 'CLICKED_NEED_HELP_WITH_BAILOUT',
|
|
||||||
BAILOUT: 'BAILOUT'
|
BAILOUT: 'BAILOUT'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||||
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -55,10 +51,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -141,14 +133,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: issPageValues.VEHICLE_LOOKUP,
|
scenario: issPageValues.VEHICLE_LOOKUP,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: issPageValues.BAILOUT_PAGE, // TODO is this a bug
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -215,10 +199,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -256,10 +236,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -293,10 +269,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -455,14 +427,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
|
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
|
||||||
destinationIssPageValue: issPageValues.POLICY_VEHICLES
|
destinationIssPageValue: issPageValues.POLICY_VEHICLES
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -539,10 +503,6 @@ const routingTable = () => [
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAR_ID_NOT_FOUND,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAR_ID_NOT_FOUND,
|
||||||
destinationIssPageValue: issPageValues.VIN_LOOKUP
|
destinationIssPageValue: issPageValues.VIN_LOOKUP
|
||||||
},
|
},
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
||||||
destinationIssPageValue: issPageValues.POLICY_ENDORSEMENTS
|
destinationIssPageValue: issPageValues.POLICY_ENDORSEMENTS
|
||||||
|
|
@ -591,18 +551,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||||
destinationIssPageValue: issPageValues.SCHEDULE_PAGE
|
destinationIssPageValue: issPageValues.SCHEDULE_PAGE
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.PRICING_LOOKUP_ERROR,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -620,10 +568,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
|
||||||
destinationIssPageValue: issPageValues.TPA_SEARCH
|
destinationIssPageValue: issPageValues.TPA_SEARCH
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -692,10 +636,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_PAY_NOW,
|
scenario: navigationScenarios.CLICKED_PAY_NOW,
|
||||||
destinationIssPageValue: issPageValues.PAYMENT_PAGE
|
destinationIssPageValue: issPageValues.PAYMENT_PAGE
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -768,10 +708,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||||
destinationIssPageValue: issPageValues.TPA_CONFIRMATION
|
destinationIssPageValue: issPageValues.TPA_CONFIRMATION
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.SAVE_SESSION_FAILED,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -798,10 +734,6 @@ const routingTable = () => [
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
||||||
destinationIssPageValue: issPageValues.TPA_SUBMIT
|
destinationIssPageValue: issPageValues.TPA_SUBMIT
|
||||||
},
|
|
||||||
{
|
|
||||||
scenario: navigationScenarios.CLICKED_NEED_HELP,
|
|
||||||
destinationIssPageValue: issPageValues.BAILOUT_PAGE
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import { createPinia } from 'pinia';
|
import { createPinia } from 'pinia';
|
||||||
import App from '@/App.vue';
|
import App from '@/App.vue';
|
||||||
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
describe('Router', () => {
|
describe('Router', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
|
@ -37,18 +39,15 @@ describe('Router', () => {
|
||||||
expect(router.push.mock.calls[0][0].state).toBe(parameters);
|
expect(router.push.mock.calls[0][0].state).toBe(parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should route from CAPABILITY_QUESTIONS to BAILOUT_PAGE on CLICKED_NEED_HELP_WITH_BAILOUT', () => {
|
it('Should set bailout and navigate to bailout page when calling navigateBailout', () => {
|
||||||
const scenario = navigationScenarios.CLICKED_NEED_HELP_WITH_BAILOUT;
|
// Arrange
|
||||||
const currentRoute = { query: { issPage: issPageValues.CAPABILITY_QUESTIONS } };
|
|
||||||
|
|
||||||
router.push = jest.fn();
|
router.push = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
router.navigate(scenario, currentRoute);
|
router.navigateBailout(bailoutMessage.unknown({}));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(router.push).toHaveBeenCalled();
|
|
||||||
|
|
||||||
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.BAILOUT_PAGE);
|
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.BAILOUT_PAGE);
|
||||||
|
expect(useMainStore().isBailout).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import applicationConfig from '@/constants/application-config';
|
import applicationConfig from '@/constants/application-config';
|
||||||
import bailoutCode from '@/constants/bailoutCode';
|
import bailoutCode from '@/constants/bailoutCode';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
|
||||||
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 damageLocationsSelected from '@/constants/damage-locations-selected';
|
import damageLocationsSelected from '@/constants/damage-locations-selected';
|
||||||
|
|
@ -22,14 +21,11 @@ import {
|
||||||
noCoverageForSelectedVehicle,
|
noCoverageForSelectedVehicle,
|
||||||
repairWaivedForSelectedVehicle
|
repairWaivedForSelectedVehicle
|
||||||
} from '@/helpers/policy-vehicle-helper';
|
} from '@/helpers/policy-vehicle-helper';
|
||||||
import {
|
import { buildURLSearchParams, getPartNumbersListForQueryString } from '@/helpers/querystring-helper';
|
||||||
buildURLSearchParams,
|
|
||||||
getPartNumbersListForQueryString,
|
|
||||||
getTaxLineItemQueryString
|
|
||||||
} from '@/helpers/querystring-helper';
|
|
||||||
import { getTopLevelGlassPartsWithRecal } from '@/helpers/recal-helper';
|
import { getTopLevelGlassPartsWithRecal } from '@/helpers/recal-helper';
|
||||||
import { getDateForSavedSessionTimeout } from '@/helpers/session-helper';
|
import { getDateForSavedSessionTimeout } from '@/helpers/session-helper';
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
|
import CoverageStatuses from '@/constants/coverage-statuses';
|
||||||
|
|
||||||
const storeId = 'main';
|
const storeId = 'main';
|
||||||
|
|
||||||
|
|
@ -533,20 +529,15 @@ export const useMainStore = defineStore({
|
||||||
payload: {}
|
payload: {}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getIsVinbyAddressPermissible() {
|
async getIsVinbyAddressPermissible() {
|
||||||
try {
|
try {
|
||||||
const response = globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.IsVinbyAddressPermissible.method,
|
method: endpoints.IsVinbyAddressPermissible.method,
|
||||||
endpoint: `${endpoints.IsVinbyAddressPermissible.url}?state=${this.order.customer.address.state}`,
|
endpoint: `${endpoints.IsVinbyAddressPermissible.url}?state=${this.order.customer.address.state}`,
|
||||||
payload: {}
|
payload: {}
|
||||||
});
|
});
|
||||||
return response;
|
} catch (e) {
|
||||||
} catch (responseError) {
|
return false;
|
||||||
return {
|
|
||||||
error: {
|
|
||||||
status: responseError.status
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getCoveragePolicyInfo() {
|
async getCoveragePolicyInfo() {
|
||||||
|
|
@ -555,7 +546,7 @@ export const useMainStore = defineStore({
|
||||||
|
|
||||||
if (!issConfig.isCoverageEnabled || applicationUser.coverageLookupAttempts > 10) {
|
if (!issConfig.isCoverageEnabled || applicationUser.coverageLookupAttempts > 10) {
|
||||||
this.updateCoverageType(coverageType.NONE);
|
this.updateCoverageType(coverageType.NONE);
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.applicationUser.coverageAttempts += 1;
|
this.applicationUser.coverageAttempts += 1;
|
||||||
|
|
@ -571,7 +562,8 @@ export const useMainStore = defineStore({
|
||||||
dateOfLoss: policy.dateOfLoss,
|
dateOfLoss: policy.dateOfLoss,
|
||||||
zipCode: policy.policyZipCode,
|
zipCode: policy.policyZipCode,
|
||||||
referralCorrelationId: order.referralCorrelationId
|
referralCorrelationId: order.referralCorrelationId
|
||||||
}
|
},
|
||||||
|
bailoutOnError: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const responsePolicy = response?.data?.policies?.[0];
|
const responsePolicy = response?.data?.policies?.[0];
|
||||||
|
|
@ -600,10 +592,8 @@ export const useMainStore = defineStore({
|
||||||
} else {
|
} else {
|
||||||
this.updateCoverageType(coverageType.NONE);
|
this.updateCoverageType(coverageType.NONE);
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.updateCoverageType(coverageType.NONE);
|
this.updateCoverageType(coverageType.NONE);
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearDuplicateOrders() {
|
clearDuplicateOrders() {
|
||||||
|
|
@ -621,82 +611,81 @@ export const useMainStore = defineStore({
|
||||||
updateIsItacOptimized(isItacOptimized) {
|
updateIsItacOptimized(isItacOptimized) {
|
||||||
this.order.insuranceCoverage.isItacOptimized = isItacOptimized || false;
|
this.order.insuranceCoverage.isItacOptimized = isItacOptimized || false;
|
||||||
},
|
},
|
||||||
registerClaim() {
|
async registerClaim() {
|
||||||
const nonNumberCharRegex = /[^0-9]/g;
|
const nonNumberCharRegex = /[^0-9]/g;
|
||||||
const { order, isITAC } = this;
|
const { isITAC } = this;
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
globalMethods.callHttpClient({
|
try {
|
||||||
|
const response = await globalMethods.callHttpClient({
|
||||||
method: endpoints.RegisterClaim.method,
|
method: endpoints.RegisterClaim.method,
|
||||||
endpoint: endpoints.RegisterClaim.url,
|
endpoint: endpoints.RegisterClaim.url,
|
||||||
payload:
|
payload:
|
||||||
{
|
{
|
||||||
referralCorrelationId: this.order.referralCorrelationId,
|
referralCorrelationId: this.order.referralCorrelationId,
|
||||||
accountNumber: this.order.parentAccountNumber?.toString() ?? '',
|
accountNumber: this.order.parentAccountNumber?.toString() ?? '',
|
||||||
policyData: this.order.policy.policyData,
|
policyData: this.order.policy.policyData,
|
||||||
isItac: isITAC,
|
isItac: isITAC,
|
||||||
insured: {
|
insured: {
|
||||||
firstName: this.order.customer.firstName,
|
firstName: this.order.customer.firstName,
|
||||||
lastName: this.order.customer.lastName,
|
lastName: this.order.customer.lastName,
|
||||||
address: {
|
address: {
|
||||||
addressLine1: this.order.customer.address.streetAddress,
|
addressLine1: this.order.customer.address.streetAddress,
|
||||||
addressLine2: this.order.customer.address.streetAddress2,
|
addressLine2: this.order.customer.address.streetAddress2,
|
||||||
city: this.order.customer.address.city,
|
city: this.order.customer.address.city,
|
||||||
state: this.order.customer.address.state,
|
state: this.order.customer.address.state,
|
||||||
zipCode: this.order.customer.address.zipCode,
|
zipCode: this.order.customer.address.zipCode,
|
||||||
country: 'US' // TODO set from store
|
country: 'US' // TODO set from store
|
||||||
|
},
|
||||||
|
homePhone: {
|
||||||
|
number: this.contactInfo.homePhone?.replaceAll(nonNumberCharRegex, '') ?? ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
homePhone: {
|
driver: {
|
||||||
number: this.contactInfo.homePhone?.replaceAll(nonNumberCharRegex, '') ?? ''
|
firstName: this.order.customer.firstName,
|
||||||
|
lastName: this.order.customer.lastName
|
||||||
|
},
|
||||||
|
caller: {
|
||||||
|
homePhone: {}
|
||||||
|
},
|
||||||
|
policyInfo: {
|
||||||
|
policyNumber: this.order.policy.policyNumber,
|
||||||
|
safelitePolicy: {
|
||||||
|
policies: []
|
||||||
|
},
|
||||||
|
actualDeductible: this.currentDeductible.toString() ?? ''
|
||||||
|
},
|
||||||
|
lossInfo: {
|
||||||
|
dateOfLoss: this.order.policy.dateOfLoss,
|
||||||
|
location: {
|
||||||
|
city: this.order.policy.damageCity,
|
||||||
|
state: this.order.policy.damageState,
|
||||||
|
country: 'US' // TODO set from store
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
id: this.order.vehicle.policyVehicleId?.toString() ?? '',
|
||||||
|
year: this.order.vehicle.year?.toString() ?? '',
|
||||||
|
make: this.order.vehicle.make,
|
||||||
|
model: this.order.vehicle.model,
|
||||||
|
vin: this.order.vehicle.vin
|
||||||
|
},
|
||||||
|
cause: this.order.policy.damageCause,
|
||||||
|
damageDescription: this.order.policy.damageCause
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
driver: {
|
bailoutOnError: false
|
||||||
firstName: this.order.customer.firstName,
|
|
||||||
lastName: this.order.customer.lastName
|
|
||||||
},
|
|
||||||
caller: {
|
|
||||||
homePhone: {}
|
|
||||||
},
|
|
||||||
policyInfo: {
|
|
||||||
policyNumber: this.order.policy.policyNumber,
|
|
||||||
safelitePolicy: {
|
|
||||||
policies: []
|
|
||||||
},
|
|
||||||
actualDeductible: this.currentDeductible.toString() ?? ''
|
|
||||||
},
|
|
||||||
lossInfo: {
|
|
||||||
dateOfLoss: this.order.policy.dateOfLoss,
|
|
||||||
location: {
|
|
||||||
city: this.order.policy.damageCity,
|
|
||||||
state: this.order.policy.damageState,
|
|
||||||
country: 'US' // TODO set from store
|
|
||||||
},
|
|
||||||
vehicle: {
|
|
||||||
id: this.order.vehicle.policyVehicleId?.toString() ?? '',
|
|
||||||
year: this.order.vehicle.year?.toString() ?? '',
|
|
||||||
make: this.order.vehicle.make,
|
|
||||||
model: this.order.vehicle.model,
|
|
||||||
vin: this.order.vehicle.vin
|
|
||||||
},
|
|
||||||
cause: this.order.policy.damageCause,
|
|
||||||
damageDescription: this.order.policy.damageCause
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).then((response) => {
|
|
||||||
this.order.insuranceCoverage.claimNumber = response.data.claimNumber;
|
|
||||||
if (response.data.isSuccess) {
|
|
||||||
this.updateCoverageStatus(coverageStatuses.VERIFIED);
|
|
||||||
} else {
|
|
||||||
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
|
||||||
}
|
|
||||||
return resolve(response);
|
|
||||||
}, (error) => {
|
|
||||||
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
|
||||||
this.order.insuranceCoverage.claimNumber = null;
|
|
||||||
return reject(error);
|
|
||||||
});
|
});
|
||||||
});
|
this.order.insuranceCoverage.claimNumber = response.data.claimNumber;
|
||||||
|
if (response.data.isSuccess) {
|
||||||
|
this.updateCoverageStatus(coverageStatuses.VERIFIED);
|
||||||
|
} else {
|
||||||
|
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
||||||
|
this.order.insuranceCoverage.claimNumber = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getFinalDeductible() {
|
async getFinalDeductible() {
|
||||||
const endorsementAnswersForPayload = [];
|
const endorsementAnswersForPayload = [];
|
||||||
const endorsementAnswers = this.order.policy.endorsementQuestionAnswers;
|
const endorsementAnswers = this.order.policy.endorsementQuestionAnswers;
|
||||||
if (endorsementAnswers) {
|
if (endorsementAnswers) {
|
||||||
|
|
@ -712,9 +701,9 @@ export const useMainStore = defineStore({
|
||||||
glassInformation?.forEach((glassPiece) => {
|
glassInformation?.forEach((glassPiece) => {
|
||||||
manualGlassNamesArray.push(glassPiece?.glassLocation?.toUpperCase());
|
manualGlassNamesArray.push(glassPiece?.glassLocation?.toUpperCase());
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
globalMethods.callHttpClient({
|
const r = await globalMethods.callHttpClient({
|
||||||
method: endpoints.FinalDeductible.method,
|
method: endpoints.FinalDeductible.method,
|
||||||
endpoint: endpoints.FinalDeductible.url,
|
endpoint: endpoints.FinalDeductible.url,
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -736,16 +725,18 @@ export const useMainStore = defineStore({
|
||||||
vehicleVin: this.order.vehicle.vin,
|
vehicleVin: this.order.vehicle.vin,
|
||||||
policyData: this.order.policy.policyData,
|
policyData: this.order.policy.policyData,
|
||||||
isItac: this.isITAC
|
isItac: this.isITAC
|
||||||
}
|
},
|
||||||
}).then((r) => {
|
bailoutOnError: false
|
||||||
this.order.policy.policyData = r.data.policyData;
|
});
|
||||||
this.updateDeductible(r.data);
|
this.order.policy.policyData = r.data.policyData;
|
||||||
return resolve(r);
|
this.updateDeductible(r.data);
|
||||||
}).catch((error) => reject(error));
|
return r;
|
||||||
});
|
} catch (e) {
|
||||||
|
this.updateCoverageStatus(CoverageStatuses.PENDING);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getDuplicateReferrals() {
|
async getDuplicateReferrals() {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
parentAccountNumber: this.order.parentAccountNumber,
|
parentAccountNumber: this.order.parentAccountNumber,
|
||||||
customerPhoneNumber: this.order.contactInfo.servicePhone,
|
customerPhoneNumber: this.order.contactInfo.servicePhone,
|
||||||
|
|
@ -754,18 +745,16 @@ export const useMainStore = defineStore({
|
||||||
dateOfLoss: this.order.policy.dateOfLoss
|
dateOfLoss: this.order.policy.dateOfLoss
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
globalMethods.callHttpClient({
|
const duplicates = await globalMethods.callHttpClient({
|
||||||
method: endpoints.DuplicateSearch.method,
|
method: endpoints.DuplicateSearch.method,
|
||||||
endpoint: `${endpoints.DuplicateSearch.url}?${params.toString()}`
|
endpoint: `${endpoints.DuplicateSearch.url}?${params.toString()}`,
|
||||||
}).then((r) => {
|
bailoutOnError: false
|
||||||
this.applicationUser.duplicateOrders = r.data ?? [];
|
|
||||||
return resolve(r.data);
|
|
||||||
}).catch((error) => {
|
|
||||||
this.applicationUser.duplicateOrders = [];
|
|
||||||
return reject(error);
|
|
||||||
});
|
});
|
||||||
});
|
this.applicationUser.duplicateOrders = duplicates.data ?? [];
|
||||||
|
} catch (e) {
|
||||||
|
this.applicationUser.duplicateOrders = [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async lookupVinByPlate(licensePlate, licenseState) {
|
async lookupVinByPlate(licensePlate, licenseState) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1219,9 +1208,6 @@ export const useMainStore = defineStore({
|
||||||
IsOEMRequest: this.hasOemEndorsement
|
IsOEMRequest: this.hasOemEndorsement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
throw error;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { lineItems, serverData, isItac, primaryBillToNumber, partsWerePriced, isItacOptimized } = response.data;
|
const { lineItems, serverData, isItac, primaryBillToNumber, partsWerePriced, isItacOptimized } = response.data;
|
||||||
|
|
@ -1361,7 +1347,8 @@ export const useMainStore = defineStore({
|
||||||
endpoint: endpoints.LookupVehicleByVin.url,
|
endpoint: endpoints.LookupVehicleByVin.url,
|
||||||
payload: {
|
payload: {
|
||||||
vin
|
vin
|
||||||
}
|
},
|
||||||
|
bailoutOnError: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1393,7 +1380,7 @@ export const useMainStore = defineStore({
|
||||||
this.applicationUser.crmCustomerId = response.crmCustomerId.toString();
|
this.applicationUser.crmCustomerId = response.crmCustomerId.toString();
|
||||||
},
|
},
|
||||||
|
|
||||||
saveSession({ submitAfterSave, createWorkOrderNumberForPIA }) {
|
saveSession({ submitAfterSave, createWorkOrderNumberForPIA, bailoutOnError }) {
|
||||||
const { vehicle, damage, policy, customer, contactInfo, payment,
|
const { vehicle, damage, policy, customer, contactInfo, payment,
|
||||||
lineItems, serviceLocation, schedule, insuranceCoverage } = this.order;
|
lineItems, serviceLocation, schedule, insuranceCoverage } = this.order;
|
||||||
|
|
||||||
|
|
@ -1545,7 +1532,7 @@ export const useMainStore = defineStore({
|
||||||
method: endpoints.SaveSession.method,
|
method: endpoints.SaveSession.method,
|
||||||
endpoint: endpoints.SaveSession.url,
|
endpoint: endpoints.SaveSession.url,
|
||||||
payload,
|
payload,
|
||||||
bailoutOnError: false
|
bailoutOnError
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (loadedFromDupeCheck) {
|
if (loadedFromDupeCheck) {
|
||||||
this.order.loadedSessionClearedPreviousData = true;
|
this.order.loadedSessionClearedPreviousData = true;
|
||||||
|
|
@ -2462,6 +2449,7 @@ export const useMainStore = defineStore({
|
||||||
populateInitialState(forceReset) {
|
populateInitialState(forceReset) {
|
||||||
if (!sessionStorage.getItem(storeId) || forceReset) {
|
if (!sessionStorage.getItem(storeId) || forceReset) {
|
||||||
this.$state = getDefaultState();
|
this.$state = getDefaultState();
|
||||||
|
this.resetSubmittedOrder();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -2700,34 +2688,26 @@ export const useMainStore = defineStore({
|
||||||
|
|
||||||
async getBillToInfo(componentProviderNumber = null) {
|
async getBillToInfo(componentProviderNumber = null) {
|
||||||
const { order, issConfig } = this;
|
const { order, issConfig } = this;
|
||||||
try {
|
const params = new URLSearchParams({
|
||||||
const params = new URLSearchParams({
|
parentAccountNumber: order.parentAccountNumber.toString(),
|
||||||
parentAccountNumber: order.parentAccountNumber.toString(),
|
providerNumber: componentProviderNumber || this.providerNumber,
|
||||||
providerNumber: componentProviderNumber || this.providerNumber,
|
typeOfClaim: 'GLASS ONLY',
|
||||||
typeOfClaim: 'GLASS ONLY',
|
lineOfBusiness: 'PERSONAL',
|
||||||
lineOfBusiness: 'PERSONAL',
|
isItac: this.isITAC
|
||||||
isItac: this.isITAC
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
method: endpoints.GetBillToInfo.method,
|
method: endpoints.GetBillToInfo.method,
|
||||||
endpoint: `${endpoints.GetBillToInfo.url}?${params.toString()}`
|
endpoint: `${endpoints.GetBillToInfo.url}?${params.toString()}`,
|
||||||
});
|
bailoutOnError: false
|
||||||
|
});
|
||||||
|
|
||||||
const billToInfo = response.data;
|
const billToInfo = response.data;
|
||||||
if (billToInfo != null) {
|
issConfig.billToAccountNumber = billToInfo.toString();
|
||||||
issConfig.billToAccountNumber = billToInfo.toString();
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.reject(new Error('Invalid billToInfo'));
|
|
||||||
} catch (e) {
|
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async validateClientTag(clientTag) {
|
async validateClientTag(clientTag) {
|
||||||
return await globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.ValidateClientTag.method,
|
method: endpoints.ValidateClientTag.method,
|
||||||
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`
|
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -459,9 +459,9 @@ describe('Store', () => {
|
||||||
expect(store.order.insuranceCoverage.claimNumber).not.toBeNull();
|
expect(store.order.insuranceCoverage.claimNumber).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Call to client returns exception, resulting in object with error property being returned', async () => {
|
it('Call to client returns exception, and no error is returned from registerClaim method', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
expect.assertions(4);
|
expect.assertions(3);
|
||||||
const error = 'register claim error';
|
const error = 'register claim error';
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
store.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||||
|
|
@ -1494,8 +1494,8 @@ describe('Store', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('api call throws exception => insuranceCoverage.coverageType is NONE', async () => {
|
it('api call throws exception => no error is thrown from getCoveragePolicyInfo and insuranceCoverage.coverageType is NONE', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(2);
|
||||||
const error = 'get coverage policy info error';
|
const error = 'get coverage policy info error';
|
||||||
store.issConfig.isCoverageEnabled = true;
|
store.issConfig.isCoverageEnabled = true;
|
||||||
store.applicationUser.coverageLookupAttempts = 0;
|
store.applicationUser.coverageLookupAttempts = 0;
|
||||||
|
|
@ -1567,9 +1567,9 @@ describe('Store', () => {
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||||
expect(store.applicationUser.duplicateOrders).toEqual(expected);
|
expect(store.applicationUser.duplicateOrders).toEqual(expected);
|
||||||
});
|
});
|
||||||
it('Call to client returns exception => object with error property returned and duplicateReferrals set to []', async () => {
|
it('Call to client returns exception => object with error property returned and duplicateReferrals set to [] and no error is returned from getDuplicateReferrals', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
expect.assertions(3);
|
expect.assertions(2);
|
||||||
const error = 'get duplicate referrals error';
|
const error = 'get duplicate referrals error';
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||||
|
|
||||||
|
|
@ -1807,7 +1807,8 @@ describe('Store', () => {
|
||||||
vehicleVin,
|
vehicleVin,
|
||||||
policyData,
|
policyData,
|
||||||
isItac: store.isITAC
|
isItac: store.isITAC
|
||||||
})
|
}),
|
||||||
|
bailoutOnError: false
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
it('only "Yes" endorsement answers are added to payload', () => {
|
it('only "Yes" endorsement answers are added to payload', () => {
|
||||||
|
|
@ -1912,14 +1913,15 @@ describe('Store', () => {
|
||||||
vehicleVin,
|
vehicleVin,
|
||||||
policyData,
|
policyData,
|
||||||
isItac: store.isITAC
|
isItac: store.isITAC
|
||||||
})
|
}),
|
||||||
|
bailoutOnError: false
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('unsuccessful api call', () => {
|
describe('unsuccessful api call', () => {
|
||||||
it('api call throws exception', async () => {
|
it('api call throws exception. no error from getFinalDeductible', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
expect.assertions(2);
|
expect.assertions(1);
|
||||||
const error = 'final deductible error';
|
const error = 'final deductible error';
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||||
|
|
||||||
|
|
@ -2078,8 +2080,8 @@ describe('Store', () => {
|
||||||
expect(result.data.shopProviders[1]).toBe(provider2);
|
expect(result.data.shopProviders[1]).toBe(provider2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('api call throws exception => coverageType none', async () => {
|
it('api call throws exception => coverageType none and no error from getCoveragePolicyInfo', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(2);
|
||||||
const error = 'get coverage policy info error';
|
const error = 'get coverage policy info error';
|
||||||
|
|
||||||
store.issConfig.isCoverageEnabled = true;
|
store.issConfig.isCoverageEnabled = true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue