Merge pull request #709 from Safelite/feature/digital/SSR-1167
SSR-1167 Coverage Rework
This commit is contained in:
commit
02db8e965b
31 changed files with 1279 additions and 2039 deletions
|
|
@ -1,8 +0,0 @@
|
|||
const coverageStatementPageVariations = Object.freeze({
|
||||
DEDUCTIBLE: 0,
|
||||
ITAC: 1,
|
||||
NO_COMP: 2,
|
||||
UNVERIFIED: 3
|
||||
});
|
||||
|
||||
export default coverageStatementPageVariations;
|
||||
|
|
@ -1,6 +1,17 @@
|
|||
const coverageStatuses = Object.freeze({
|
||||
/**
|
||||
* We have not yet attempted claim registration
|
||||
*/
|
||||
PENDING: 0,
|
||||
NO_COMP: 1,
|
||||
|
||||
/**
|
||||
* We have attempted claim registration, and we got a failure response
|
||||
*/
|
||||
NO_COVERAGE: 1,
|
||||
|
||||
/**
|
||||
* We have attempted claim registration, and we got a success response
|
||||
*/
|
||||
VERIFIED: 2
|
||||
});
|
||||
|
||||
|
|
|
|||
28
src/constants/coverage-type.js
Normal file
28
src/constants/coverage-type.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const coverageType = Object.freeze({
|
||||
/**
|
||||
* We attempted policy lookup and it failed or we are no comp and no comp quotes are disabled for this client
|
||||
*/
|
||||
NONE: 0,
|
||||
|
||||
/**
|
||||
* We attempted policy lookup and got success response
|
||||
* We have selected a vehicle that has comprehensive coverage
|
||||
* We are not considered ITAC
|
||||
*/
|
||||
Deductible: 1,
|
||||
|
||||
/**
|
||||
* We attempted policy lookup and got a success response
|
||||
* We determined that we are in an ITAC case
|
||||
*/
|
||||
ITAC: 2,
|
||||
|
||||
/**
|
||||
* We attempted policy lookup and got a success response
|
||||
* The vehicle policy does not have comprehensive coverage
|
||||
* No Comp quotes are enabled by the client
|
||||
*/
|
||||
NO_COMP: 3
|
||||
});
|
||||
|
||||
export default coverageType;
|
||||
|
|
@ -157,7 +157,7 @@ const endpoints = Object.freeze({
|
|||
method: 'POST'
|
||||
},
|
||||
ValidateZip: {
|
||||
url: `${LOCATION_BASE_URL}/zip`,
|
||||
url: (zip) => `${LOCATION_BASE_URL}/zip/${zip}`,
|
||||
method: 'GET'
|
||||
},
|
||||
GooglePlaces: {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { useMainStore } from '@/store';
|
|||
import { getPriceOfLineItems, getTaxOfLineItems } from '@/helpers/price-calculator';
|
||||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
import coverageType from "@/constants/coverage-type";
|
||||
|
||||
/**
|
||||
* Returns the lineItems object from the order
|
||||
|
|
@ -93,7 +94,7 @@ export function isOrderUnverified(order) {
|
|||
* @returns {boolean} order NO COMP flag
|
||||
*/
|
||||
export function isOrderNoComp(order) {
|
||||
return order.policy?.noCoverage ?? false;
|
||||
return order.insuranceCoverage?.coverageType === coverageType.NO_COMP ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +103,7 @@ export function isOrderNoComp(order) {
|
|||
* @returns {boolean} order ITAC flag
|
||||
*/
|
||||
export function isOrderITAC(order) {
|
||||
return order.policy?.isITAC ?? false;
|
||||
return order.insuranceCoverage?.coverageType === coverageType.ITAC ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import {
|
|||
} from '@/helpers/cart-helper';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import { getEnumName } from '@/helpers/unit-test-helper';
|
||||
|
||||
describe('cart-helper', () => {
|
||||
function createDummyItem(partNumber, price, salesTax) {
|
||||
|
|
@ -251,7 +254,7 @@ describe('cart-helper', () => {
|
|||
});
|
||||
|
||||
describe('isOrderUnverified', () => {
|
||||
test.each([[false, false], [true, true]])('Returns %p when policy.isUnverified is %p', (expected, isUnverified) => {
|
||||
test.each([[false, false], [true, true]])('Returns %p when isUnverified is %p', (expected, isUnverified) => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified
|
||||
|
|
@ -266,7 +269,7 @@ describe('cart-helper', () => {
|
|||
});
|
||||
|
||||
describe('isOrderNoComp', () => {
|
||||
test('Returns false when policy is null', () => {
|
||||
test('Returns false when insuranceCoverage is null', () => {
|
||||
// Arrange
|
||||
const order = {};
|
||||
|
||||
|
|
@ -277,24 +280,30 @@ describe('cart-helper', () => {
|
|||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
test.each([[false, false], [true, true]])('Returns %p when policy.NoCoverage is %p', (expected, noCoverage) => {
|
||||
// Arrange
|
||||
const order = {
|
||||
policy: {
|
||||
noCoverage
|
||||
}
|
||||
};
|
||||
describe.each([
|
||||
[false, coverageType.NONE],
|
||||
[false, coverageType.ITAC],
|
||||
[true, coverageType.NO_COMP],
|
||||
[false, coverageType.Deductible]])('isOrderNoComp by coverageType', (expected, type) => {
|
||||
test(`Returns ${expected} when insuranceCoverage.coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
insuranceCoverage: {
|
||||
coverageType: type
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = isOrderNoComp(order);
|
||||
// Act
|
||||
const result = isOrderNoComp(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isOrderITAC', () => {
|
||||
test('Returns false when policy is null', () => {
|
||||
test('Returns false when insuranceCoverage is null', () => {
|
||||
// Arrange
|
||||
const order = {};
|
||||
|
||||
|
|
@ -305,298 +314,247 @@ describe('cart-helper', () => {
|
|||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
test.each([[false, false], [true, true]])('Returns %p when policy.isITAC is %p', (expected, isITAC) => {
|
||||
// Arrange
|
||||
const order = {
|
||||
policy: {
|
||||
isITAC
|
||||
}
|
||||
};
|
||||
describe.each([
|
||||
[false, coverageType.NONE],
|
||||
[true, coverageType.ITAC],
|
||||
[false, coverageType.NO_COMP],
|
||||
[false, coverageType.Deductible]])('isOrderITAC by coverageType ', (expected, type) => {
|
||||
test(`Returns ${expected} when insuranceCoverage.coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
insuranceCoverage: {
|
||||
coverageType: type
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = isOrderITAC(order);
|
||||
// Act
|
||||
const result = isOrderITAC(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSubtotal', () => {
|
||||
test('Returns 0 when there are null items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[100, coverageType.Deductible]])('getSubtotal null line items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are null items and verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns 0 when there are no items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[100, coverageType.Deductible]])('getSubtotal no line items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are no items and verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns sub total of deductible + vaps + fee line items when verified deductible', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
describe.each([
|
||||
[330, coverageType.ITAC],
|
||||
[330, coverageType.NO_COMP],
|
||||
[310, coverageType.Deductible]])('getSubtotal with line items', (expected, type) => {
|
||||
test(`Returns ${expected} cart subtotal when verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(310);
|
||||
});
|
||||
|
||||
test('Returns sub total of all line items when verified no comp', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(330);
|
||||
});
|
||||
|
||||
test('Returns sub total of all line items when verified ITAC', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: true
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSubtotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(330);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSalesTax', () => {
|
||||
test('Returns 0 when there are null items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[0, coverageType.Deductible]])('getSalesTax null items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are null items and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns 0 when there are no items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[0, coverageType.Deductible]])('getSalesTax with no items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are no items and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns sales tax vaps + fee line items when verified', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
describe.each([
|
||||
[21, coverageType.ITAC],
|
||||
[21, coverageType.NO_COMP],
|
||||
[15, coverageType.Deductible]])('getSalesTax with line items', (expected, type) => {
|
||||
test(`Returns ${expected} when coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(15);
|
||||
});
|
||||
|
||||
test('Returns sales tax of all line items when verified no comp', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(21);
|
||||
});
|
||||
|
||||
test('Returns sales tax of all line items when verified ITAC', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: true
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getSalesTax(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(21);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCartTotal', () => {
|
||||
test('Returns 0 when there are null items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[100, coverageType.Deductible]
|
||||
])('getCartTotal null items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are null items and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns 0 when there are no items', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
describe.each([
|
||||
[0, coverageType.ITAC],
|
||||
[0, coverageType.NO_COMP],
|
||||
[100, coverageType.Deductible]
|
||||
])('getCartTotal no items', (expected, type) => {
|
||||
test(`Returns ${expected} when there are no items and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(0);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test('Returns total of vaps + fee line items when verified', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
describe.each([
|
||||
[351, coverageType.ITAC],
|
||||
[351, coverageType.NO_COMP],
|
||||
[325, coverageType.Deductible]
|
||||
])('getCartTotal items', (expected, type) => {
|
||||
test(`Returns ${expected} cart total when verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(325);
|
||||
});
|
||||
|
||||
test('Returns total of all line items when verified no comp', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(351);
|
||||
});
|
||||
|
||||
test('Returns total of all line items when verified ITAC', () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
isUnverified: false,
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: true
|
||||
},
|
||||
currentDeductible: 0,
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = getCartTotal(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(351);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,3 +26,8 @@ export function getRandomString(minLength = 1, maxLength = 100) {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getRandomEnum(type) {
|
||||
const keys = Object.keys(type);
|
||||
return type[keys[getRandomInt(0, keys.length)]];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ export async function getZipCodeData(zipCode) {
|
|||
const serviceZipValidationResponse = await useMainStore().validateZip({ zip: zipCode });
|
||||
|
||||
return {
|
||||
containsMilitaryBase: serviceZipValidationResponse.data.containsMilitaryBase,
|
||||
isValid: serviceZipValidationResponse.data.isValid,
|
||||
isServiceable: serviceZipValidationResponse.data.isServiceable,
|
||||
state: serviceZipValidationResponse.data.state,
|
||||
zipCodeCtu: serviceZipValidationResponse.data.zipCodeCtu
|
||||
containsMilitaryBase: serviceZipValidationResponse.containsMilitaryBase,
|
||||
isValid: serviceZipValidationResponse.isValid,
|
||||
isServiceable: serviceZipValidationResponse.isServiceable,
|
||||
state: serviceZipValidationResponse.state,
|
||||
zipCodeCtu: serviceZipValidationResponse.zipCodeCtu
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ export function setupMocksForJsFiles() {
|
|||
return { baseMixin };
|
||||
}
|
||||
|
||||
export function getEnumName(object, value) {
|
||||
for (const field in object) {
|
||||
if (object[field] === value) {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Private methods
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ Object {
|
|||
"partQuestionAnswers": null,
|
||||
},
|
||||
"eon": null,
|
||||
"insuranceCoverage": Object {
|
||||
"claimNumber": null,
|
||||
"coverageStatus": 0,
|
||||
"coverageType": 0,
|
||||
},
|
||||
"lineItems": Object {
|
||||
"feeItems": Array [],
|
||||
"glassParts": null,
|
||||
|
|
@ -71,11 +76,6 @@ Object {
|
|||
"transReferenceNumber": null,
|
||||
"transactionId": null,
|
||||
},
|
||||
"insuranceCoverage": Object {
|
||||
"claimNumber": null,
|
||||
"coverageStatus": 0,
|
||||
"isVerified": false,
|
||||
},
|
||||
"isPayInAdvance": null,
|
||||
"parentAccountNumber": 0,
|
||||
"payInAdvanceType": null,
|
||||
|
|
@ -93,10 +93,7 @@ Object {
|
|||
"endorsementQuestionAnswers": Array [],
|
||||
"endorsements": Array [],
|
||||
"isDamageGlassOnly": null,
|
||||
"isITAC": false,
|
||||
"noCoverage": null,
|
||||
"policyData": null,
|
||||
"policyLookupSuccessful": null,
|
||||
"policyNumber": null,
|
||||
"policyZipCode": null,
|
||||
"status": null,
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@ import { createTestingPinia } from '@pinia/testing';
|
|||
import cartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import {getEnumName, getMountOptions} from '@/helpers/unit-test-helper.js';
|
||||
import { useMainStore, getDefaultState } from '@/store';
|
||||
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/service-package-helper.js';
|
||||
import { getPriceOfLineItems } from '@/helpers/price-calculator.js';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||
|
||||
|
|
@ -125,11 +127,9 @@ describe('cart-dropdown component', () => {
|
|||
const initialData = { isExpanded };
|
||||
const storeData = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -150,12 +150,9 @@ describe('cart-dropdown component', () => {
|
|||
order: {
|
||||
currentDeductible: 0,
|
||||
lineItems: { },
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: true,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.ITAC
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
|
|
@ -303,12 +300,9 @@ describe('cart-dropdown component', () => {
|
|||
order: {
|
||||
currentDeductible: 0,
|
||||
lineItems: { },
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: true,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.ITAC
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
|
|
@ -330,11 +324,9 @@ describe('cart-dropdown component', () => {
|
|||
const initialData = { isExpanded };
|
||||
const storeData = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1317,158 +1309,41 @@ describe('cart-dropdown component', () => {
|
|||
});
|
||||
});
|
||||
describe('method', () => {
|
||||
describe('getDisplayed', () => {
|
||||
test('returns "Verifying coverage" when not no comp, not itac, and deductible null', () => {
|
||||
const dollarAmount = '$84.00';
|
||||
describe.each([
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.Deductible]
|
||||
])('getDisplayed', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverage status ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false
|
||||
},
|
||||
currentDeductible: null
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(VERIFYING_COVERAGE);
|
||||
});
|
||||
test('returns "Verifying coverage" when not no comp, not itac, and coverage status PENDING', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 321
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
formatAmountInDollars.mockReturnValueOnce(dollarAmount);
|
||||
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
const result = wrapper.vm.getDisplayed(0);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(VERIFYING_COVERAGE);
|
||||
});
|
||||
test('returns dollar amount when itac', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: true,
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: 321
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars.mockImplementationOnce(() => dollarAmount);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
});
|
||||
test('returns dollar amount when no comp and enableNoCompQuotes true', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: false,
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: 321
|
||||
},
|
||||
issConfig: {
|
||||
enableNoCompQuote: true
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars.mockImplementationOnce(() => dollarAmount);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
});
|
||||
test('returns "Verifying Coverage" when no comp and enableNoCompQuotes false', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
policy: {
|
||||
isITAC: false,
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: 321
|
||||
},
|
||||
issConfig: {
|
||||
enableNoCompQuote: false
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(VERIFYING_COVERAGE);
|
||||
});
|
||||
test('returns dollar amount when deductible set, not itac, not no comp, and verified', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
policy: {
|
||||
isITAC: false,
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: 321,
|
||||
policyLookupSuccessful: true,
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars
|
||||
.mockImplementationOnce((value) => (value === amount ? dollarAmount : 1));
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('getCartItemForVapsPart', () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`coverageStatement.vue-working returns the initial data 1`] = `
|
||||
exports[`coverageStatement.vue returns the initial data 1`] = `
|
||||
Object {
|
||||
"baseServiceLineItems": Array [],
|
||||
"deductibleText": "Your deductible is",
|
||||
|
|
|
|||
|
|
@ -4,14 +4,16 @@ import coverageStatement from '@/layouts/coverage-statement/coverage-statement.v
|
|||
// Supporting Files
|
||||
import { nextTick } from 'vue';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import { useMainStore, getDefaultState } from '@/store';
|
||||
import { useMainStore } from '@/store';
|
||||
import { getPriceOfLineItems } from '@/helpers/price-calculator.js';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
jest.mock('@/helpers/price-calculator.js', () => ({
|
||||
|
|
@ -92,15 +94,7 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
|||
return { wrapper };
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
const store = useMainStore();
|
||||
const defaultState = getDefaultState();
|
||||
Object.keys(defaultState).forEach((key) => {
|
||||
store[key] = defaultState[key];
|
||||
});
|
||||
});
|
||||
|
||||
describe('coverageStatement.vue-working', () => {
|
||||
describe('coverageStatement.vue', () => {
|
||||
test('returns the initial data', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
|
|
@ -108,9 +102,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -173,360 +167,105 @@ describe('coverageStatement.vue-working', () => {
|
|||
});
|
||||
});
|
||||
describe('Computed', () => {
|
||||
describe('verifiedNoComp', () => {
|
||||
describe('isNoCompQuoteVisible true', () => {
|
||||
const enableNoCompQuote = true;
|
||||
test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: isNoComp,
|
||||
policyLookupSuccessful: false
|
||||
}
|
||||
},
|
||||
issConfig: { enableNoCompQuote }
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test.each([true, false])('returns false when isNoComp false', (policyLookupSuccessful) => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful
|
||||
}
|
||||
},
|
||||
issConfig: { enableNoCompQuote }
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns true when policyLookupSuccessful true, noCoverage true, and enableNoCompQuote true', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
}
|
||||
},
|
||||
issConfig: { enableNoCompQuote }
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
test('returns false when policyLookupSuccessful true, noCoverage true and enableNoCompQuote false', () => {
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isNoCompQuoteVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
enableNoCompQuote: false
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('isITACQuoteVisible', () => {
|
||||
const priceOfLineItems = 213;
|
||||
test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
|
||||
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isITACQuoteVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: isNoComp,
|
||||
policyLookupSuccessful: false
|
||||
},
|
||||
currentDeductible: priceOfLineItems + 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test.each([true, false])('returns false when isNoComp true', (policyLookupSuccessful) => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful
|
||||
},
|
||||
currentDeductible: priceOfLineItems + 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test.each([
|
||||
[true, false],
|
||||
[true, true],
|
||||
[false, false],
|
||||
[false, true]
|
||||
])('returns false when deductibleValue equals totalServicePrice', (noCoverage, policyLookupSuccessful) => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage,
|
||||
policyLookupSuccessful
|
||||
},
|
||||
currentDeductible: priceOfLineItems
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test.each([
|
||||
[true, false],
|
||||
[true, true],
|
||||
[false, false],
|
||||
[false, true]
|
||||
])(
|
||||
'returns false when deductibleValue less than totalServicePrice when noCoverage is %p and policyLookupSuccessful is %p',
|
||||
(noCoverage, policyLookupSuccessful) => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage,
|
||||
policyLookupSuccessful
|
||||
},
|
||||
currentDeductible: priceOfLineItems - 1
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
}
|
||||
);
|
||||
test('returns true when deductibleValue more than totalServicePrice, noComp is false, and policyLookupSuccessful true', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: priceOfLineItems + 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('isDeductibleVisible', () => {
|
||||
const servicePrice = 123;
|
||||
describe('claim registration required', () => {
|
||||
const issConfig = { isClaimRegistrationRequired: true };
|
||||
let verifiedDeductibleStoreState;
|
||||
beforeEach(() => {
|
||||
verifiedDeductibleStoreState = {
|
||||
issConfig,
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: servicePrice - 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||
});
|
||||
test('returns false when deductible is null', () => {
|
||||
// Arrange
|
||||
const mainInitialState = verifiedDeductibleStoreState;
|
||||
mainInitialState.order.currentDeductible = null;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when register claim not successful', () => {
|
||||
// Arrange
|
||||
const mainInitialState = verifiedDeductibleStoreState;
|
||||
mainInitialState.order.payment.insuranceCoverage.isVerified = false;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns true when register claim successful, isNoComp false, and service price over deductible', () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent(verifiedDeductibleStoreState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('claim registration not required', () => {
|
||||
const issConfig = { isClaimRegistrationRequired: false };
|
||||
let verifiedDeductibleStoreState;
|
||||
beforeEach(() => {
|
||||
verifiedDeductibleStoreState = {
|
||||
issConfig,
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: false
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: servicePrice - 1
|
||||
}
|
||||
};
|
||||
});
|
||||
test('returns false when policy lookup not successful', () => {
|
||||
// Arrange
|
||||
const mainInitialState = verifiedDeductibleStoreState;
|
||||
mainInitialState.order.policy.policyLookupSuccessful = false;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns true when policyLookupSuccessful, isNoComp false, and deductible over service price', () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent(verifiedDeductibleStoreState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
test('returns false when isNoComp true', () => {
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isDeductibleVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const isNoComp = true;
|
||||
const storeState = {
|
||||
issConfig: {
|
||||
isClaimRegistrationRequired: false
|
||||
},
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
noCoverage: isNoComp,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: servicePrice - 1
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeState);
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when service price below deductible', () => {
|
||||
// Arrange
|
||||
const storeState = {
|
||||
issConfig: {
|
||||
isClaimRegistrationRequired: false
|
||||
},
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
currentDeductible: servicePrice + 1
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('isADAS', () => {
|
||||
|
|
@ -618,269 +357,80 @@ describe('coverageStatement.vue-working', () => {
|
|||
});
|
||||
});
|
||||
describe('isQuoteDisplayed', () => {
|
||||
test('returns false when policy lookup not successful', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: false
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
describe('not no comp', () => {
|
||||
const priceOfLineItems = 341;
|
||||
test('returns false when deductible equal to service price', () => {
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible]
|
||||
])('isQuoteDisplayed', (expected, status, type) => {
|
||||
// eslint-disable-next-line max-len
|
||||
test(`$returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false
|
||||
},
|
||||
currentDeductible: priceOfLineItems
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when deductible less than service price', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false
|
||||
},
|
||||
currentDeductible: priceOfLineItems - 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns true when policy lookup successful and deductible over service price', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false
|
||||
},
|
||||
currentDeductible: priceOfLineItems + 1
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('not itac', () => {
|
||||
const priceOfLineItems = 23;
|
||||
test('returns false when isNoComp false', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false
|
||||
},
|
||||
currentDeductible: priceOfLineItems
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when isNoComp true and enableNoCompQuote false', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: true
|
||||
},
|
||||
currentDeductible: priceOfLineItems
|
||||
},
|
||||
issConfig: {
|
||||
enableNoCompQuote: false
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns true when isNoComp true and enableNoCompQuote true', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: true
|
||||
},
|
||||
currentDeductible: priceOfLineItems
|
||||
},
|
||||
issConfig: {
|
||||
enableNoCompQuote: true
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isQuoteDisplayed;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe.each([[0], [12]])('shouldRegisterClaim', (policyVehicleId) => {
|
||||
const servicePrice = 90;
|
||||
let shouldRegisterClaimStoreStateItac;
|
||||
beforeEach(() => {
|
||||
shouldRegisterClaimStoreStateItac = {
|
||||
describe.each([
|
||||
[false, false, true, true, 0],
|
||||
[false, true, false, true, 0],
|
||||
[false, true, true, false, 0],
|
||||
[false, true, true, true, -1],
|
||||
[false, true, true, true, null],
|
||||
[true, true, true, true, 0]
|
||||
])('shouldRegisterClaim', (
|
||||
expected,
|
||||
isClaimRegistrationRequired,
|
||||
isPolicyLookupSuccessful,
|
||||
isPendingClaimRegistration,
|
||||
policyVehicleId
|
||||
) => {
|
||||
test(`returns ${expected} when isClaimRegistrationRequired is ${isClaimRegistrationRequired} `
|
||||
+ `and isPolicyLookupSuccessful is ${isPolicyLookupSuccessful} `
|
||||
+ `and isPendingClaimRegistration is ${isPendingClaimRegistration} `
|
||||
+ `and policyVehicleId is ${(policyVehicleId == null ? 'NULL' : policyVehicleId)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
claimNumber: null
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: isPendingClaimRegistration ? coverageStatuses.PENDING : coverageStatuses.VERIFIED,
|
||||
coverageType: isPolicyLookupSuccessful ? coverageType.Deductible : coverageType.NONE
|
||||
},
|
||||
vehicle: {
|
||||
policyVehicleId
|
||||
},
|
||||
currentDeductible: servicePrice - 1
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
isClaimRegistrationRequired: true,
|
||||
enableNoCompQuote: true
|
||||
isClaimRegistrationRequired
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||
});
|
||||
test('returns false when policy lookup not successful', () => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.order.policy.policyLookupSuccessful = false;
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when policy vehicle id is less than 0', () => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.order.vehicle.policyVehicleId = -3;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when policy vehicle id is null', () => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.order.vehicle.policyVehicleId = null;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when claim registration is not required', () => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.issConfig.isClaimRegistrationRequired = false;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when claim already registered', () => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.order.payment.insuranceCoverage.claimNumber = 13;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
describe('returns true when policy lookup success, vehicleId set to %p, claim reg req, claim not yet reg', () => {
|
||||
test('and itac', () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent(shouldRegisterClaimStoreStateItac);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
test.each([
|
||||
[servicePrice],
|
||||
[servicePrice + 1]
|
||||
])('and deductible case', (deductibleValue) => {
|
||||
// Arrange
|
||||
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||
mainInitialState.currentDeductible = deductibleValue;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.shouldRegisterClaim;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -948,8 +498,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.NONE
|
||||
},
|
||||
currentDeductible: null
|
||||
}
|
||||
|
|
@ -974,9 +525,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: deductible
|
||||
}
|
||||
|
|
@ -1001,9 +552,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.ITAC
|
||||
},
|
||||
currentDeductible: deductible
|
||||
}
|
||||
|
|
@ -1031,9 +582,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.ITAC
|
||||
},
|
||||
currentDeductible: deductible
|
||||
}
|
||||
|
|
@ -1060,9 +611,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.NO_COMP
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
|
|
@ -1091,9 +642,9 @@ describe('coverageStatement.vue-working', () => {
|
|||
damage: {
|
||||
isRepair: true
|
||||
},
|
||||
policy: {
|
||||
noCoverage: true,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.NO_COMP
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
|
|
@ -1117,49 +668,50 @@ describe('coverageStatement.vue-working', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
describe('ITAC flag', () => {
|
||||
test('ITAC flag updated once component is initialized', async () => {
|
||||
describe('ITAC CoverageType', () => {
|
||||
test('set ITAC coverageType once component is initialized', async () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
policy: {
|
||||
isITAC: null
|
||||
}
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: 666
|
||||
}
|
||||
};
|
||||
const mockStoreActions = () => {
|
||||
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([]));
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState, {}, mockStoreActions);
|
||||
getPriceOfLineItems.mockReturnValue(333);
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
wrapper.vm.initializeComponent();
|
||||
await wrapper.vm.initializeComponent();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyITACFlag)
|
||||
expect(wrapper.vm.mainStore.updateCoverageType)
|
||||
.toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(wrapper.vm.mainStore.updateCoverageType)
|
||||
.toHaveBeenCalledWith(coverageType.ITAC);
|
||||
});
|
||||
|
||||
it('Loaded duplicate with previously registered claim => claim registration is not called', async () => {
|
||||
it('Loaded duplicate with previously registered claim => claim registration is not called', async () => {
|
||||
// Arrange
|
||||
const sellingPrice = getRandomInt(50, 100);
|
||||
const deductible = sellingPrice - 1;
|
||||
const initialStore = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible,
|
||||
claimNumber: getRandomString(10, 10)
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
noCoverage: false,
|
||||
deductible: {
|
||||
repair: deductible
|
||||
}
|
||||
},
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
claimNumber: getRandomString(10, 10)
|
||||
}
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
|
|
@ -1225,16 +777,10 @@ describe('coverageStatement.vue-working', () => {
|
|||
const deductible = servicePrice - 1;
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
claimNumber: null,
|
||||
isVerified: true
|
||||
}
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false,
|
||||
isITAC: false,
|
||||
policyLookupSuccessful: true
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible,
|
||||
claimNumber: null
|
||||
},
|
||||
vehicle: {
|
||||
policyVehicleId: 1
|
||||
|
|
@ -1255,14 +801,8 @@ describe('coverageStatement.vue-working', () => {
|
|||
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
||||
const next = (method) => { method(wrapper.vm); };
|
||||
|
||||
console.log(wrapper.vm.pageVariation);
|
||||
|
||||
// Act
|
||||
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
||||
for (let i = 0; i < 7; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await nextTick();
|
||||
}
|
||||
await coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ import alert from '@/ux-components/alert/alert.vue';
|
|||
import contentGroupModal from '@/iss-components/content-group-modal/content-group-modal.vue';
|
||||
import buttonQuestion from '@/digital-components/button-question/button-question.vue';
|
||||
import textBlock from '@/digital-components/text-block/text-block.vue';
|
||||
import pageVariations from '@/constants/coverage-statement-page-variations';
|
||||
|
||||
// Import Supporting Files
|
||||
import {
|
||||
|
|
@ -121,11 +120,12 @@ import baseFormMixin from '@/mixins/base-form-mixin.js';
|
|||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import widgetFields from '@/constants/cms-widget-fields.js';
|
||||
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||
import { getPriceOfLineItems } from '@/helpers/price-calculator';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
|
||||
const SAFELITE_PROVIDER = 'Safelite';
|
||||
|
||||
|
|
@ -173,9 +173,12 @@ export default {
|
|||
|
||||
let hasBailedOut = false;
|
||||
let pricingResults = [];
|
||||
const { policy, vehicle } = useMainStore();
|
||||
if (policy.policyLookupSuccessful && vehicle.policyVehicleId >= 0) {
|
||||
await useMainStore().getFinalDeductible();
|
||||
const { vehicle, isPolicyLookupSuccessful, isITAC, isDeductible } = useMainStore();
|
||||
if (isPolicyLookupSuccessful && vehicle.policyVehicleId >= 0) {
|
||||
if (isITAC || isDeductible) {
|
||||
await useMainStore().getFinalDeductible();
|
||||
}
|
||||
|
||||
pricingResults = await useMainStore()
|
||||
.getPriceOrderItems(availableLineItems)
|
||||
.catch((err) => {
|
||||
|
|
@ -194,19 +197,23 @@ export default {
|
|||
|
||||
if (!hasBailedOut) {
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
next(async (vm) => {
|
||||
showIssLoadingModal(true);
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setSupportingItems(resultMap.supportingItems);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
vm.setBaseServiceLineItems(pricingResults);
|
||||
vm.initializeComponent();
|
||||
await vm.initializeComponent();
|
||||
if (!vm.unverified) {
|
||||
useMainStore().disableKeyFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
const mainStore = useMainStore();
|
||||
return { mainStore };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
baseServiceLineItems: [],
|
||||
|
|
@ -227,47 +234,6 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
pageVariation() {
|
||||
const {
|
||||
isNoComp,
|
||||
issConfig,
|
||||
policy,
|
||||
payment,
|
||||
isClaimRegistrationRequired
|
||||
} = useMainStore();
|
||||
const registerClaimSuccessful =
|
||||
payment.insuranceCoverage.isVerified;
|
||||
|
||||
if (!policy.policyLookupSuccessful) {
|
||||
return pageVariations.UNVERIFIED;
|
||||
}
|
||||
|
||||
if (isNoComp) {
|
||||
if (issConfig.enableNoCompQuote) {
|
||||
return pageVariations.NO_COMP;
|
||||
}
|
||||
return pageVariations.UNVERIFIED;
|
||||
}
|
||||
|
||||
if (this.deductibleValue == null) {
|
||||
return pageVariations.UNVERIFIED;
|
||||
}
|
||||
|
||||
// TODO this should be determined based on the result of the ITAC price call
|
||||
// TODO it seems that ITAC now requires claim registration calls. If this call fails
|
||||
// should the page become unverified?
|
||||
if (this.deductibleValue > this.totalServicePrice) {
|
||||
return pageVariations.ITAC;
|
||||
}
|
||||
|
||||
if (isClaimRegistrationRequired) {
|
||||
if (registerClaimSuccessful) {
|
||||
return pageVariations.DEDUCTIBLE;
|
||||
}
|
||||
return pageVariations.UNVERIFIED;
|
||||
}
|
||||
return pageVariations.DEDUCTIBLE;
|
||||
},
|
||||
coverageStatementSubHeader() {
|
||||
return this.getTextFromCmsWithCustomIfStatements(
|
||||
this.widget.subheader,
|
||||
|
|
@ -324,17 +290,16 @@ export default {
|
|||
return useMainStore().order.currentDeductible;
|
||||
},
|
||||
isNoCompQuoteVisible() {
|
||||
return this.pageVariation === pageVariations.NO_COMP;
|
||||
return this.mainStore.isVerified && this.mainStore.isNoComp;
|
||||
},
|
||||
isITACQuoteVisible() {
|
||||
return this.pageVariation === pageVariations.ITAC;
|
||||
return this.mainStore.isVerified && this.mainStore.isITAC;
|
||||
},
|
||||
isDeductibleVisible() {
|
||||
return this.pageVariation === pageVariations.DEDUCTIBLE;
|
||||
return this.mainStore.isVerified && this.mainStore.isDeductible;
|
||||
},
|
||||
|
||||
isUnverifiedVisible() {
|
||||
return this.pageVariation === pageVariations.UNVERIFIED;
|
||||
return this.mainStore.isUnverified;
|
||||
},
|
||||
isADAS() {
|
||||
const { glassParts } = useMainStore().order.lineItems;
|
||||
|
|
@ -363,18 +328,18 @@ export default {
|
|||
},
|
||||
shouldRegisterClaim() {
|
||||
const {
|
||||
policy,
|
||||
vehicle,
|
||||
isClaimRegistrationRequired,
|
||||
isClaimAlreadyRegistered
|
||||
isPolicyLookupSuccessful,
|
||||
isPendingClaimRegistration
|
||||
} = useMainStore();
|
||||
const { policyVehicleId } = vehicle;
|
||||
return (
|
||||
policy.policyLookupSuccessful
|
||||
isPolicyLookupSuccessful
|
||||
&& policyVehicleId != null
|
||||
&& policyVehicleId >= 0
|
||||
&& isClaimRegistrationRequired
|
||||
&& !isClaimAlreadyRegistered
|
||||
&& isPendingClaimRegistration
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -401,18 +366,20 @@ export default {
|
|||
return !!useMainStore().vehicle.carId;
|
||||
},
|
||||
async initializeComponent() {
|
||||
useMainStore().updatePolicyITACFlag(this.isITACQuoteVisible);
|
||||
// TODO how should coverage status be updated
|
||||
const coverageStatus =
|
||||
this.isITACQuoteVisible || this.isNoCompQuoteVisible
|
||||
? coverageStatuses.VERIFIED
|
||||
: coverageStatuses.PENDING;
|
||||
useMainStore().updateCoverageStatus(coverageStatus);
|
||||
if (this.shouldRegisterClaim) {
|
||||
await useMainStore()
|
||||
.registerClaim()
|
||||
?.catch(() => {});
|
||||
await this.mainStore.registerClaim();
|
||||
} else if (!this.mainStore.isClaimRegistrationRequired) {
|
||||
this.mainStore.updateCoverageStatus(coverageStatuses.VERIFIED);
|
||||
}
|
||||
|
||||
// TODO this should be determined based on the result of the ITAC price call
|
||||
// TODO it seems that ITAC now requires claim registration calls. If this call fails
|
||||
if (this.mainStore.isVerified
|
||||
&& this.mainStore.isDeductible
|
||||
&& this.deductibleValue > this.totalServicePrice) {
|
||||
this.mainStore.updateCoverageType(coverageType.ITAC);
|
||||
}
|
||||
|
||||
showIssLoadingModal(false);
|
||||
},
|
||||
async navigateForward() {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import { getRandomString } from '@/helpers/data-generation.js';
|
|||
import { useMainStore } from '@/store';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
|
|
@ -420,12 +422,15 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
test('policyLookupSuccessful true 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
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: [{ test: 'a' }]
|
||||
}
|
||||
}
|
||||
|
|
@ -439,12 +444,15 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.$router.navigate)
|
||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES, undefined);
|
||||
});
|
||||
test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
||||
test('coverageType deductible and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: []
|
||||
}
|
||||
}
|
||||
|
|
@ -458,12 +466,13 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.$router.navigate)
|
||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES, undefined);
|
||||
});
|
||||
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
||||
test('coverageType none => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: false
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.NONE
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -477,13 +486,16 @@ describe('duplicateCheck.vue', () => {
|
|||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
||||
test('coverageType deductible and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
||||
// Arrange
|
||||
const vin = getRandomString(17, 17);
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: [{ vin }]
|
||||
},
|
||||
vehicle: {
|
||||
|
|
@ -502,13 +514,16 @@ describe('duplicateCheck.vue', () => {
|
|||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
||||
test('coverageType deductible and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
||||
// Arrange
|
||||
const vin = getRandomString(17, 17);
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: [{ vin }]
|
||||
},
|
||||
vehicle: {
|
||||
|
|
@ -527,12 +542,15 @@ describe('duplicateCheck.vue', () => {
|
|||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
||||
test('coverageType deductible and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: []
|
||||
},
|
||||
vehicle: {
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ export default {
|
|||
}
|
||||
},
|
||||
navigateForward() {
|
||||
if (!this.mainStore.order.policy.policyLookupSuccessful) {
|
||||
if (!this.mainStore.isPolicyLookupSuccessful) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|||
import { mount } from '@vue/test-utils';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { nextTick } from 'vue';
|
||||
import coverageStatuses from "@/constants/coverage-statuses";
|
||||
import coverageType from "@/constants/coverage-type";
|
||||
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
|
||||
|
|
@ -70,12 +72,13 @@ const initialStore = {
|
|||
}
|
||||
}
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isInsurance: true,
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
contactInfo: {
|
||||
firstName: 'Test',
|
||||
|
|
@ -110,18 +113,17 @@ const sessionStorage = {
|
|||
}
|
||||
}
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
|
||||
|
|
@ -320,18 +322,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
serviceLocation: {
|
||||
appointmentType: 'Mobile'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -362,18 +363,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
}
|
||||
}
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -412,18 +412,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
zipCode: '12345',
|
||||
appointmentType: 'Mobile'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -454,18 +453,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
},
|
||||
appointmentType: 'Dropoff'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -496,18 +494,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
},
|
||||
appointmentType: 'Inshop'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -535,18 +532,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
zipCode: '12345',
|
||||
appointmentType: 'Mobile'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -577,18 +573,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
},
|
||||
appointmentType: 'Inshop'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -616,18 +611,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
zipCode: '12345',
|
||||
appointmentType: 'Mobile'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -658,18 +652,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
},
|
||||
appointmentType: 'Dropoff'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
@ -701,18 +694,17 @@ describe('OrderConfirmation.vue', () => {
|
|||
},
|
||||
appointmentType: 'Inshop'
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
isPayInAdvance: false
|
||||
},
|
||||
lineItems: {
|
||||
vaps: []
|
||||
},
|
||||
policy: {
|
||||
noCoverage: false
|
||||
},
|
||||
policy: {},
|
||||
damage: {}
|
||||
};
|
||||
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import { paymentMethods } from '@/constants/payment-method-constants';
|
|||
import queryStrings from '@/constants/query-strings';
|
||||
import { experimentSettings } from '@/constants/experiments';
|
||||
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
// Mock so it can be used as an assertion
|
||||
jest.mock('@/helpers/order-helper.js', () => ({
|
||||
|
|
@ -139,15 +141,9 @@ describe('payment-method.vue', () => {
|
|||
beforeEach(() => {
|
||||
store = {
|
||||
order: {
|
||||
policy: {
|
||||
isITAC: false,
|
||||
noCoverage: false,
|
||||
policyLookupSuccessful: true
|
||||
},
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: true
|
||||
}
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: 123
|
||||
},
|
||||
|
|
@ -166,9 +162,9 @@ describe('payment-method.vue', () => {
|
|||
}
|
||||
};
|
||||
});
|
||||
test('returns true when policyLookupSuccessful false', () => {
|
||||
test('returns true when coverageStatus is pending', () => {
|
||||
// Arrange
|
||||
store.order.policy.policyLookupSuccessful = false;
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
|
|
@ -177,10 +173,9 @@ describe('payment-method.vue', () => {
|
|||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
test('returns true when no comp and enableNoCompQuote false', () => {
|
||||
test('returns true when coverageStatus is no coverage', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = true;
|
||||
store.issConfig.enableNoCompQuote = false;
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.NO_COVERAGE;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
|
|
@ -189,35 +184,9 @@ describe('payment-method.vue', () => {
|
|||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
test('returns true when not no comp and currentDeductible null', () => {
|
||||
test('returns false when coverageStatus is verified', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = false;
|
||||
store.order.currentDeductible = null;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isPayInAdvanceDisabled;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
test('returns true when isClaimRegistrationRequired true and insurance coverage not verified', () => {
|
||||
// Arrange
|
||||
store.order.payment.insuranceCoverage.isVerified = false;
|
||||
store.issConfig.isClaimRegistrationRequired = true;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isPayInAdvanceDisabled;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
test('returns false when no comp, enableNoCompQuote true, and currentDeductible null and pia enabled', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = true;
|
||||
store.issConfig.enableNoCompQuote = true;
|
||||
store.order.currentDeductible = null;
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
|
|
@ -226,17 +195,7 @@ describe('payment-method.vue', () => {
|
|||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test('returns false when not no comp, currentDeductible not null and pia enabled', () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isPayInAdvanceDisabled;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
test.skip('returns true when pia not enabled', () => {
|
||||
test('returns true when pia not enabled', () => {
|
||||
// Arrange
|
||||
mixin = {
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -200,13 +200,13 @@ const defaultOrder = {
|
|||
vaps: [parts.frontWipers],
|
||||
promos: []
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: null,
|
||||
coverageType: null,
|
||||
claimNumber: null
|
||||
},
|
||||
payment: {
|
||||
isInsurance: false,
|
||||
insuranceCoverage: {
|
||||
isVerified: null,
|
||||
coverageStatus: null,
|
||||
coverageVerificationType: null
|
||||
},
|
||||
isPayInAdvance: true,
|
||||
payInAdvanceType: 'Afterpay',
|
||||
inactivePromos: []
|
||||
|
|
|
|||
|
|
@ -121,9 +121,12 @@ describe('policy-vehicles.vue', () => {
|
|||
const store = useMainStore();
|
||||
store.lookupVehicleByVin.mockReturnValue(Promise.resolve(lookupVehicleResponse));
|
||||
|
||||
const expectedInput = {
|
||||
const updateVehicleInput = {
|
||||
year,
|
||||
vin,
|
||||
vin
|
||||
};
|
||||
|
||||
const updateVehicleCoverage = {
|
||||
noCoverage: true,
|
||||
deductible: 0,
|
||||
repairWaived: false,
|
||||
|
|
@ -136,7 +139,8 @@ describe('policy-vehicles.vue', () => {
|
|||
// Assert
|
||||
expect(wrapper.vm.bailout).toBeFalsy();
|
||||
expect(wrapper.vm.policyVinFound).toBeTruthy();
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(updateVehicleInput);
|
||||
expect(store.updateVehicleCoverage).toHaveBeenCalledWith(updateVehicleCoverage);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE,
|
||||
undefined,
|
||||
|
|
@ -174,9 +178,12 @@ describe('policy-vehicles.vue', () => {
|
|||
const store = useMainStore();
|
||||
store.lookupVehicleByVin.mockReturnValue(Promise.resolve(lookupVehicleResponse));
|
||||
|
||||
const expectedInput = {
|
||||
const updateVehicleInput = {
|
||||
year,
|
||||
vin,
|
||||
vin
|
||||
};
|
||||
|
||||
const updateVehicleCoverage = {
|
||||
noCoverage: true,
|
||||
deductible: 0,
|
||||
repairWaived: false,
|
||||
|
|
@ -187,7 +194,8 @@ describe('policy-vehicles.vue', () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(updateVehicleInput);
|
||||
expect(store.updateVehicleCoverage).toHaveBeenCalledWith(updateVehicleCoverage);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
||||
undefined
|
||||
|
|
@ -225,9 +233,12 @@ describe('policy-vehicles.vue', () => {
|
|||
const store = useMainStore();
|
||||
store.lookupVehicleByVin.mockReturnValue(Promise.resolve(lookupVehicleResponse));
|
||||
|
||||
const expectedInput = {
|
||||
const updateVehicleInput = {
|
||||
year,
|
||||
vin,
|
||||
vin
|
||||
};
|
||||
|
||||
const updateVehicleCoverage = {
|
||||
noCoverage: true,
|
||||
deductible: 0,
|
||||
repairWaived: false,
|
||||
|
|
@ -238,7 +249,8 @@ describe('policy-vehicles.vue', () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(updateVehicleInput);
|
||||
expect(store.updateVehicleCoverage).toHaveBeenCalledWith(updateVehicleCoverage);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
||||
undefined
|
||||
|
|
|
|||
|
|
@ -148,9 +148,13 @@ export default {
|
|||
}
|
||||
if (vehicle) {
|
||||
// save selected vehicle to the store
|
||||
this.mainStore.updateVehicle(vehicle.data);
|
||||
this.displayGeneric = false;
|
||||
this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value);
|
||||
useMainStore().updateVehicle({
|
||||
...vehicle.data,
|
||||
policyVehicleId: this.selectedPolicyVehicle?.id,
|
||||
vin: value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -186,10 +190,7 @@ export default {
|
|||
make: vehicle.vehicleMake || '',
|
||||
model: vehicle.vehicleModel || '',
|
||||
style: vehicle.vehicleStyle || '',
|
||||
vin: vehicle.vin,
|
||||
noCoverage: this.noCoverageForSelectedVehicle,
|
||||
deductible: this.deductibleForSelectedVehicle,
|
||||
repairWaived: this.repairWaivedForSelectedVehicle
|
||||
vin: vehicle.vin
|
||||
});
|
||||
this.policyVinFound = false;
|
||||
return this.navigateForward();
|
||||
|
|
@ -202,19 +203,17 @@ export default {
|
|||
return this.navigateForward();
|
||||
}
|
||||
|
||||
this.vehicleFromLookup = Object.assign(
|
||||
vehicleLookupResponse.data,
|
||||
{
|
||||
policyVehicleId: vehicle.id,
|
||||
vin: this.selectedVehicleVin,
|
||||
noCoverage: this.noCoverageForSelectedVehicle,
|
||||
deductible: this.deductibleForSelectedVehicle,
|
||||
repairWaived: this.repairWaivedForSelectedVehicle,
|
||||
endorsements: this.endorsementsForSelectedVehicle
|
||||
}
|
||||
);
|
||||
|
||||
useMainStore().updateVehicle(this.vehicleFromLookup);
|
||||
useMainStore().updateVehicle({
|
||||
...vehicleLookupResponse.data,
|
||||
policyVehicleId: vehicle.id,
|
||||
vin: this.selectedVehicleVin
|
||||
});
|
||||
useMainStore().updateVehicleCoverage({
|
||||
noCoverage: this.noCoverageForSelectedVehicle,
|
||||
deductible: this.deductibleForSelectedVehicle,
|
||||
repairWaived: this.repairWaivedForSelectedVehicle,
|
||||
endorsements: this.endorsementsForSelectedVehicle
|
||||
});
|
||||
}
|
||||
return this.navigateForward();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -73,10 +73,10 @@ export default {
|
|||
}
|
||||
},
|
||||
isITAC() {
|
||||
return useMainStore().policy.isITAC;
|
||||
return useMainStore().isITAC;
|
||||
},
|
||||
isItacOrNoComp() {
|
||||
return useMainStore().policy.isITAC || useMainStore().policy.noCoverage;
|
||||
return this.isITAC || useMainStore().isNoComp;
|
||||
},
|
||||
isMobileOnly() {
|
||||
return this.isServiceableMobile && !this.isServiceableInshop;
|
||||
|
|
|
|||
|
|
@ -171,10 +171,10 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isITAC() {
|
||||
return useMainStore().policy.isITAC;
|
||||
return useMainStore().isITAC;
|
||||
},
|
||||
isItacOrNoComp() {
|
||||
return useMainStore().policy.isITAC || useMainStore().policy.noCoverage;
|
||||
return this.isITAC || useMainStore().isNoComp;
|
||||
},
|
||||
mobileLocationLinkPromptText() {
|
||||
return this.getCmsContent(this.linkWidgetName, 'HeaderText');
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
import tpaConfirmation from '@/layouts/tpa-confirmation/tpa-confirmation.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
|
||||
|
|
@ -187,8 +188,8 @@ describe('TPAConfirmation.vue', () => {
|
|||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: false }
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -203,8 +204,8 @@ describe('TPAConfirmation.vue', () => {
|
|||
const currentDeductible = '500';
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED
|
||||
},
|
||||
currentDeductible
|
||||
}
|
||||
|
|
@ -219,72 +220,51 @@ describe('TPAConfirmation.vue', () => {
|
|||
});
|
||||
describe('Methods', () => {
|
||||
describe('getCustomValueFromString', () => {
|
||||
describe('with argument deductibleAboveZero', () => {
|
||||
test.each([
|
||||
[false],
|
||||
[true]
|
||||
])(
|
||||
'returns false when isVerified %p and currentDeductible is zero',
|
||||
(isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 0
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, 0],
|
||||
[false, coverageStatuses.PENDING, 500],
|
||||
[false, coverageStatuses.NO_COVERAGE, 0],
|
||||
[false, coverageStatuses.NO_COVERAGE, 500],
|
||||
[false, coverageStatuses.VERIFIED, 0],
|
||||
[true, coverageStatuses.VERIFIED, 500]
|
||||
])('with argument deductibleAboveZero', (expected, status, deductible) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} and currentDeductible is ${deductible}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: deductible
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(false);
|
||||
}
|
||||
);
|
||||
test.each([
|
||||
[true, true],
|
||||
[false, false]
|
||||
])(
|
||||
'returns %p when isVerified %p and currentDeductible is not zero',
|
||||
(expected, isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 500
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('with argument zeroDeductible', () => {
|
||||
test.each([
|
||||
[true, true],
|
||||
[false, false]
|
||||
])(
|
||||
'returns %p when isVerified is %p currentDeductible is zero',
|
||||
(expected, isVerified) => {
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, 0],
|
||||
[false, coverageStatuses.PENDING, 500],
|
||||
[false, coverageStatuses.NO_COVERAGE, 0],
|
||||
[false, coverageStatuses.NO_COVERAGE, 500],
|
||||
[true, coverageStatuses.VERIFIED, 0],
|
||||
[false, coverageStatuses.VERIFIED, 500]
|
||||
])('with argument zeroDeductible', (expected, status, deductible) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} and currentDeductible is ${deductible}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: 0
|
||||
currentDeductible: deductible
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
@ -295,48 +275,23 @@ describe('TPAConfirmation.vue', () => {
|
|||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
test.each([
|
||||
[false],
|
||||
[true]
|
||||
])(
|
||||
'returns false when isVerified is %p currentDeductible is not zero',
|
||||
(isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 250
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'zeroDeductible';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('with argument verifyingCoverage', () => {
|
||||
test.each([
|
||||
[true, false],
|
||||
[false, true]
|
||||
])(
|
||||
'with argument verifyingCoverage returns %p when isVerified %p',
|
||||
(expected, isVerified) => {
|
||||
describe.each([
|
||||
[true, coverageStatuses.PENDING],
|
||||
[true, coverageStatuses.NO_COVERAGE],
|
||||
[false, coverageStatuses.VERIFIED]
|
||||
])('with argument zeroDeductible', (expected, status) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: 26
|
||||
currentDeductible: 123
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
@ -347,8 +302,8 @@ describe('TPAConfirmation.vue', () => {
|
|||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('setBailoutInfo', () => {
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ export default {
|
|||
return this.toDisplayPhoneNumber(useMainStore().order.serviceLocation.provider.phoneNumber);
|
||||
},
|
||||
isVerified() {
|
||||
return useMainStore().order.payment.insuranceCoverage.isVerified;
|
||||
return useMainStore().isVerified;
|
||||
},
|
||||
carrierName() {
|
||||
return this.mainStore.issConfig.clientName;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@ import { createTestingPinia } from '@pinia/testing';
|
|||
import tpaSubmit from '@/layouts/tpa-submit/tpa-submit.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { useMainStore } from '@/store';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import widgetFields from '@/constants/cms-widget-fields.js';
|
||||
import { toTitleCase, formatAddress, toDisplayPhoneNumber } from '@/helpers/text-helper.js';
|
||||
import { toTitleCase, formatAddress, toDisplayPhoneNumber, formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||
import { getDamageDisplayContent } from '@/helpers/damage-review-content-generator.js';
|
||||
import baseMixin from '@/mixins/base-mixin';
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
|
|
@ -76,6 +77,7 @@ beforeEach(() => {
|
|||
formatAddress.mockClear();
|
||||
toDisplayPhoneNumber.mockClear();
|
||||
getDamageDisplayContent.mockClear();
|
||||
formatAmountInDollars.mockClear();
|
||||
});
|
||||
|
||||
describe('tpa-submit', () => {
|
||||
|
|
@ -557,22 +559,26 @@ describe('tpa-submit', () => {
|
|||
// Assert
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
test.each([
|
||||
[true, true],
|
||||
[false, false]
|
||||
])('isVerified returns %p when store value %p', (expected, storeValue) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: storeValue }
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.isVerified).toBe(expected);
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING],
|
||||
[true, coverageStatuses.VERIFIED],
|
||||
[false, coverageStatuses.NO_COVERAGE]
|
||||
])('isVerified', (expected, status) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.isVerified).toBe(expected);
|
||||
});
|
||||
});
|
||||
test.each([
|
||||
[5, 5],
|
||||
|
|
@ -592,160 +598,100 @@ describe('tpa-submit', () => {
|
|||
// Assert
|
||||
expect(wrapper.vm.currentDeductible).toBe(expected);
|
||||
});
|
||||
describe('deductible box value', () => {
|
||||
test('returns "Verifying coverage" when isVerified false', () => {
|
||||
describe.each([
|
||||
['Verifying coverage', coverageStatuses.PENDING],
|
||||
['$123.46', coverageStatuses.VERIFIED],
|
||||
['Verifying coverage', coverageStatuses.NO_COVERAGE]
|
||||
])('deductibleBoxValue', (expected, status) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: false }
|
||||
}
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: 123.456
|
||||
}
|
||||
};
|
||||
formatAmountInDollars.mockReturnValue('$123.46');
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const expected = 'Verifying coverage';
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.deductibleBoxValue).toBe(expected);
|
||||
});
|
||||
test('returns in dollars response when isVerified true', () => {
|
||||
// Arrange
|
||||
const currentDeductible = '123094';
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified: true }
|
||||
},
|
||||
currentDeductible
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const notExpected = 'Verifying coverage';
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.deductibleBoxValue).not.toBe(notExpected);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('methods', () => {
|
||||
describe('getCustomValueFromString', () => {
|
||||
describe('with argument deductibleAboveZero', () => {
|
||||
test.each([
|
||||
[false],
|
||||
[true]
|
||||
])(
|
||||
'returns false when isVerified %p and currentDeductible is zero',
|
||||
(isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 0
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(false);
|
||||
}
|
||||
);
|
||||
test.each([
|
||||
[true, true],
|
||||
[false, false]
|
||||
])(
|
||||
'returns %p when isVerified %p and currentDeductible is not zero',
|
||||
(expected, isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 10
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
describe('with argument zeroDeductible', () => {
|
||||
test.each([
|
||||
[true, true],
|
||||
[false, false]
|
||||
])(
|
||||
'returns %p when isVerified is %p currentDeductible is zero',
|
||||
(expected, isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 0
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'zeroDeductible';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
test.each([
|
||||
[false],
|
||||
[true]
|
||||
])(
|
||||
'returns false when isVerified is %p currentDeductible is not zero',
|
||||
(isVerified) => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
},
|
||||
currentDeductible: 76
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'zeroDeductible';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
test.each([
|
||||
[true, false],
|
||||
[false, true]
|
||||
])(
|
||||
'with argument verifyingCoverage returns %p when isVerified %p',
|
||||
(expected, isVerified) => {
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, 0],
|
||||
[false, coverageStatuses.PENDING, 100],
|
||||
[false, coverageStatuses.VERIFIED, 0],
|
||||
[true, coverageStatuses.VERIFIED, 100],
|
||||
[false, coverageStatuses.NO_COVERAGE, 0],
|
||||
[false, coverageStatuses.NO_COVERAGE, 100]
|
||||
])('with argument deductibleAboveZero', (expected, status, deductible) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} and currentDeductible is ${deductible}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
payment: {
|
||||
insuranceCoverage: { isVerified }
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: 26
|
||||
currentDeductible: deductible
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'deductibleAboveZero';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, 0],
|
||||
[false, coverageStatuses.PENDING, 100],
|
||||
[true, coverageStatuses.VERIFIED, 0],
|
||||
[false, coverageStatuses.VERIFIED, 100],
|
||||
[false, coverageStatuses.NO_COVERAGE, 0],
|
||||
[false, coverageStatuses.NO_COVERAGE, 100]
|
||||
])('with argument zeroDeductible', (expected, status, deductible) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} and currentDeductible is ${deductible}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: deductible
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
const argument = 'zeroDeductible';
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getCustomValueFromString(argument);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
[true, coverageStatuses.PENDING],
|
||||
[false, coverageStatuses.VERIFIED],
|
||||
[true, coverageStatuses.NO_COVERAGE]
|
||||
])('with argument verifyingCoverage', (expected, status) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)}`, () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
@ -756,8 +702,9 @@ describe('tpa-submit', () => {
|
|||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('with unknown argument returns null', () => {
|
||||
// Arrange
|
||||
const initialStore = {
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ export default {
|
|||
);
|
||||
},
|
||||
isVerified() {
|
||||
return useMainStore().order.payment.insuranceCoverage.isVerified;
|
||||
return useMainStore().isVerified;
|
||||
},
|
||||
currentDeductible() {
|
||||
return useMainStore().order.currentDeductible;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import applicationConfig from '@/constants/application-config';
|
|||
import { useMainStore } from '@/store';
|
||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import globalMethods from '@/global-methods';
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
|
|
@ -19,6 +21,9 @@ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
|||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
fetchCmsContentForPage: jest.fn()
|
||||
}));
|
||||
jest.mock('@/global-methods', () => ({
|
||||
callHttpClient: jest.fn()
|
||||
}));
|
||||
|
||||
/** @ignore */
|
||||
function setupMocks({
|
||||
|
|
@ -167,13 +172,9 @@ describe('navigation', () => {
|
|||
test('Navigation should not happen', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: false
|
||||
}
|
||||
}));
|
||||
wrapper.vm.mainStore.getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
wrapper.vm.mainStore.applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.reject());
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -208,85 +209,13 @@ describe('navigation', () => {
|
|||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
});
|
||||
test('if isCoverageEnabled is false, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().issConfig.isCoverageEnabled = false;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if isCoverageEnabled is true, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().issConfig.isCoverageEnabled = true;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is true, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.coverageLookupAttempts = 11;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is false, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.coverageLookupAttempts = 10;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled();
|
||||
});
|
||||
test('if policy and vehicles are found but no duplicates, navigate to policy-vehicle page', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
useMainStore().applicationUser.duplicateOrders = [];
|
||||
useMainStore().order.policy.policyLookupSuccessful = true;
|
||||
useMainStore().order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
useMainStore().order.policy.vehicles = [
|
||||
{ vin: 'TEST_VIN' },
|
||||
{ vin: 'TEST_VIN2' }
|
||||
|
|
@ -314,7 +243,7 @@ describe('navigation', () => {
|
|||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
useMainStore().applicationUser.duplicateOrders = [];
|
||||
useMainStore().order.policy.policyLookupSuccessful = true;
|
||||
useMainStore().order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
useMainStore().order.policy.vehicles = [];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
|
|
@ -339,7 +268,7 @@ describe('navigation', () => {
|
|||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
useMainStore().applicationUser.duplicateOrders = [];
|
||||
useMainStore().order.policy.policyLookupSuccessful = true;
|
||||
useMainStore().order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
useMainStore().order.policy.vehicles = null;
|
||||
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
|
|
@ -364,7 +293,7 @@ describe('navigation', () => {
|
|||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
useMainStore().order.policy.policyLookupSuccessful = false;
|
||||
useMainStore().order.insuranceCoverage.coverageType = coverageType.NONE;
|
||||
useMainStore().applicationUser.duplicateOrders = [];
|
||||
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
|
|
|
|||
|
|
@ -174,8 +174,6 @@ import states from '@/constants/states';
|
|||
import globalRules from '@/constants/global-rules';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import MaskaFormattedMasks from '@/constants/maska-masks';
|
||||
import globalMethods from '@/global-methods';
|
||||
import { endpoints } from '@/constants/endpoints';
|
||||
|
||||
// define validation rules
|
||||
defineRule(
|
||||
|
|
@ -294,90 +292,35 @@ export default {
|
|||
isDateOfLossDisabled() {
|
||||
return !!this.mainStore.issConfig.disabledFields.dateOfLoss;
|
||||
},
|
||||
isCoverageEnabled() {
|
||||
return this.mainStore.issConfig.isCoverageEnabled;
|
||||
},
|
||||
maxCoverageLookupAttemptsReached() {
|
||||
return this.mainStore.applicationUser.coverageLookupAttempts >= 11;
|
||||
},
|
||||
phoneMask() {
|
||||
return MaskaFormattedMasks.PHONE_NUMBER;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async forwardButtonAction() {
|
||||
await this.mainStore
|
||||
.validateZip({ zip: this.welcomePageModel.policyZipCode })
|
||||
.then(async (zipInfo) => {
|
||||
if (zipInfo?.data?.isValid === true) {
|
||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||
|
||||
this.mainStore.order.serviceLocation.zipCodeCtu =
|
||||
zipInfo.data.zipCodeCtu?.toString();
|
||||
|
||||
const billToInfo = await this.getBillToInfo(
|
||||
this.mainStore.issConfig.parentAccountNumber,
|
||||
this.mainStore.order.serviceLocation.zipCodeCtu
|
||||
);
|
||||
|
||||
if (billToInfo !== null) {
|
||||
this.mainStore.issConfig.billToAccountNumber =
|
||||
billToInfo.billToAccountNumber;
|
||||
this.mainStore.issConfig.itacCashBillToNumber =
|
||||
billToInfo.itacCashBillToNumber;
|
||||
this.mainStore.issConfig.itacFnrBillToNumber =
|
||||
billToInfo.itacFnrBillToNumber;
|
||||
}
|
||||
|
||||
await this.mainStore
|
||||
.getDuplicateReferrals()
|
||||
.then(
|
||||
() => {},
|
||||
() => {}
|
||||
)
|
||||
.finally(async () => {
|
||||
if (
|
||||
this.isCoverageEnabled
|
||||
&& !this.maxCoverageLookupAttemptsReached
|
||||
) {
|
||||
await this.mainStore
|
||||
.getCoveragePolicyInfo()
|
||||
?.then(
|
||||
() => {},
|
||||
() => {}
|
||||
);
|
||||
} else {
|
||||
this.mainStore.order.policy.policyLookupSuccessful = false;
|
||||
}
|
||||
this.navigateForward();
|
||||
});
|
||||
} else {
|
||||
this.displayInvalidZipAlert = true;
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
}
|
||||
});
|
||||
},
|
||||
async getBillToInfo(parentAccountNumber, providerNumber) {
|
||||
try {
|
||||
const payload = {
|
||||
parentAccountNumber: parentAccountNumber.toString(),
|
||||
providerNumber: providerNumber.toString(),
|
||||
billToSelectionCriteria: {
|
||||
typeOfClaim: 'GLASS ONLY',
|
||||
lineOfBusiness: 'PERSONAL'
|
||||
}
|
||||
};
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetBillToInfo.method,
|
||||
endpoint: endpoints.GetBillToInfo.url,
|
||||
payload
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.error(`Error Status Code: ${err.data?.status}: ${err.data?.title}`);
|
||||
return null;
|
||||
await this.configureZip();
|
||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||
await this.mainStore.getBillToInfo();
|
||||
await this.mainStore.getDuplicateReferrals();
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// TODO: Bailout?
|
||||
} finally {
|
||||
if (!this.displayInvalidZipAlert) {
|
||||
this.navigateForward();
|
||||
}
|
||||
}
|
||||
},
|
||||
async configureZip() {
|
||||
try {
|
||||
await this.mainStore.validateZip({ zip: this.welcomePageModel.policyZipCode });
|
||||
return Promise.resolve();
|
||||
} catch (e) {
|
||||
this.displayInvalidZipAlert = true;
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
return Promise.reject(e);
|
||||
}
|
||||
},
|
||||
navigateForward() {
|
||||
|
|
@ -388,7 +331,7 @@ export default {
|
|||
{},
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
} else if (this.mainStore.policy.policyLookupSuccessful) {
|
||||
} else if (this.mainStore.isPolicyLookupSuccessful) {
|
||||
if (this.mainStore.order.policy.vehicles?.length > 0 ?? false) {
|
||||
// navigate to policy-vehicles page
|
||||
this.$router.navigate(
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import bailoutCode from '@/constants/bailoutCode';
|
|||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import { getLineItemsFlattened } from '@/helpers/line-items-helper';
|
||||
import { buildQueryStringParameterFromArrayOfComplexObjects, getLineItemQueryString, getTaxLineItemQueryString } from '@/helpers/querystring-helper';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
const storeId = 'main';
|
||||
|
||||
|
|
@ -99,13 +100,10 @@ export const getDefaultState = () => ({
|
|||
damageState: null,
|
||||
damageCity: null,
|
||||
isDamageGlassOnly: null,
|
||||
policyLookupSuccessful: null,
|
||||
noCoverage: null,
|
||||
deductible: {
|
||||
repair: null, // numerical value; how much customer owes on deductible in repair case
|
||||
replace: null // numerical value; how much customer owes on deductible in replace case,
|
||||
},
|
||||
isITAC: false,
|
||||
vehicles: [],
|
||||
endorsements: [],
|
||||
endorsementQuestionAnswers: [],
|
||||
|
|
@ -156,12 +154,12 @@ export const getDefaultState = () => ({
|
|||
vaps: null,
|
||||
serverData: null
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.NONE,
|
||||
claimNumber: null
|
||||
},
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: false,
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
claimNumber: null
|
||||
},
|
||||
parentAccountNumber: 0,
|
||||
isPayInAdvance: null,
|
||||
payInAdvanceType: null,
|
||||
|
|
@ -289,31 +287,17 @@ export const useMainStore = defineStore({
|
|||
isDropOffAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF,
|
||||
isInShopAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.IN_SHOP,
|
||||
isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired,
|
||||
isClaimAlreadyRegistered: (state) => state.order.payment.insuranceCoverage.claimNumber !== null,
|
||||
isClaimAlreadyRegistered: (state) => state.order.insuranceCoverage.claimNumber !== null,
|
||||
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
|
||||
bailoutCode: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE]?.bailoutCode,
|
||||
isNoComp: (s) => !!s.order.policy.noCoverage,
|
||||
isITAC: (state) => !!state.order.policy.isITAC,
|
||||
isUnverified: (s) => {
|
||||
const { payment, currentDeductible, policy } = s.order;
|
||||
const { policyLookupSuccessful } = policy;
|
||||
const registerClaimSuccessful = !!payment.insuranceCoverage.isVerified;
|
||||
if (!policyLookupSuccessful) {
|
||||
return true;
|
||||
}
|
||||
if (s.isNoComp && !s.issConfig.enableNoCompQuote) {
|
||||
return true;
|
||||
}
|
||||
if (!s.isNoComp && currentDeductible == null) {
|
||||
return true;
|
||||
}
|
||||
if (s.isClaimRegistrationRequired && !registerClaimSuccessful) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// TODO condense verification logic
|
||||
isVerifiedCoverageStatus: (state) => state.order.payment.insuranceCoverage.coverageStatus === coverageStatuses.VERIFIED,
|
||||
isPolicyLookupSuccessful: (s) => s.order.insuranceCoverage.coverageType !== coverageType.NONE,
|
||||
isNoComp: (s) => s.order.insuranceCoverage.coverageType === coverageType.NO_COMP,
|
||||
isNoCompQuoteEnabled: (s) => s.issConfig.enableNoCompQuote,
|
||||
isITAC: (state) => state.order.insuranceCoverage.coverageType === coverageType.ITAC,
|
||||
isDeductible: (state) => state.order.insuranceCoverage.coverageType === coverageType.Deductible,
|
||||
isUnverified: (s) => s.order.insuranceCoverage.coverageStatus !== coverageStatuses.VERIFIED,
|
||||
isVerified: (state) => state.order.insuranceCoverage.coverageStatus === coverageStatuses.VERIFIED,
|
||||
isPendingClaimRegistration: (state) => state.order.insuranceCoverage.coverageStatus === coverageStatuses.PENDING,
|
||||
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
|
||||
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);
|
||||
return matchedEvent?.eventValue;
|
||||
|
|
@ -403,7 +387,7 @@ export const useMainStore = defineStore({
|
|||
funnelServiceZipCodeCtu: ctuToUse,
|
||||
funnelParentAccountNumber: s.order.parentAccountNumber,
|
||||
funnelProviderNumber: s.order.serviceLocation.provider.providerNumber,
|
||||
funnelIsCoverageVerified: s.order.payment.insuranceCoverage.isVerified,
|
||||
funnelIsCoverageVerified: s.isVerified,
|
||||
funnelHasRecalibrationPart: getHasRecalibrationPart(s),
|
||||
funnelSelectedMultiGlass: s.order.damage.glassToReplace?.length > 1,
|
||||
funnelSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects(s.order.damage.glassToReplace, 'glassLocation')
|
||||
|
|
@ -539,13 +523,20 @@ export const useMainStore = defineStore({
|
|||
};
|
||||
}
|
||||
},
|
||||
getCoveragePolicyInfo() {
|
||||
const { order } = this;
|
||||
async getCoveragePolicyInfo() {
|
||||
const { order, issConfig, applicationUser } = this;
|
||||
const { policy } = order;
|
||||
|
||||
if (!issConfig.isCoverageEnabled || applicationUser.coverageLookupAttempts > 10) {
|
||||
this.updateCoverageType(coverageType.NONE);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this.applicationUser.coverageAttempts += 1;
|
||||
console.log(`Coverage lookup attempt #${this.applicationUser.coverageAttempts}. Max attempts allowed: 10.`);
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
|
||||
try {
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.CoveragePolicyInfo.method,
|
||||
endpoint: endpoints.CoveragePolicyInfo.url,
|
||||
payload: {
|
||||
|
|
@ -555,40 +546,45 @@ export const useMainStore = defineStore({
|
|||
zipCode: policy.policyZipCode,
|
||||
referralCorrelationId: order.referralCorrelationId
|
||||
}
|
||||
}).then((r) => {
|
||||
const responsePolicy = r?.data?.policies?.[0];
|
||||
policy.policyLookupSuccessful = !!responsePolicy;
|
||||
if (policy.policyLookupSuccessful) {
|
||||
const insured = responsePolicy.insureds?.[0];
|
||||
|
||||
// populate policy holder details from policy lookup
|
||||
order.customer.address.streetAddress = insured?.address;
|
||||
order.customer.address.city = insured?.city;
|
||||
order.customer.address.state = insured?.state;
|
||||
order.customer.address.zipCode = insured?.zipCode?.toString();
|
||||
order.customer.firstName = insured?.firstName;
|
||||
order.customer.lastName = insured?.lastName;
|
||||
|
||||
// populate additional fields
|
||||
order.serviceLocation.zipCode = insured?.zipCode?.toString();
|
||||
order.policy.policyData = responsePolicy.policyData;
|
||||
|
||||
// populate vehicles
|
||||
order.policy.vehicles = responsePolicy.vehicles ?? [];
|
||||
}
|
||||
return resolve(r);
|
||||
}).catch((error) => {
|
||||
policy.policyLookupSuccessful = false;
|
||||
return reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
const responsePolicy = response?.data?.policies?.[0];
|
||||
if (responsePolicy) {
|
||||
this.updateCoverageType(coverageType.Deductible);
|
||||
const insured = responsePolicy.insureds?.[0];
|
||||
|
||||
// populate policy holder details from policy lookup
|
||||
order.customer.address.streetAddress = insured?.address;
|
||||
order.customer.address.city = insured?.city;
|
||||
order.customer.address.state = insured?.state;
|
||||
order.customer.address.zipCode = insured?.zipCode?.toString();
|
||||
order.customer.firstName = insured?.firstName;
|
||||
order.customer.lastName = insured?.lastName;
|
||||
|
||||
// populate additional fields
|
||||
order.serviceLocation.zipCode = insured?.zipCode?.toString();
|
||||
order.policy.policyData = responsePolicy.policyData;
|
||||
|
||||
// populate vehicles
|
||||
order.policy.vehicles = responsePolicy.vehicles ?? [];
|
||||
} else {
|
||||
this.updateCoverageType(coverageType.NONE);
|
||||
}
|
||||
return Promise.resolve();
|
||||
} catch (e) {
|
||||
this.updateCoverageType(coverageType.NONE);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
},
|
||||
updateCoverageStatus(newStatus) {
|
||||
this.order.payment.insuranceCoverage.coverageStatus = newStatus;
|
||||
updateCoverageStatus(status) {
|
||||
this.order.insuranceCoverage.coverageStatus = status;
|
||||
},
|
||||
updateCoverageType(type) {
|
||||
this.order.insuranceCoverage.coverageType = type;
|
||||
},
|
||||
registerClaim() {
|
||||
const nonNumberCharRegex = /[^0-9]/g;
|
||||
const { order } = this;
|
||||
const { order, isITAC } = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
method: endpoints.RegisterClaim.method,
|
||||
|
|
@ -598,7 +594,7 @@ export const useMainStore = defineStore({
|
|||
referralCorrelationId: this.order.referralCorrelationId,
|
||||
accountNumber: this.issConfig.parentAccountNumber?.toString() ?? '',
|
||||
policyData: this.order.policy.policyData,
|
||||
isItac: this.order.policy.isITAC,
|
||||
isItac: isITAC,
|
||||
insured: {
|
||||
firstName: this.order.customer.firstName,
|
||||
lastName: this.order.customer.lastName,
|
||||
|
|
@ -648,18 +644,17 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
}).then((response) => {
|
||||
const registerClaimFailed = response.data.isError;
|
||||
order.payment.insuranceCoverage.isVerified = !registerClaimFailed;
|
||||
order.payment.insuranceCoverage.claimNumber = null;
|
||||
if (this.policy?.noCoverage ?? false) {
|
||||
this.updateCoverageStatus(coverageStatuses.NO_COMP);
|
||||
} else if (!registerClaimFailed) {
|
||||
order.insuranceCoverage.claimNumber = null;
|
||||
if (!registerClaimFailed) {
|
||||
this.updateCoverageStatus(coverageStatuses.VERIFIED);
|
||||
this.order.payment.insuranceCoverage.claimNumber = response.data.claimNumber;
|
||||
this.order.insuranceCoverage.claimNumber = response.data.claimNumber;
|
||||
} else {
|
||||
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
||||
}
|
||||
return resolve(response);
|
||||
}, (error) => {
|
||||
this.order.payment.insuranceCoverage.isVerified = false;
|
||||
this.order.payment.insuranceCoverage.claimNumber = null;
|
||||
this.updateCoverageStatus(coverageStatuses.NO_COVERAGE);
|
||||
this.order.insuranceCoverage.claimNumber = null;
|
||||
return reject(error);
|
||||
});
|
||||
});
|
||||
|
|
@ -694,7 +689,7 @@ export const useMainStore = defineStore({
|
|||
status: this.order.policy.status,
|
||||
originalDeductible: this.order.originalDeductible,
|
||||
currentDeductible: this.order.currentDeductible,
|
||||
noCoverage: this.order.policy.noCoverage,
|
||||
noCoverage: false,
|
||||
isRepair: this.order.damage.isRepair,
|
||||
policyNumber: this.order.policy.policyNumber,
|
||||
insuredFirstName: this.order.customer.firstName,
|
||||
|
|
@ -703,7 +698,7 @@ export const useMainStore = defineStore({
|
|||
policyVehicleId: this.order.vehicle.policyVehicleId?.toString() ?? '',
|
||||
vehicleVin: this.order.vehicle.vin,
|
||||
policyData: this.order.policy.policyData,
|
||||
isItac: this.order.policy.isITAC
|
||||
isItac: this.isITAC
|
||||
}
|
||||
}).then((r) => {
|
||||
this.order.policy.policyData = r.data.policyData;
|
||||
|
|
@ -1053,7 +1048,7 @@ export const useMainStore = defineStore({
|
|||
const zipCodeToUse = this.order.serviceLocation.zipCode;
|
||||
if (!this.order.serviceLocation.zipCodeCtu) {
|
||||
const zipInfo = await this.validateZip({ zip: zipCodeToUse });
|
||||
this.order.serviceLocation.zipCodeCtu = zipInfo.data.zipCodeCtu;
|
||||
this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu;
|
||||
}
|
||||
const ctuToUse = this.order.serviceLocation.zipCodeCtu;
|
||||
const deductibleToUse = this.order.currentDeductible ?? 0;
|
||||
|
|
@ -1217,7 +1212,7 @@ export const useMainStore = defineStore({
|
|||
|
||||
saveSession({ submitAfterSave }) {
|
||||
const { vehicle, damage, policy, customer, contactInfo, payment,
|
||||
lineItems, serviceLocation, schedule } = this.order;
|
||||
lineItems, serviceLocation, schedule, insuranceCoverage } = this.order;
|
||||
|
||||
// We don't want to save the session for a loaded session until the car ID is set
|
||||
if (this.order.loadedFromDupeCheck && !vehicle.carId) {
|
||||
|
|
@ -1272,12 +1267,11 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
policyNumber: policy.policyNumber,
|
||||
policyZipCode: policy.policyZipCode,
|
||||
noCoverage: policy.noCoverage,
|
||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||
originalDeductible: this.order.originalDeductible,
|
||||
currentDeductible: this.order.currentDeductible,
|
||||
IsItac: this.order.policy.isITAC,
|
||||
OemEndorsement: policy.endorsements?.indexOf('OEM Approved') !== -1 ?? false
|
||||
OemEndorsement: policy.endorsements?.indexOf('OEM Approved') !== -1 ?? false,
|
||||
noCoverage: this.isNoComp,
|
||||
isItac: this.isITAC
|
||||
},
|
||||
customer: {
|
||||
address: {
|
||||
|
|
@ -1301,18 +1295,23 @@ export const useMainStore = defineStore({
|
|||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageType: insuranceCoverage.coverageType,
|
||||
coverageStatus: insuranceCoverage.coverageStatus,
|
||||
claimNumber: insuranceCoverage.claimNumber
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
isVerified: payment.insuranceCoverage?.isVerified ?? false,
|
||||
coverageStatus: payment.insuranceCoverage?.coverageStatus,
|
||||
claimNumber: payment.insuranceCoverage?.claimNumber
|
||||
},
|
||||
parentAccountNumber: this.issConfig.parentAccountNumber,
|
||||
paypalToken: payment.paypalToken,
|
||||
isPaypal: payment.payInAdvanceType === paymentMethods.PAYPAL,
|
||||
isCreditCard: payment.payInAdvanceType === paymentMethods.CREDIT_CARD,
|
||||
isAfterpay: payment.payInAdvanceType === paymentMethods.AFTERPAY,
|
||||
CCToken: payment.creditCardToken
|
||||
CCToken: payment.creditCardToken,
|
||||
insuranceCoverage: {
|
||||
isVerified: this.isVerified,
|
||||
coverageStatus: this.isNoComp ? coverageStatuses.NO_COVERAGE : this.isVerified ? coverageStatuses.VERIFIED : coverageStatuses.PENDING,
|
||||
claimNumber: insuranceCoverage.claimNumber
|
||||
}
|
||||
},
|
||||
serviceLocation: {
|
||||
address: {
|
||||
|
|
@ -1392,7 +1391,7 @@ export const useMainStore = defineStore({
|
|||
return response;
|
||||
}
|
||||
|
||||
if (order.policy.policyLookupSuccessful) {
|
||||
if (this.isPolicyLookupSuccessful) {
|
||||
order.customer.emailAddress = data.customer?.emailAddress;
|
||||
order.customer.firstName = data.customer?.firstName;
|
||||
order.customer.lastName = data.customer?.lastName;
|
||||
|
|
@ -1411,9 +1410,16 @@ export const useMainStore = defineStore({
|
|||
order.contactInfo.alternativePhone = data?.customer?.alternativePhone;
|
||||
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
||||
|
||||
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
|
||||
order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus;
|
||||
order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber;
|
||||
if (data.insuranceCoverage) {
|
||||
order.insuranceCoverage.coverageType = data?.insuranceCoverage?.coverageType;
|
||||
order.insuranceCoverage.coverageStatus = data?.insuranceCoverage?.coverageStatus;
|
||||
order.insuranceCoverage.claimNumber = data?.insuranceCoverage?.claimNumber;
|
||||
} else if (data?.payment?.insuranceCoverage) {
|
||||
if (data?.payment?.insuranceCoverage?.isVerified) {
|
||||
order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
||||
}
|
||||
order.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber;
|
||||
}
|
||||
|
||||
if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) {
|
||||
order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber;
|
||||
|
|
@ -1422,18 +1428,17 @@ export const useMainStore = defineStore({
|
|||
if (vehicle) {
|
||||
const vehicleResponse = await this.lookupVehicleByVin(vehicle.vin);
|
||||
if (vehicleResponse) {
|
||||
Object.assign(
|
||||
vehicleResponse.data,
|
||||
{
|
||||
policyVehicleId: vehicle.id,
|
||||
vin: vehicle.vin,
|
||||
noCoverage: noCoverageForSelectedVehicle(vehicle),
|
||||
deductible: deductibleForSelectedVehicle(vehicle),
|
||||
repairWaived: repairWaivedForSelectedVehicle(vehicle),
|
||||
endorsements: endorsementsForSelectedVehicle(vehicle)
|
||||
}
|
||||
);
|
||||
this.updateVehicle(vehicleResponse.data);
|
||||
this.updateVehicle({
|
||||
...vehicleResponse.data,
|
||||
policyVehicleId: vehicle.id,
|
||||
vin: vehicle.vin
|
||||
});
|
||||
this.updateVehicleCoverage({
|
||||
noCoverage: noCoverageForSelectedVehicle(vehicle),
|
||||
deductible: deductibleForSelectedVehicle(vehicle),
|
||||
repairWaived: repairWaivedForSelectedVehicle(vehicle),
|
||||
endorsements: endorsementsForSelectedVehicle(vehicle)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1605,9 +1610,9 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
resetInsurance() {
|
||||
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
this.order.payment.insuranceCoverage.claimNumber = null;
|
||||
this.order.payment.insuranceCoverage.isVerified = false;
|
||||
this.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
this.order.insuranceCoverage.coverageType = coverageType.NONE;
|
||||
this.order.insuranceCoverage.claimNumber = null;
|
||||
},
|
||||
|
||||
updateSupportingItems(partsData) {
|
||||
|
|
@ -1629,7 +1634,7 @@ export const useMainStore = defineStore({
|
|||
|
||||
updateMobileFee(fee) {
|
||||
// Mobile Fee is only added for NO COMP or ITAC
|
||||
if (fee && !this.isUnverified && (this.isNoComp || this.isITAC)) {
|
||||
if (fee && this.isVerified && (this.isNoComp || this.isITAC)) {
|
||||
this.addPartTypeFeeItem(fee, partTypeStrings.MOBILE_FEE);
|
||||
} else {
|
||||
this.addPartTypeFeeItem(null, partTypeStrings.MOBILE_FEE);
|
||||
|
|
@ -1638,7 +1643,7 @@ export const useMainStore = defineStore({
|
|||
|
||||
updateRecycleFee(fee) {
|
||||
// Recycle Fee is only added for NO COMP or ITAC and has Windshield Replacement
|
||||
if (fee && !this.isUnverified && (this.isNoComp || this.isITAC) && this.hasWindshieldReplacement) {
|
||||
if (fee && this.isVerified && (this.isNoComp || this.isITAC) && this.hasWindshieldReplacement) {
|
||||
this.addPartNumberFeeItem(fee, partNumberStrings.RECYCLE_FEE);
|
||||
} else {
|
||||
this.addPartNumberFeeItem(null, partNumberStrings.RECYCLE_FEE);
|
||||
|
|
@ -1698,22 +1703,33 @@ export const useMainStore = defineStore({
|
|||
this.resetBailout();
|
||||
}
|
||||
|
||||
// These could be undefined
|
||||
this.order.policy.noCoverage = vehicle.noCoverage;
|
||||
const currentCoverageStatus = vehicle.noCoverage ? coverageStatuses.NO_COMP : coverageStatuses.PENDING;
|
||||
this.updateCoverageStatus(currentCoverageStatus);
|
||||
this.order.policy.deductible.replace = vehicle.deductible;
|
||||
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible;
|
||||
this.order.policy.endorsements = vehicle?.endorsements;
|
||||
|
||||
// TODO logic should be more complicated later on
|
||||
this.order.originalDeductible = vehicle.deductible;
|
||||
this.order.currentDeductible = vehicle.deductible;
|
||||
|
||||
this.updateSupportingItems(null);
|
||||
this.updateVaps(null);
|
||||
},
|
||||
|
||||
updateVehicleCoverage(coverage) {
|
||||
if (coverage.noCoverage) {
|
||||
if (this.isNoCompQuoteEnabled) {
|
||||
this.updateCoverageType(coverageType.NO_COMP);
|
||||
} else {
|
||||
this.updateCoverageType(coverageType.NONE);
|
||||
}
|
||||
} else {
|
||||
this.updateCoverageType(coverageType.Deductible);
|
||||
}
|
||||
|
||||
if (!this.isClaimRegistrationRequired) {
|
||||
this.updateCoverageStatus(coverageStatuses.VERIFIED);
|
||||
}
|
||||
|
||||
this.order.policy.deductible.replace = coverage.deductible;
|
||||
this.order.policy.deductible.repair = coverage?.repairWaived ?? false ? 0 : coverage.deductible;
|
||||
this.order.policy.endorsements = coverage?.endorsements;
|
||||
|
||||
// TODO logic should be more complicated later on
|
||||
this.order.originalDeductible = coverage.deductible;
|
||||
this.order.currentDeductible = coverage.deductible;
|
||||
},
|
||||
updateVehicleVin(vin) {
|
||||
this.order.vehicle.vin = vin;
|
||||
},
|
||||
|
|
@ -1740,7 +1756,6 @@ export const useMainStore = defineStore({
|
|||
this.order.policy.damageCause = null;
|
||||
this.order.policy.damageCity = null;
|
||||
this.order.policy.damageState = null;
|
||||
this.order.policy.isITAC = false;
|
||||
},
|
||||
|
||||
resetCustomer() {
|
||||
|
|
@ -1944,9 +1959,6 @@ export const useMainStore = defineStore({
|
|||
this.order.customer.lastName = customerQuestions.lastName;
|
||||
this.order.serviceLocation.zipCode = customerQuestions.addressQuestions.zipCode;
|
||||
},
|
||||
updatePolicyITACFlag(isITAC) {
|
||||
this.order.policy.isITAC = isITAC;
|
||||
},
|
||||
updateIsSafeliteProvider(isSafelite) {
|
||||
this.order.serviceLocation.IsSafeliteProvider = isSafelite;
|
||||
},
|
||||
|
|
@ -2268,10 +2280,53 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
async validateZip({ zip }) {
|
||||
return await globalMethods.callHttpClient({
|
||||
method: endpoints.ValidateZip.method,
|
||||
endpoint: `${endpoints.ValidateZip.url}/${zip}`
|
||||
});
|
||||
try {
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.ValidateZip.method,
|
||||
endpoint: endpoints.ValidateZip.url(zip)
|
||||
});
|
||||
const zipInfo = response.data;
|
||||
if (zipInfo?.isValid === true) {
|
||||
this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu;
|
||||
return Promise.resolve(zipInfo);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Invalid Zip Info'));
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
},
|
||||
|
||||
async getBillToInfo() {
|
||||
const { order, issConfig } = this;
|
||||
try {
|
||||
const payload = {
|
||||
parentAccountNumber: issConfig.parentAccountNumber.toString(),
|
||||
providerNumber: order.serviceLocation.zipCodeCtu.toString(),
|
||||
billToSelectionCriteria: {
|
||||
typeOfClaim: 'GLASS ONLY',
|
||||
lineOfBusiness: 'PERSONAL'
|
||||
}
|
||||
};
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetBillToInfo.method,
|
||||
endpoint: endpoints.GetBillToInfo.url,
|
||||
payload
|
||||
});
|
||||
|
||||
const billToInfo = response.data;
|
||||
if (billToInfo != null) {
|
||||
issConfig.billToAccountNumber = billToInfo.billToAccountNumber;
|
||||
issConfig.itacCashBillToNumber = billToInfo.itacCashBillToNumber;
|
||||
issConfig.itacFnrBillToNumber = billToInfo.itacFnrBillToNumber;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Invalid billToInfo'));
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
},
|
||||
|
||||
async validateClientTag(clientTag) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,20 @@
|
|||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { useMainStore, getDefaultState } from '@/store/index.js';
|
||||
import globalMethods from '@/global-methods.js';
|
||||
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
|
||||
import {
|
||||
getRandomString,
|
||||
getRandomGuid,
|
||||
getRandomInt,
|
||||
getRandomBoolean,
|
||||
getRandomEnum
|
||||
} from '@/helpers/data-generation.js';
|
||||
import coverageStatuses from '@/constants/coverage-statuses.js';
|
||||
import { paymentMethods } from '@/constants/payment-method-constants';
|
||||
import { endpoints } from '@/constants/endpoints';
|
||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import { getEnumName } from '@/helpers/unit-test-helper';
|
||||
|
||||
describe('Store', () => {
|
||||
let store;
|
||||
|
|
@ -157,12 +165,12 @@ describe('Store', () => {
|
|||
expect(store.order.vehicle).toMatchObject(expectedVehicle);
|
||||
});
|
||||
|
||||
it('UpdateVehicle should set policy values appropriately with repair waived', () => {
|
||||
it('updateVehicleCoverage should set policy values appropriately with repair waived', () => {
|
||||
// Arrange
|
||||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const endorsements = [getRandomString(10, 20)];
|
||||
const vehicle = {
|
||||
const vehicleCoverage = {
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: true,
|
||||
|
|
@ -170,7 +178,6 @@ describe('Store', () => {
|
|||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
noCoverage,
|
||||
deductible: {
|
||||
replace: deductible,
|
||||
repair: 0
|
||||
|
|
@ -179,7 +186,7 @@ describe('Store', () => {
|
|||
};
|
||||
|
||||
// Act
|
||||
store.updateVehicle(vehicle);
|
||||
store.updateVehicleCoverage(vehicleCoverage);
|
||||
|
||||
// Assert
|
||||
expect(store.order.policy).toMatchObject(expectedPolicy);
|
||||
|
|
@ -190,7 +197,7 @@ describe('Store', () => {
|
|||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const endorsements = [getRandomString(10, 20)];
|
||||
const vehicle = {
|
||||
const vehicleCoverage = {
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: false,
|
||||
|
|
@ -198,7 +205,6 @@ describe('Store', () => {
|
|||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
noCoverage,
|
||||
deductible: {
|
||||
replace: deductible,
|
||||
repair: deductible
|
||||
|
|
@ -207,34 +213,31 @@ describe('Store', () => {
|
|||
};
|
||||
|
||||
// Act
|
||||
store.updateVehicle(vehicle);
|
||||
store.updateVehicleCoverage(vehicleCoverage);
|
||||
|
||||
// Assert
|
||||
expect(store.order.policy).toMatchObject(expectedPolicy);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[true, coverageStatuses.NO_COMP],
|
||||
[false, coverageStatuses.PENDING]
|
||||
])(
|
||||
'UpdateVehicle should set coverageStatus appropriately based on noCoverage value',
|
||||
(expectedNoCoverage, expectedCoverageStatus) => {
|
||||
describe.each([
|
||||
[coverageType.NO_COMP, true, true],
|
||||
[coverageType.NONE, false, true],
|
||||
[coverageType.Deductible, true, false]
|
||||
])('updateVehicleCoverage noCoverage', (expected, enableNoCompQuote, noCoverage) => {
|
||||
test(`CoverageType is set to expected ${getEnumName(coverageType, expected)} when vehicle noCoverage is ${noCoverage} and enableNoCompQuote is ${enableNoCompQuote}`, () => {
|
||||
// Arrange
|
||||
const vehicle = {
|
||||
noCoverage: expectedNoCoverage
|
||||
store.issConfig.enableNoCompQuote = enableNoCompQuote;
|
||||
const vehicleCoverage = {
|
||||
noCoverage
|
||||
};
|
||||
|
||||
store.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
|
||||
// Act
|
||||
store.updateVehicle(vehicle);
|
||||
store.updateVehicleCoverage(vehicleCoverage);
|
||||
|
||||
// Assert
|
||||
expect(store.order.policy.noCoverage).toBe(expectedNoCoverage);
|
||||
expect(store.order.payment.insuranceCoverage.coverageStatus).toBe(expectedCoverageStatus);
|
||||
}
|
||||
);
|
||||
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(expected);
|
||||
});
|
||||
});
|
||||
it('setVehicle is bailout if the vehicle cannot be serviced by Safelite', () => {
|
||||
// Arrange
|
||||
const vehicle = {
|
||||
|
|
@ -417,7 +420,7 @@ describe('Store', () => {
|
|||
deductible: 0
|
||||
}
|
||||
};
|
||||
store.policy.noCoverage = true;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.NO_COMP;
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
@ -426,9 +429,9 @@ describe('Store', () => {
|
|||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
|
||||
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP);
|
||||
expect(store.payment.insuranceCoverage.claimNumber).toBe(null);
|
||||
expect(store.order.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.NO_COMP);
|
||||
expect(store.order.insuranceCoverage.claimNumber).toBe(response.data.claimNumber);
|
||||
});
|
||||
|
||||
it('successful response with coverage => isVerified true and coverage status verified', async () => {
|
||||
|
|
@ -444,7 +447,7 @@ describe('Store', () => {
|
|||
deductible: 0
|
||||
}
|
||||
};
|
||||
store.policy.noCoverage = false;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
@ -453,17 +456,17 @@ describe('Store', () => {
|
|||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
|
||||
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
|
||||
expect(store.payment.insuranceCoverage.claimNumber).toBe(response.data.claimNumber);
|
||||
expect(store.order.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.Deductible);
|
||||
expect(store.order.insuranceCoverage.claimNumber).not.toBeNull();
|
||||
});
|
||||
|
||||
it('Call to client returns exception, resulting in object with error property being returned', async () => {
|
||||
// Arrange
|
||||
expect.assertions(5);
|
||||
expect.assertions(4);
|
||||
const error = 'register claim error';
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
store.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
|
||||
// Act
|
||||
await store.registerClaim().catch((e) => {
|
||||
|
|
@ -472,9 +475,8 @@ describe('Store', () => {
|
|||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
expect(store.payment.insuranceCoverage.isVerified).toBe(false);
|
||||
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.PENDING);
|
||||
expect(store.payment.insuranceCoverage.claimNumber).toBe(null);
|
||||
expect(store.order.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COVERAGE);
|
||||
expect(store.order.insuranceCoverage.claimNumber).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -677,8 +679,8 @@ describe('Store', () => {
|
|||
const customerState = getRandomString(2, 2);
|
||||
const policyNumber = getRandomString(6, 6);
|
||||
const policyZipCode = getRandomString(6, 6);
|
||||
const policyLookupSuccessful = getRandomString(6, 6);
|
||||
const noCoverage = getRandomString(6, 6);
|
||||
const status = getRandomEnum(coverageStatuses);
|
||||
const type = getRandomEnum(coverageType);
|
||||
const originalDeductible = getRandomString(6, 6);
|
||||
const currentDeductible = getRandomString(6, 6);
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
|
|
@ -691,8 +693,8 @@ describe('Store', () => {
|
|||
store.order.contactInfo.servicePhone = customerPhoneNumber;
|
||||
store.order.policy.policyNumber = policyNumber;
|
||||
store.order.policy.policyZipCode = policyZipCode;
|
||||
store.order.policy.policyLookupSuccessful = policyLookupSuccessful;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.insuranceCoverage.coverageStatus = status;
|
||||
store.order.insuranceCoverage.coverageType = type;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -711,10 +713,12 @@ describe('Store', () => {
|
|||
}),
|
||||
policyNumber,
|
||||
policyZipCode,
|
||||
noCoverage,
|
||||
policyLookupSuccessful,
|
||||
originalDeductible,
|
||||
currentDeductible
|
||||
}),
|
||||
insuranceCoverage: expect.objectContaining({
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
})
|
||||
})
|
||||
}));
|
||||
|
|
@ -798,17 +802,40 @@ describe('Store', () => {
|
|||
})
|
||||
}));
|
||||
});
|
||||
it.each([
|
||||
[coverageStatuses.PENDING],
|
||||
[coverageStatuses.NO_COMP],
|
||||
[coverageStatuses.VERIFIED]
|
||||
])('calls api with expected payment', async (coverageStatus) => {
|
||||
describe.each([
|
||||
[coverageStatuses.PENDING, coverageType.NO_COMP, null],
|
||||
[coverageStatuses.PENDING, coverageType.ITAC, null],
|
||||
[coverageStatuses.PENDING, coverageType.Deductible, null],
|
||||
[coverageStatuses.VERIFIED, coverageType.ITAC, 'V_ITAC_123'],
|
||||
[coverageStatuses.VERIFIED, coverageType.Deductible, 'V_Deductible_123'],
|
||||
[coverageStatuses.NO_COVERAGE, coverageType.NONE, null],
|
||||
])('calls api with expected insuranceCoverage', (status, type, claimNumber) => {
|
||||
test(`calls api with coverageStatus is ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)} and claimNumber is ${claimNumber}`, async () => {
|
||||
// Arrange
|
||||
store.order.insuranceCoverage.coverageStatus = status;
|
||||
store.order.insuranceCoverage.coverageType = type;
|
||||
store.order.insuranceCoverage.claimNumber = claimNumber;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
await store.saveSession({});
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
insuranceCoverage: expect.objectContaining({
|
||||
coverageStatus: status,
|
||||
coverageType: type,
|
||||
claimNumber
|
||||
})
|
||||
})
|
||||
}));
|
||||
});
|
||||
});
|
||||
it('calls api with expected payment', async () => {
|
||||
// Arrange
|
||||
const parentAccountNumber = getRandomString(6, 6);
|
||||
const isVerified = getRandomBoolean();
|
||||
store.issConfig.parentAccountNumber = parentAccountNumber;
|
||||
store.order.payment.insuranceCoverage.isVerified = isVerified;
|
||||
store.order.payment.insuranceCoverage.coverageStatus = coverageStatus;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -818,10 +845,6 @@ describe('Store', () => {
|
|||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
payment: expect.objectContaining({
|
||||
InsuranceCoverage: expect.objectContaining({
|
||||
isVerified,
|
||||
coverageStatus
|
||||
}),
|
||||
parentAccountNumber
|
||||
})
|
||||
})
|
||||
|
|
@ -1105,7 +1128,7 @@ describe('Store', () => {
|
|||
referralCorrelationId: getRandomGuid()
|
||||
};
|
||||
|
||||
store.order.policy.policyLookupSuccessful = true;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
store.policy.vehicles = [{ vin: vehicle.vin }];
|
||||
|
||||
// Act
|
||||
|
|
@ -1134,7 +1157,7 @@ describe('Store', () => {
|
|||
referralCorrelationId: getRandomGuid()
|
||||
};
|
||||
|
||||
store.order.policy.policyLookupSuccessful = true;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
store.policy.vehicles = [{ vin: vehicle.vin }];
|
||||
|
||||
// Act
|
||||
|
|
@ -1205,6 +1228,8 @@ describe('Store', () => {
|
|||
describe('successful method call', () => {
|
||||
it('calls getCoveragePolicyInfo api endpoint', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -1216,16 +1241,55 @@ describe('Store', () => {
|
|||
endpoint: endpoints.CoveragePolicyInfo.url
|
||||
}));
|
||||
});
|
||||
it('Returns expected response object', async () => {
|
||||
it('Sets policy fields for successful policy lookup', async () => {
|
||||
// Arrange
|
||||
const response = { ReferralNumber: getRandomString(6, 6) };
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
const address = getRandomString(6, 6);
|
||||
const city = getRandomString(6, 6);
|
||||
const state = getRandomString(6, 6);
|
||||
const zipCode = getRandomString(6, 6);
|
||||
const firstName = getRandomString(6, 6);
|
||||
const lastName = getRandomString(6, 6);
|
||||
|
||||
const vehicle = { id: '123' };
|
||||
|
||||
const response = {
|
||||
data: {
|
||||
policies: [
|
||||
{
|
||||
insureds: [
|
||||
{
|
||||
address,
|
||||
city,
|
||||
state,
|
||||
zipCode,
|
||||
firstName,
|
||||
lastName
|
||||
}
|
||||
],
|
||||
vehicles: [
|
||||
vehicle
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
// Act
|
||||
const result = store.getCoveragePolicyInfo();
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
await expect(result).resolves.toBe(response);
|
||||
await expect(store.order.customer.address.streetAddress).toBe(address);
|
||||
await expect(store.order.customer.address.city).toBe(city);
|
||||
await expect(store.order.customer.address.state).toBe(state);
|
||||
await expect(store.order.customer.address.zipCode).toBe(zipCode);
|
||||
await expect(store.order.customer.firstName).toBe(firstName);
|
||||
await expect(store.order.customer.lastName).toBe(lastName);
|
||||
await expect(store.order.serviceLocation.zipCode).toBe(zipCode);
|
||||
await expect(store.order.policy.vehicles).toStrictEqual([vehicle])
|
||||
});
|
||||
it('calls api with expected data', async () => {
|
||||
// Arrange
|
||||
|
|
@ -1239,6 +1303,8 @@ describe('Store', () => {
|
|||
store.order.policy.dateOfLoss = dateOfLoss;
|
||||
store.order.policy.policyZipCode = zipCode;
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -1255,18 +1321,22 @@ describe('Store', () => {
|
|||
})
|
||||
}));
|
||||
});
|
||||
it('null response by api => policyLookupSuccessful false', async () => {
|
||||
it('null response by api => insuranceCoverage.coverageType is NONE', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(null));
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(false);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.NONE);
|
||||
});
|
||||
it('no policies returned by api => policyLookupSuccessful false', async () => {
|
||||
it('no policies returned by api => insuranceCoverage.coverageType is NONE', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
const responseNoPolicies = {
|
||||
data: {
|
||||
policies: []
|
||||
|
|
@ -1278,7 +1348,7 @@ describe('Store', () => {
|
|||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(false);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.NONE);
|
||||
});
|
||||
it('multiple policies returned by api => data set based on first policy returned', async () => {
|
||||
// Arrange
|
||||
|
|
@ -1303,13 +1373,15 @@ describe('Store', () => {
|
|||
policies: [policy1, {}]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(true);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.Deductible);
|
||||
|
||||
expect(store.order.customer.address.streetAddress).toBe(insured.address);
|
||||
expect(store.order.customer.address.city).toBe(insured.city);
|
||||
|
|
@ -1338,13 +1410,15 @@ describe('Store', () => {
|
|||
}]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(true);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.Deductible);
|
||||
expect(store.order.customer.address.streetAddress).toBe(insured1.address);
|
||||
});
|
||||
it('no policy vehicles on first policy => order.policy.vehicles empty list', async () => {
|
||||
|
|
@ -1354,19 +1428,69 @@ describe('Store', () => {
|
|||
policies: [{ vehicles: [] }]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(true);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.Deductible);
|
||||
expect(store.order.policy.vehicles).toEqual([]);
|
||||
});
|
||||
});
|
||||
it('api call throws exception => policyLookupSuccessful false', async () => {
|
||||
|
||||
test('if isCoverageEnabled is false, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = false;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if isCoverageEnabled is true, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is true, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 11;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is false, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 10;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
});
|
||||
it('api call throws exception => insuranceCoverage.coverageType is NONE', async () => {
|
||||
expect.assertions(3);
|
||||
const error = 'get coverage policy info error';
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
|
||||
// Act
|
||||
|
|
@ -1380,7 +1504,7 @@ describe('Store', () => {
|
|||
method: endpoints.CoveragePolicyInfo.method,
|
||||
endpoint: endpoints.CoveragePolicyInfo.url
|
||||
}));
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(false);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.NONE);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1452,89 +1576,20 @@ describe('Store', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('updatePolicyITACFlag method', () => {
|
||||
it('updatePolicyITACFlag updates policy.isITAC flag in store', () => {
|
||||
describe.each([
|
||||
[true, coverageStatuses.PENDING],
|
||||
[true, coverageStatuses.NO_COVERAGE],
|
||||
[false, coverageStatuses.VERIFIED]
|
||||
])('isUnverified', (expected, status) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)}`, () => {
|
||||
// Arrange
|
||||
const moqIsITAC = getRandomBoolean();
|
||||
|
||||
// Act
|
||||
store.updatePolicyITACFlag(moqIsITAC);
|
||||
|
||||
// Assert
|
||||
expect(store.order.policy.isITAC).toEqual(moqIsITAC);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isUnverified', () => {
|
||||
beforeEach(() => {
|
||||
store.order.policy.isITAC = false;
|
||||
store.order.policy.noCoverage = false;
|
||||
store.order.payment.insuranceCoverage.isVerified = true;
|
||||
store.order.currentDeductible = 123;
|
||||
store.order.policy.policyLookupSuccessful = true;
|
||||
store.issConfig.isClaimRegistrationRequired = true;
|
||||
store.issConfig.enableNoCompQuote = true;
|
||||
});
|
||||
it('returns true when policyLookupSuccessful false', () => {
|
||||
// Arrange
|
||||
store.order.policy.policyLookupSuccessful = false;
|
||||
store.order.insuranceCoverage.coverageStatus = status;
|
||||
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
it('returns true when no comp and enableNoCompQuote false', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = true;
|
||||
store.issConfig.enableNoCompQuote = false;
|
||||
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
it('returns true when not no comp and currentDeductible null', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = false;
|
||||
store.order.currentDeductible = null;
|
||||
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
it('returns true when isClaimRegistrationRequired true and insurance coverage not verified', () => {
|
||||
// Arrange
|
||||
store.order.payment.insuranceCoverage.isVerified = false;
|
||||
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
it('returns false when no comp, enableNoCompQuote true, and currentDeductible null', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = true;
|
||||
store.order.currentDeductible = null;
|
||||
store.issConfig.enableNoCompQuote = true;
|
||||
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
it('returns false when not no comp, currentDeductible not null', () => {
|
||||
// Act
|
||||
const result = store.isUnverified;
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1686,7 +1741,6 @@ describe('Store', () => {
|
|||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const originalDeductible = getRandomInt(0, 5000);
|
||||
const noCoverage = getRandomBoolean();
|
||||
const isRepair = getRandomBoolean();
|
||||
const policyNumber = getRandomString(10, 20);
|
||||
const insuredFirstName = getRandomString(10, 20);
|
||||
|
|
@ -1695,13 +1749,11 @@ describe('Store', () => {
|
|||
const policyVehicleId = getRandomInt(1, 2).toString();
|
||||
const vehicleVin = getRandomString(17, 17);
|
||||
const policyData = getRandomString(100, 200);
|
||||
const isItac = getRandomBoolean();
|
||||
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.issConfig.parentAccountNumber = parentAccountNumber;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.damage.isRepair = isRepair;
|
||||
|
|
@ -1713,8 +1765,6 @@ describe('Store', () => {
|
|||
store.order.vehicle.vin = vehicleVin;
|
||||
store.order.policy.policyData = policyData;
|
||||
|
||||
store.updatePolicyITACFlag(isItac);
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
// Act
|
||||
|
|
@ -1733,7 +1783,7 @@ describe('Store', () => {
|
|||
status,
|
||||
currentDeductible,
|
||||
originalDeductible,
|
||||
noCoverage,
|
||||
noCoverage: store.isNoComp,
|
||||
isRepair,
|
||||
policyNumber,
|
||||
insuredFirstName,
|
||||
|
|
@ -1742,7 +1792,7 @@ describe('Store', () => {
|
|||
policyVehicleId,
|
||||
vehicleVin,
|
||||
policyData,
|
||||
isItac
|
||||
isItac: store.isITAC
|
||||
})
|
||||
}));
|
||||
});
|
||||
|
|
@ -1768,7 +1818,6 @@ describe('Store', () => {
|
|||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const originalDeductible = getRandomInt(0, 5000);
|
||||
const noCoverage = getRandomBoolean();
|
||||
const isRepair = getRandomBoolean();
|
||||
const endorsementAnswers = [
|
||||
{
|
||||
|
|
@ -1797,13 +1846,11 @@ describe('Store', () => {
|
|||
const policyVehicleId = getRandomInt(1, 2).toString();
|
||||
const vehicleVin = getRandomString(17, 17);
|
||||
const policyData = getRandomString(100, 200);
|
||||
const isItac = false;
|
||||
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.issConfig.parentAccountNumber = parentAccountNumber;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.policy.endorsementQuestionAnswers = endorsementAnswers;
|
||||
|
|
@ -1816,8 +1863,6 @@ describe('Store', () => {
|
|||
store.order.vehicle.vin = vehicleVin;
|
||||
store.order.policy.policyData = policyData;
|
||||
|
||||
store.updatePolicyITACFlag(isItac);
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
// Act
|
||||
|
|
@ -1837,7 +1882,7 @@ describe('Store', () => {
|
|||
status,
|
||||
currentDeductible,
|
||||
originalDeductible,
|
||||
noCoverage,
|
||||
noCoverage: store.isNoComp,
|
||||
isRepair,
|
||||
policyNumber,
|
||||
insuredFirstName,
|
||||
|
|
@ -1846,7 +1891,7 @@ describe('Store', () => {
|
|||
policyVehicleId,
|
||||
vehicleVin,
|
||||
policyData,
|
||||
isItac
|
||||
isItac: store.isITAC
|
||||
})
|
||||
}));
|
||||
});
|
||||
|
|
@ -1991,9 +2036,12 @@ describe('Store', () => {
|
|||
expect(result.data.shopProviders[1]).toBe(provider2);
|
||||
});
|
||||
});
|
||||
it('api call throws exception => policyLookupSuccessful false', async () => {
|
||||
it('api call throws exception => coverageType none', async () => {
|
||||
expect.assertions(3);
|
||||
const error = 'get coverage policy info error';
|
||||
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
|
||||
// Act
|
||||
|
|
@ -2007,7 +2055,7 @@ describe('Store', () => {
|
|||
method: endpoints.CoveragePolicyInfo.method,
|
||||
endpoint: endpoints.CoveragePolicyInfo.url
|
||||
}));
|
||||
expect(store.order.policy.policyLookupSuccessful).toBe(false);
|
||||
expect(store.order.insuranceCoverage.coverageType).toBe(coverageType.NONE);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -2050,28 +2098,27 @@ describe('Store', () => {
|
|||
});
|
||||
|
||||
describe('billToNumberToUse getter', () => {
|
||||
it('returns itacCashBillToNumber when in ITAC flow', () => {
|
||||
it('returns itacCashBillToNumber when coverageType is ITAC', () => {
|
||||
// Arrange
|
||||
store.order.policy.isITAC = true;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.ITAC;
|
||||
store.issConfig.itacCashBillToNumber = '12345';
|
||||
|
||||
// Assert
|
||||
expect(store.billToNumberToUse).toEqual(store.issConfig.itacCashBillToNumber);
|
||||
});
|
||||
|
||||
it('returns itacFnrBillToNumber when in NoComp flow', () => {
|
||||
it('returns itacFnrBillToNumber when coverageType is No Comp', () => {
|
||||
// Arrange
|
||||
store.order.policy.noCoverage = true;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.NO_COMP;
|
||||
store.issConfig.itacFnrBillToNumber = '12345';
|
||||
|
||||
// Assert
|
||||
expect(store.billToNumberToUse).toEqual(store.issConfig.itacFnrBillToNumber);
|
||||
});
|
||||
|
||||
it('returns billToAccountNumber when not ITAC and not NoComp', () => {
|
||||
it('returns billToAccountNumber when coverageType is Deductible', () => {
|
||||
// Arrange
|
||||
store.order.policy.isITAC = null;
|
||||
store.order.policy.noCoverage = null;
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
store.issConfig.billToAccountNumber = '12345';
|
||||
|
||||
// Assert
|
||||
|
|
|
|||
Loading…
Reference in a new issue