Merge pull request #576 from Safelite/feature/digital/SSR-600
SSR-600 Cannot continue existing claim
This commit is contained in:
commit
899919e809
4 changed files with 61 additions and 49 deletions
|
|
@ -136,7 +136,8 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: expectedSubtext
|
||||
SubText: expectedSubtext,
|
||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||
});
|
||||
});
|
||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||
|
|
@ -173,7 +174,8 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: expectedSubtext
|
||||
SubText: expectedSubtext,
|
||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||
});
|
||||
});
|
||||
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
||||
|
|
@ -210,7 +212,8 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: expectedSubtext
|
||||
SubText: expectedSubtext,
|
||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||
});
|
||||
});
|
||||
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
||||
|
|
@ -248,7 +251,8 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: `${expectedVehicle}, ${expectedDate}`
|
||||
SubText: `${expectedVehicle}, ${expectedDate}`,
|
||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -352,7 +356,7 @@ describe('duplicateCheck.vue', () => {
|
|||
test('Selected duplicate => load session called', async () => {
|
||||
// Arrange
|
||||
const newOrderSelectionName = getRandomString(6, 6);
|
||||
const selectedAnswer = getRandomString(6, 6);
|
||||
const selectedAnswer = {};
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
|
|
@ -405,7 +409,7 @@ describe('duplicateCheck.vue', () => {
|
|||
test('Load session throws error => still navigate forward', async () => {
|
||||
// Arrange
|
||||
const newOrderSelectionName = getRandomString(6, 6);
|
||||
const selectedAnswer = getRandomString(6, 6);
|
||||
const selectedAnswer = {};
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
selectedAnswer: '',
|
||||
selectedAnswer: null,
|
||||
widget: {
|
||||
siteHeader: 'SiteHeaderWidget',
|
||||
siteSubHeader: 'SiteSubHeaderWidget',
|
||||
|
|
@ -113,7 +113,8 @@ export default {
|
|||
return {
|
||||
Text: duplicateOrderText,
|
||||
Name: o.referralNumber,
|
||||
SubText: toTitleCase(subtext)
|
||||
SubText: toTitleCase(subtext),
|
||||
value: o
|
||||
};
|
||||
}) ?? [];
|
||||
},
|
||||
|
|
@ -126,13 +127,16 @@ 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 {
|
||||
this.navigateForward();
|
||||
if (this.selectedAnswer !== null && typeof this.selectedAnswer === 'object') {
|
||||
await useMainStore().loadSession(this.selectedAnswer)
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
this.navigateForward();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.navigateForward();
|
||||
},
|
||||
navigateForward() {
|
||||
if (!this.mainStore.order.policy.policyLookupSuccessful) {
|
||||
|
|
|
|||
|
|
@ -1285,20 +1285,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.responseDate,
|
||||
parentAccountNumber: issConfig.parentAccountNumber,
|
||||
referralCorrelationId: order.referralCorrelationId
|
||||
referralCorrelationId: duplicate.referralCorrelationId
|
||||
}
|
||||
});
|
||||
const { data } = response;
|
||||
|
|
@ -1307,10 +1304,6 @@ 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;
|
||||
order.customer.firstName = data.customer?.firstName;
|
||||
|
|
|
|||
|
|
@ -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,34 +1021,31 @@ 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);
|
||||
});
|
||||
it('sets expected application user data', async () => {
|
||||
// Arrange
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
||||
|
||||
// Act
|
||||
await store.loadSession();
|
||||
|
||||
// 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 +1059,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 +1084,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 +1099,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 +1106,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);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue