Merge pull request #460 from Safelite/feature/digital/SSR-511
Wiring up duplicate search
This commit is contained in:
commit
189250f70f
6 changed files with 76 additions and 29 deletions
|
|
@ -145,6 +145,11 @@ const endpoints = Object.freeze({
|
|||
SaveSession: {
|
||||
url: '/order/api/v1/order/save-session/iss',
|
||||
method: 'POST'
|
||||
},
|
||||
DuplicateSearch: {
|
||||
// eslint-disable-next-line max-len
|
||||
url: (accountNumber, policyNumber, phoneNumber) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${phoneNumber}`,
|
||||
method: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ describe('duplicateCheck.vue', () => {
|
|||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
|
||||
const mainInitialState = {
|
||||
applicationUser: {
|
||||
duplicateOrders: undefined
|
||||
|
|
@ -159,7 +159,7 @@ describe('duplicateCheck.vue', () => {
|
|||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
|
||||
const mainInitialState = {
|
||||
applicationUser: {
|
||||
duplicateOrders: []
|
||||
|
|
@ -181,7 +181,7 @@ describe('duplicateCheck.vue', () => {
|
|||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
|
||||
const date = getRandomString(9, 9);
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const mainInitialState = {
|
||||
|
|
@ -192,7 +192,7 @@ describe('duplicateCheck.vue', () => {
|
|||
vehicleMake: getRandomString(5, 5),
|
||||
vehicleModel: getRandomString(5, 5),
|
||||
dateOfLoss: date,
|
||||
referralNumber: referralNumber
|
||||
referralNumber
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -211,7 +211,6 @@ describe('duplicateCheck.vue', () => {
|
|||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: date
|
||||
|
||||
});
|
||||
});
|
||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||
|
|
@ -354,7 +353,7 @@ describe('duplicateCheck.vue', () => {
|
|||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
|
|
|
|||
|
|
@ -99,9 +99,10 @@ export default {
|
|||
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||
: null;
|
||||
const subtext = vehicle
|
||||
|
||||
const subtext = vehicle && o.dateOfLoss
|
||||
? `${vehicle}, ${o.dateOfLoss}`
|
||||
: o.dateOfLoss;
|
||||
: (vehicle ?? '').concat(o.dateOfLoss ?? '');
|
||||
|
||||
return {
|
||||
Text: duplicateOrderText,
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ export default {
|
|||
methods: {
|
||||
async forwardButtonAction() {
|
||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||
const duplicateCheckResponse = useMainStore().getDuplicateReferrals();
|
||||
const duplicateCheckResponse = await useMainStore().getDuplicateReferrals();
|
||||
const duplicatePromiseResultMap = [
|
||||
{
|
||||
resultKey: 'duplicateCheckResponse',
|
||||
|
|
|
|||
|
|
@ -469,27 +469,23 @@ export const useMainStore = defineStore({
|
|||
});
|
||||
});
|
||||
},
|
||||
// TODO when endpoint finished replace dummy data with api call
|
||||
getDuplicateReferrals() {
|
||||
const apiInputs = [
|
||||
this.issConfig.accountNumber,
|
||||
this.order.policy.policyNumber,
|
||||
this.order.policy.dateOfLoss
|
||||
];
|
||||
|
||||
return [
|
||||
{
|
||||
referralNumber: '12345',
|
||||
vehicleYear: '2013',
|
||||
vehicleMake: 'Honda',
|
||||
vehicleModel: 'Civic',
|
||||
dateOfLoss: '09/23/2023'
|
||||
},
|
||||
{
|
||||
referralNumber: '34210',
|
||||
dateOfLoss: '08/01/2022'
|
||||
}
|
||||
];
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
method: endpoints.DuplicateSearch.method,
|
||||
endpoint: endpoints.DuplicateSearch.url(
|
||||
this.issConfig.accountNumber,
|
||||
this.order.policy.policyNumber,
|
||||
this.order.customer.phoneNumber?.replaceAll('-', '')
|
||||
)
|
||||
}).then((r) => {
|
||||
this.applicationUser.duplicateOrders = r.data ?? [];
|
||||
return resolve(r.data);
|
||||
}).catch((error) => {
|
||||
this.applicationUser.duplicateOrders = [];
|
||||
return reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
async lookupVinByPlate(licensePlate, licenseState) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -977,4 +977,50 @@ describe('Store', () => {
|
|||
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