Wiring up duplicate search
This commit is contained in:
parent
f616433fe3
commit
b06057576c
6 changed files with 79 additions and 29 deletions
|
|
@ -145,6 +145,11 @@ const endpoints = Object.freeze({
|
||||||
SaveSession: {
|
SaveSession: {
|
||||||
url: '/order/api/v1/order/save-session/iss',
|
url: '/order/api/v1/order/save-session/iss',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
},
|
||||||
|
DuplicateSearch: {
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
url: (accountNumber, policyNumber, phoneNumber) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${phoneNumber}`,
|
||||||
|
method: 'GET'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: getRandomString(5, 5),
|
vehicleMake: getRandomString(5, 5),
|
||||||
vehicleModel: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
dateOfLoss: date,
|
dateOfLoss: date,
|
||||||
referralNumber: referralNumber
|
referralNumber
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,6 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: date
|
SubText: date
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,10 @@ export default {
|
||||||
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||||
: null;
|
: null;
|
||||||
const subtext = vehicle
|
|
||||||
|
const subtext = vehicle && o.dateOfLoss
|
||||||
? `${vehicle}, ${o.dateOfLoss}`
|
? `${vehicle}, ${o.dateOfLoss}`
|
||||||
: o.dateOfLoss;
|
: (vehicle ?? '').concat(o.dateOfLoss ?? '');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
|
|
|
||||||
|
|
@ -298,8 +298,9 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
|
console.log("FORWARD MARCH!");
|
||||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||||
const duplicateCheckResponse = useMainStore().getDuplicateReferrals();
|
const duplicateCheckResponse = await useMainStore().getDuplicateReferrals();
|
||||||
const duplicatePromiseResultMap = [
|
const duplicatePromiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: 'duplicateCheckResponse',
|
resultKey: 'duplicateCheckResponse',
|
||||||
|
|
@ -310,6 +311,7 @@ export default {
|
||||||
|
|
||||||
this.mainStore.applicationUser.duplicateOrders = duplicateResultMap.duplicateCheckResponse ?? [];
|
this.mainStore.applicationUser.duplicateOrders = duplicateResultMap.duplicateCheckResponse ?? [];
|
||||||
this.duplicates = duplicateResultMap.duplicateCheckResponse;
|
this.duplicates = duplicateResultMap.duplicateCheckResponse;
|
||||||
|
console.log(`duplicates: ${this.duplicates}`);
|
||||||
|
|
||||||
// call coverage policy lookup if isCoverageEnabled flag enabled
|
// call coverage policy lookup if isCoverageEnabled flag enabled
|
||||||
if (this.isCoverageEnabled) {
|
if (this.isCoverageEnabled) {
|
||||||
|
|
|
||||||
|
|
@ -469,27 +469,24 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// TODO when endpoint finished replace dummy data with api call
|
|
||||||
getDuplicateReferrals() {
|
getDuplicateReferrals() {
|
||||||
const apiInputs = [
|
return new Promise((resolve, reject) => {
|
||||||
this.issConfig.accountNumber,
|
globalMethods.callHttpClient({
|
||||||
this.order.policy.policyNumber,
|
method: endpoints.DuplicateSearch.method,
|
||||||
this.order.policy.dateOfLoss
|
endpoint: endpoints.DuplicateSearch.url(
|
||||||
];
|
this.issConfig.accountNumber,
|
||||||
|
this.order.policy.policyNumber,
|
||||||
return [
|
this.order.customer.phoneNumber?.replaceAll('-', '')
|
||||||
{
|
)
|
||||||
referralNumber: '12345',
|
}).then((r) => {
|
||||||
vehicleYear: '2013',
|
console.log(r);
|
||||||
vehicleMake: 'Honda',
|
this.applicationUser.duplicateOrders = r.data ?? [];
|
||||||
vehicleModel: 'Civic',
|
return resolve(r.data);
|
||||||
dateOfLoss: '09/23/2023'
|
}).catch((error) => {
|
||||||
},
|
this.applicationUser.duplicateOrders = [];
|
||||||
{
|
return reject(error);
|
||||||
referralNumber: '34210',
|
});
|
||||||
dateOfLoss: '08/01/2022'
|
});
|
||||||
}
|
|
||||||
];
|
|
||||||
},
|
},
|
||||||
async lookupVinByPlate(licensePlate, licenseState) {
|
async lookupVinByPlate(licensePlate, licenseState) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -977,4 +977,50 @@ describe('Store', () => {
|
||||||
expect(store.order.policy.endorsementQuestionAnswers).toEqual(endorsementQuestionAnswersArray);
|
expect(store.order.policy.endorsementQuestionAnswers).toEqual(endorsementQuestionAnswersArray);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('duplicateSearch method', () => {
|
||||||
|
it('successful response => duplicateReferrals set to expected', async () => {
|
||||||
|
// Arrange
|
||||||
|
const expected = [
|
||||||
|
{
|
||||||
|
accountNumber: getRandomString(6, 6),
|
||||||
|
claimNumber: getRandomString(9, 9)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accountNumber: getRandomString(6, 6),
|
||||||
|
claimNumber: getRandomString(9, 9)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accountNumber: getRandomString(6, 6),
|
||||||
|
claimNumber: getRandomString(9, 9)
|
||||||
|
}];
|
||||||
|
const response = {
|
||||||
|
data: expected
|
||||||
|
};
|
||||||
|
|
||||||
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await store.getDuplicateReferrals();
|
||||||
|
|
||||||
|
// Asserts
|
||||||
|
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||||
|
expect(store.applicationUser.duplicateOrders).toEqual(expected);
|
||||||
|
});
|
||||||
|
it('Call to client returns exception => object with error property returned and duplicateReferrals set to []', async () => {
|
||||||
|
// Arrange
|
||||||
|
expect.assertions(3);
|
||||||
|
const error = 'this is the error';
|
||||||
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await store.getDuplicateReferrals().catch((e) => {
|
||||||
|
expect(e).toEqual(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Asserts
|
||||||
|
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||||
|
expect(store.applicationUser.duplicateOrders.length).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue