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