SSR-600 Cannot continue existing claim

This commit is contained in:
Josh Dassinger 2024-03-05 09:46:36 -06:00
parent bc7947187a
commit d839c21244
3 changed files with 53 additions and 29 deletions

View file

@ -126,13 +126,17 @@ export default {
* @summary Steps to perform when forward button clicked.
*/
async forwardButtonAction() {
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
await useMainStore().loadSession()
.then(() => {}, () => {})
.finally(() => { this.navigateForward(); });
} else {
if (this.selectedAnswer === this.getNewOrderSelectionName) {
this.navigateForward();
return;
}
const duplicate = useMainStore().applicationUser.duplicateOrders.find((d) => d.referralNumber === this.selectedAnswer);
await useMainStore().loadSession(duplicate)
.catch(() => {})
.finally(() => {
this.navigateForward();
});
},
navigateForward() {
if (!this.mainStore.order.policy.policyLookupSuccessful) {

View file

@ -1210,20 +1210,17 @@ export const useMainStore = defineStore({
});
},
async loadSession() {
async loadSession(duplicate) {
const { applicationUser, order, issConfig } = this;
// TODO how to get savedSessionId for a duplicate referral?
try {
const response = await globalMethods.callHttpClient({
method: endpoints.LoadSession.method,
endpoint: endpoints.LoadSession.url,
payload: {
savedSessionId: applicationUser.savedSessionId?.toString(),
referralNumber: order.referralNumber?.toString(),
referralDate: order.referralDate?.toString(),
referralNumber: duplicate.referralNumber,
referralDate: duplicate.referralDate,
parentAccountNumber: issConfig.parentAccountNumber,
referralCorrelationId: order.referralCorrelationId
referralCorrelationId: duplicate.referralCorrelationId
}
});
const { data } = response;
@ -1232,9 +1229,7 @@ export const useMainStore = defineStore({
return response;
}
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
applicationUser.experiments = data.applicationUser?.experiments ?? [];
applicationUser.savedSessionId = data.applicationUser?.savedSessionId;
if (order.policy.policyLookupSuccessful) {
order.customer.emailAddress = data.customer?.emailAddress;

View file

@ -961,10 +961,7 @@ describe('Store', () => {
describe('loadSession method', () => {
describe('successful method call', () => {
const applicationUser = {
crmCustomerId: getRandomString(6, 6),
experiments: getRandomString(6, 6),
pageData: getRandomString(6, 6),
savedSessionId: getRandomString(6, 6)
experiments: getRandomString(6, 6)
};
const vehicle = {
year: getRandomString(6, 6),
@ -1006,9 +1003,13 @@ describe('Store', () => {
it('calls load session api endpoint', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({ data: {} }));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
// Act
store.loadSession();
store.loadSession(duplicate);
// Asserts
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
@ -1020,9 +1021,13 @@ describe('Store', () => {
// Arrange
const response = { data: { ReferralNumber: getRandomString(6, 6) } };
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
// Act
const result = store.loadSession();
const result = store.loadSession(duplicate);
// Asserts
await expect(result).resolves.toBe(response.data);
@ -1030,24 +1035,31 @@ describe('Store', () => {
it('sets expected application user data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
// Act
await store.loadSession();
await store.loadSession(duplicate);
// Asserts
expect(store.applicationUser.experiments).toEqual(applicationUser.experiments);
expect(store.applicationUser.savedSessionId).toBe(applicationUser.savedSessionId);
expect(store.applicationUser.crmCustomerId).toBe(applicationUser.crmCustomerId);
});
it('sets expected vehicle data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
store.order.policy.policyLookupSuccessful = true;
store.policy.vehicles = [{ vin: vehicle.vin }];
// Act
await store.loadSession();
await store.loadSession(duplicate);
// Asserts
expect(store.vehicle.year).toBe(vehicle.year);
@ -1061,11 +1073,16 @@ describe('Store', () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
store.order.policy.policyLookupSuccessful = true;
store.policy.vehicles = [{ vin: vehicle.vin }];
// Act
await store.loadSession();
await store.loadSession(duplicate);
// Asserts
expect(store.order.customer.address.streetAddress).toBe(customer.address.streetAddress);
@ -1081,10 +1098,14 @@ describe('Store', () => {
it('sets expected remaining order data', async () => {
// Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
const originalWorkOrderNumber = store.order.workOrderNumber;
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
// Act
await store.loadSession();
await store.loadSession(duplicate);
// Asserts
expect(store.order.referralNumber).toBe(fullApiResponse.data.referralNumber);
@ -1092,7 +1113,6 @@ describe('Store', () => {
expect(store.order.referralCorrelationId).toBe(fullApiResponse.data.referralCorrelationId);
expect(store.order.referralSequenceNumber).toBe(fullApiResponse.data.referralSequenceNumber);
expect(store.order.eon).toBe(fullApiResponse.data.eon);
expect(store.order.workOrderNumber).toBe(originalWorkOrderNumber);
});
});
it('api call throws exception', async () => {
@ -1100,8 +1120,13 @@ describe('Store', () => {
const error = 'load session error';
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
const duplicate = {
referralNumber: getRandomString(6, 6),
referralCorrelationId: getRandomGuid()
};
// Act
await store.loadSession().catch((e) => {
await store.loadSession(duplicate).catch((e) => {
expect(e).toEqual(error);
});