SSR-1205 PR Changes
This commit is contained in:
parent
789e98e0b1
commit
8e20fe084c
11 changed files with 244 additions and 291 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
const partTypeStrings = Object.freeze({
|
const partTypeStrings = Object.freeze({
|
||||||
|
WINDSHIELD: 'WINDSHIELD',
|
||||||
FRONT_WIPER: 'FRONT WIPER',
|
FRONT_WIPER: 'FRONT WIPER',
|
||||||
REAR_WIPER: 'REAR WIPER',
|
REAR_WIPER: 'REAR WIPER',
|
||||||
RAIN_DEFENSE: 'RAIN DEFENSE',
|
RAIN_DEFENSE: 'RAIN DEFENSE',
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ export function getAllLineItems(order) {
|
||||||
* @param {object} order order object
|
* @param {object} order order object
|
||||||
* @returns {{}|undefined} recycle fee line item or undefined
|
* @returns {{}|undefined} recycle fee line item or undefined
|
||||||
*/
|
*/
|
||||||
export function getRecycleFee(order) {
|
export function getRecycleFeeLineItem(order) {
|
||||||
return getLineItems(order).feeItems?.find((lineItem) => lineItem.partNumber === partNumberStrings.RECYCLE_FEE);
|
return getLineItems(order).feeItems?.find((lineItem) => lineItem.partNumber === partNumberStrings.RECYCLE_FEE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,17 +65,17 @@ export function getRecycleFee(order) {
|
||||||
* @param {object} order order object
|
* @param {object} order order object
|
||||||
* @returns {{}|undefined} mobile fee line item or undefined
|
* @returns {{}|undefined} mobile fee line item or undefined
|
||||||
*/
|
*/
|
||||||
export function getMobileFee(order) {
|
export function getMobileFeeLineItem(order) {
|
||||||
return getLineItems(order).feeItems?.find((lineItem) => lineItem.partType === partTypeStrings.MOBILE_FEE);
|
return getLineItems(order).feeItems?.find((lineItem) => lineItem.partType === partTypeStrings.MOBILE_FEE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current deductible on the order
|
* Returns the current deductible on the order
|
||||||
* @param {object} order order object
|
* @param {object} order order object
|
||||||
* @returns {number} current deductible
|
* @returns {number|undefined|null} current deductible
|
||||||
*/
|
*/
|
||||||
export function getDeductible(order) {
|
export function getDeductible(order) {
|
||||||
return order.currentDeductible ?? 0;
|
return order.currentDeductible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,11 +111,11 @@ export function isOrderITAC(order) {
|
||||||
* @returns {number} sub total for the order
|
* @returns {number} sub total for the order
|
||||||
*/
|
*/
|
||||||
export function getSubtotal(order) {
|
export function getSubtotal(order) {
|
||||||
if (!isOrderNoComp(order) && !isOrderITAC(order)) {
|
if (!isOrderUnverified(order) && !isOrderNoComp(order) && !isOrderITAC(order)) {
|
||||||
return getDeductible(order) + getPriceOfLineItems(getNonServiceLineItems(order), false);
|
return getDeductible(order) + getPriceOfLineItems(getNonServiceLineItems(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPriceOfLineItems(getAllLineItems(order), false);
|
return getPriceOfLineItems(getAllLineItems(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -125,7 +125,7 @@ export function getSubtotal(order) {
|
||||||
*/
|
*/
|
||||||
export function getSalesTax(order) {
|
export function getSalesTax(order) {
|
||||||
let tax = 0;
|
let tax = 0;
|
||||||
if (isOrderITAC(order) || isOrderNoComp(order)) {
|
if (!isOrderUnverified(order) && (isOrderITAC(order) || isOrderNoComp(order))) {
|
||||||
tax += getTaxOfLineItems(getServiceLineItems(order));
|
tax += getTaxOfLineItems(getServiceLineItems(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import {
|
||||||
getCartTotal,
|
getCartTotal,
|
||||||
getDeductible,
|
getDeductible,
|
||||||
getLineItems,
|
getLineItems,
|
||||||
getMobileFee, getNonServiceLineItems,
|
getMobileFeeLineItem, getNonServiceLineItems,
|
||||||
getRecycleFee, getSalesTax,
|
getRecycleFeeLineItem, getSalesTax,
|
||||||
getServiceLineItems, getSubtotal, isOrderITAC, isOrderNoComp,
|
getServiceLineItems, getSubtotal, isOrderITAC, isOrderNoComp,
|
||||||
isOrderUnverified
|
isOrderUnverified
|
||||||
} from '@/helpers/cart-helper';
|
} from '@/helpers/cart-helper';
|
||||||
|
|
@ -183,7 +183,7 @@ describe('cart-helper', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getRecycleFee(order);
|
const result = getRecycleFeeLineItem(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).not.toBeNull();
|
expect(result).not.toBeNull();
|
||||||
|
|
@ -197,7 +197,7 @@ describe('cart-helper', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getRecycleFee(order);
|
const result = getRecycleFeeLineItem(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
|
|
@ -212,7 +212,7 @@ describe('cart-helper', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getMobileFee(order);
|
const result = getMobileFeeLineItem(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).not.toBeNull();
|
expect(result).not.toBeNull();
|
||||||
|
|
@ -226,7 +226,7 @@ describe('cart-helper', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getMobileFee(order);
|
const result = getMobileFeeLineItem(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
|
|
@ -251,35 +251,22 @@ describe('cart-helper', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isOrderUnverified', () => {
|
describe('isOrderUnverified', () => {
|
||||||
test('Returns true if order has isUnverified field and is true', () => {
|
test.each([[false, false], [true, true]])('Returns %p when policy.isUnverified is %p', (expected, isUnverified) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
isUnverified: true
|
isUnverified
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = isOrderUnverified(order);
|
const result = isOrderUnverified(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBe(expected);
|
||||||
});
|
|
||||||
|
|
||||||
test('Returns false if order has isUnverified field and is false', () => {
|
|
||||||
// Arrange
|
|
||||||
const order = {
|
|
||||||
isUnverified: true
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = isOrderUnverified(order);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isOrderNoComp', () => {
|
describe('isOrderNoComp', () => {
|
||||||
test('Returns null when policy is null', () => {
|
test('Returns false when policy is null', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {};
|
const order = {};
|
||||||
|
|
||||||
|
|
@ -290,11 +277,11 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns true when policy.NoCoverage is true', () => {
|
test.each([[false, false], [true, true]])('Returns %p when policy.NoCoverage is %p', (expected, noCoverage) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -302,27 +289,12 @@ describe('cart-helper', () => {
|
||||||
const result = isOrderNoComp(order);
|
const result = isOrderNoComp(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBe(expected);
|
||||||
});
|
|
||||||
|
|
||||||
test('Returns false when policy.NoCoverage is false', () => {
|
|
||||||
// Arrange
|
|
||||||
const order = {
|
|
||||||
policy: {
|
|
||||||
noCoverage: false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = isOrderNoComp(order);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isOrderITAC', () => {
|
describe('isOrderITAC', () => {
|
||||||
test('Returns null when policy is null', () => {
|
test('Returns false when policy is null', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {};
|
const order = {};
|
||||||
|
|
||||||
|
|
@ -333,11 +305,11 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns true when policy.isITAC is true', () => {
|
test.each([[false, false], [true, true]])('Returns %p when policy.isITAC is %p', (expected, isITAC) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
policy: {
|
policy: {
|
||||||
isITAC: true
|
isITAC
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -345,22 +317,7 @@ describe('cart-helper', () => {
|
||||||
const result = isOrderITAC(order);
|
const result = isOrderITAC(order);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBe(expected);
|
||||||
});
|
|
||||||
|
|
||||||
test('Returns false when policy.isITAC is false', () => {
|
|
||||||
// Arrange
|
|
||||||
const order = {
|
|
||||||
policy: {
|
|
||||||
isITAC: false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = isOrderITAC(order);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -368,6 +325,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are null items', () => {
|
test('Returns 0 when there are null items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -384,6 +342,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are no items', () => {
|
test('Returns 0 when there are no items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -397,9 +356,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sub total of deductible + vaps + fee line items', () => {
|
test('Returns sub total of deductible + vaps + fee line items when verified deductible', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -415,9 +375,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(310);
|
expect(result).toBe(310);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sub total of all line items when no comp', () => {
|
test('Returns sub total of all line items when verified no comp', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true,
|
noCoverage: true,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -433,9 +394,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(330);
|
expect(result).toBe(330);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sub total of all line items when ITAC', () => {
|
test('Returns sub total of all line items when verified ITAC', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: true
|
isITAC: true
|
||||||
|
|
@ -456,6 +418,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are null items', () => {
|
test('Returns 0 when there are null items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -472,6 +435,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are no items', () => {
|
test('Returns 0 when there are no items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -485,9 +449,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sales tax vaps + fee line items', () => {
|
test('Returns sales tax vaps + fee line items when verified', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -503,9 +468,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(15);
|
expect(result).toBe(15);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sales tax of all line items when no comp', () => {
|
test('Returns sales tax of all line items when verified no comp', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true,
|
noCoverage: true,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -521,9 +487,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(21);
|
expect(result).toBe(21);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns sales tax of all line items when ITAC', () => {
|
test('Returns sales tax of all line items when verified ITAC', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: true
|
isITAC: true
|
||||||
|
|
@ -544,6 +511,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are null items', () => {
|
test('Returns 0 when there are null items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -560,6 +528,7 @@ describe('cart-helper', () => {
|
||||||
test('Returns 0 when there are no items', () => {
|
test('Returns 0 when there are no items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true
|
noCoverage: true
|
||||||
},
|
},
|
||||||
|
|
@ -573,9 +542,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns total of vaps + fee line items', () => {
|
test('Returns total of vaps + fee line items when verified', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -591,9 +561,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(325);
|
expect(result).toBe(325);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns total of all line items when no comp', () => {
|
test('Returns total of all line items when verified no comp', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: true,
|
noCoverage: true,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
|
|
@ -609,9 +580,10 @@ describe('cart-helper', () => {
|
||||||
expect(result).toBe(351);
|
expect(result).toBe(351);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns total of all line items when ITAC', () => {
|
test('Returns total of all line items when verified ITAC', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = {
|
const order = {
|
||||||
|
isUnverified: false,
|
||||||
policy: {
|
policy: {
|
||||||
noCoverage: false,
|
noCoverage: false,
|
||||||
isITAC: true
|
isITAC: true
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* Returns the price of a single line item. Will include sales tax if includeTax is true
|
* Returns the price of a single line item. Will include sales tax if includeTax is true
|
||||||
* @param {object} lineItem line item to price
|
* @param {object} lineItem line item to price
|
||||||
* @param {boolean} includeTax if sales tax should be included
|
|
||||||
* @returns {number} price of the line item
|
* @returns {number} price of the line item
|
||||||
*/
|
*/
|
||||||
export function getPriceOfLineItem(lineItem, includeTax = false) {
|
export function getPriceOfLineItem(lineItem) {
|
||||||
let price = (lineItem.kitPrice ?? 0) + (lineItem.laborAmount ?? 0) + (lineItem.sellingPrice ?? 0);
|
let price = (lineItem.kitPrice ?? 0) + (lineItem.laborAmount ?? 0) + (lineItem.sellingPrice ?? 0);
|
||||||
if (includeTax) {
|
|
||||||
price += lineItem.salesTax ?? 0;
|
|
||||||
}
|
|
||||||
if (lineItem.childParts && lineItem.childParts.length !== 0) {
|
if (lineItem.childParts && lineItem.childParts.length !== 0) {
|
||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
price += getPriceOfLineItems(lineItem.childParts, includeTax);
|
price += getPriceOfLineItems(lineItem.childParts);
|
||||||
}
|
}
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
@ -19,11 +15,10 @@ export function getPriceOfLineItem(lineItem, includeTax = false) {
|
||||||
/**
|
/**
|
||||||
* Returns the price for the given array of line items. Will include sales tax if includeTax is true
|
* Returns the price for the given array of line items. Will include sales tax if includeTax is true
|
||||||
* @param {Array} lineItems array of line items to be priced
|
* @param {Array} lineItems array of line items to be priced
|
||||||
* @param {boolean} includeTax if sales tax should be included
|
|
||||||
* @returns {number} price of the lines items
|
* @returns {number} price of the lines items
|
||||||
*/
|
*/
|
||||||
export function getPriceOfLineItems(lineItems, includeTax = false) {
|
export function getPriceOfLineItems(lineItems) {
|
||||||
return lineItems?.reduce((accumulator, lineItem) => accumulator + getPriceOfLineItem(lineItem, includeTax), 0) ?? 0;
|
return lineItems?.reduce((accumulator, lineItem) => accumulator + getPriceOfLineItem(lineItem), 0) ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,13 @@ describe('price-calculator', () => {
|
||||||
const lineItem = {};
|
const lineItem = {};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItem(lineItem, false);
|
const result = getPriceOfLineItem(lineItem);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Empty lineItem with salesTax returns 0', () => {
|
test('Returns kit, labor, sellingPrice total', () => {
|
||||||
// Arrange
|
|
||||||
const lineItem = {};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = getPriceOfLineItem(lineItem, true);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Returns kit, labor, sellingPrice total when salesTax is false', () => {
|
|
||||||
// Arrange
|
// Arrange
|
||||||
const lineItem = {
|
const lineItem = {
|
||||||
kitPrice: 1,
|
kitPrice: 1,
|
||||||
|
|
@ -38,27 +27,11 @@ describe('price-calculator', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItem(lineItem, false);
|
const result = getPriceOfLineItem(lineItem);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(6);
|
expect(result).toBe(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Returns kit, labor, sellingPrice, salesTax total when salesTax is true', () => {
|
|
||||||
// Arrange
|
|
||||||
const lineItem = {
|
|
||||||
kitPrice: 1,
|
|
||||||
laborAmount: 2,
|
|
||||||
sellingPrice: 3,
|
|
||||||
salesTax: 4
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = getPriceOfLineItem(lineItem, true);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(10);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getPriceOfLineItems', () => {
|
describe('getPriceOfLineItems', () => {
|
||||||
|
|
@ -67,7 +40,7 @@ describe('price-calculator', () => {
|
||||||
const lineItems = null;
|
const lineItems = null;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItems(lineItems, true);
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
|
|
@ -78,7 +51,7 @@ describe('price-calculator', () => {
|
||||||
const lineItems = [];
|
const lineItems = [];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItems(lineItems, true);
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
|
|
@ -95,12 +68,12 @@ describe('price-calculator', () => {
|
||||||
const expected = 6;
|
const expected = 6;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItems(lineItems, false);
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
});
|
});
|
||||||
test('Returns expected when multiple line items', () => {
|
test('Returns expected when multiple line items and child parts', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const lineItems = [
|
const lineItems = [
|
||||||
{
|
{
|
||||||
|
|
@ -111,44 +84,30 @@ describe('price-calculator', () => {
|
||||||
{
|
{
|
||||||
kitPrice: 1
|
kitPrice: 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
kitPrice: 10,
|
|
||||||
laborAmount: 100,
|
|
||||||
sellingPrice: 1000
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const expected = 1117;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = getPriceOfLineItems(lineItems, false);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(expected);
|
|
||||||
});
|
|
||||||
test('Returns expected when multiple line items with sales tax', () => {
|
|
||||||
// Arrange
|
|
||||||
const lineItems = [
|
|
||||||
{
|
|
||||||
kitPrice: 1,
|
|
||||||
laborAmount: 2,
|
|
||||||
sellingPrice: 3,
|
|
||||||
salesTax: 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kitPrice: 1,
|
|
||||||
salesTax: 2
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
kitPrice: 10,
|
kitPrice: 10,
|
||||||
laborAmount: 100,
|
laborAmount: 100,
|
||||||
sellingPrice: 1000,
|
sellingPrice: 1000,
|
||||||
salesTax: 50
|
childParts: [
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
laborAmount: 2,
|
||||||
|
sellingPrice: 3,
|
||||||
|
salesTax: 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kitPrice: 2,
|
||||||
|
laborAmount: 3,
|
||||||
|
sellingPrice: 4,
|
||||||
|
salesTax: 5
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const expected = 1173;
|
const expected = 1132;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = getPriceOfLineItems(lineItems, true);
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
|
|
@ -222,5 +181,34 @@ describe('price-calculator', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Returns expected when multiple line items', () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = [
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
laborAmount: 2,
|
||||||
|
sellingPrice: 3,
|
||||||
|
salesTax: 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
salesTax: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kitPrice: 10,
|
||||||
|
laborAmount: 100,
|
||||||
|
sellingPrice: 1000,
|
||||||
|
salesTax: 50
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const expected = 56;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = getTaxOfLineItems(lineItems);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -169,12 +169,12 @@ import widgetFields from '@/constants/cms-widget-fields.js';
|
||||||
import {
|
import {
|
||||||
getCartTotal,
|
getCartTotal,
|
||||||
getDeductible,
|
getDeductible,
|
||||||
getLineItems, getMobileFee,
|
getLineItems, getMobileFeeLineItem,
|
||||||
getRecycleFee, getSalesTax,
|
getRecycleFeeLineItem, getSalesTax,
|
||||||
getServiceLineItems, getSubtotal, isOrderITAC, isOrderNoComp,
|
getServiceLineItems, getSubtotal, isOrderITAC, isOrderNoComp,
|
||||||
isOrderUnverified
|
isOrderUnverified
|
||||||
} from '@/helpers/cart-helper';
|
} from '@/helpers/cart-helper';
|
||||||
import {getPriceOfLineItems, getTaxOfLineItems} from '@/helpers/price-calculator';
|
import { getPriceOfLineItems, getTaxOfLineItems } from '@/helpers/price-calculator';
|
||||||
|
|
||||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||||
|
|
||||||
|
|
@ -226,10 +226,10 @@ export default {
|
||||||
return getLineItems(this.cartOrder);
|
return getLineItems(this.cartOrder);
|
||||||
},
|
},
|
||||||
recycleFeeLineItem() {
|
recycleFeeLineItem() {
|
||||||
return getRecycleFee(this.cartOrder);
|
return getRecycleFeeLineItem(this.cartOrder);
|
||||||
},
|
},
|
||||||
servicePrice() {
|
servicePrice() {
|
||||||
return getPriceOfLineItems(getServiceLineItems(this.cartOrder), false) ?? 0;
|
return getPriceOfLineItems(getServiceLineItems(this.cartOrder)) ?? 0;
|
||||||
},
|
},
|
||||||
isUnverified() {
|
isUnverified() {
|
||||||
return isOrderUnverified(this.cartOrder);
|
return isOrderUnverified(this.cartOrder);
|
||||||
|
|
@ -393,7 +393,7 @@ export default {
|
||||||
: null;
|
: null;
|
||||||
},
|
},
|
||||||
mobileFeeCartItem() {
|
mobileFeeCartItem() {
|
||||||
const mobileFeeLineItem = getMobileFee(this.cartOrder);
|
const mobileFeeLineItem = getMobileFeeLineItem(this.cartOrder);
|
||||||
return mobileFeeLineItem
|
return mobileFeeLineItem
|
||||||
? this.getCartItem(
|
? this.getCartItem(
|
||||||
this.getCmsContent(this.widget.mobileFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT),
|
this.getCmsContent(this.widget.mobileFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT),
|
||||||
|
|
@ -424,7 +424,7 @@ export default {
|
||||||
name: label,
|
name: label,
|
||||||
cartItemType: cartItemTypeString,
|
cartItemType: cartItemTypeString,
|
||||||
partType,
|
partType,
|
||||||
subTotal: getPriceOfLineItems(lineItems, false),
|
subTotal: getPriceOfLineItems(lineItems),
|
||||||
salesTax: getTaxOfLineItems(lineItems)
|
salesTax: getTaxOfLineItems(lineItems)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
totalServicePrice() {
|
totalServicePrice() {
|
||||||
return getPriceOfLineItems(this.baseServiceLineItems, false);
|
return getPriceOfLineItems(this.baseServiceLineItems);
|
||||||
},
|
},
|
||||||
serviceProviderQuestionText() {
|
serviceProviderQuestionText() {
|
||||||
return this.getCmsContent(
|
return this.getCmsContent(
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ import { useMainStore } from '@/store';
|
||||||
import { paymentMethods, hopPaymentMethods } from '@/constants/payment-method-constants.js';
|
import { paymentMethods, hopPaymentMethods } from '@/constants/payment-method-constants.js';
|
||||||
import queryStrings from '@/constants/query-strings';
|
import queryStrings from '@/constants/query-strings';
|
||||||
import CartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue';
|
import CartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
|
import settleAllPromises from '@/helpers/layout-helper';
|
||||||
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
|
import baseMixin from '@/mixins/base-mixin';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const parts = {
|
const parts = {
|
||||||
|
|
@ -105,123 +109,124 @@ const taxedParts = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup global mocks
|
// Setup global mocks
|
||||||
let mockCmsContent = {};
|
// Mock fetchCmsContentForPage
|
||||||
|
|
||||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
fetchCmsContentForPage: () => Promise.resolve('content')
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
doesCopyContainRouterLink: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function setupMocks({ customMountOptions = {}, queryString }) {
|
// Mock our module for promises.
|
||||||
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRunAfterInitializingStore = () => {}, queryString = {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
...customMountOptions,
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
},
|
||||||
route: { query: { issPage: 'page-name', ...queryString }, params: {} }
|
route: { query: { issPage: 'page-name', ...queryString }, params: {} }
|
||||||
});
|
});
|
||||||
|
|
||||||
// set all mock stuff
|
const testingPinia = createTestingPinia({
|
||||||
mountOptions.mixins = [
|
initialState: {
|
||||||
{
|
main: mainInitialState
|
||||||
methods: {
|
|
||||||
getCmsContent: jest.fn().mockImplementation((widgetName, fieldName) => {
|
|
||||||
if (mockCmsContent[widgetName] && mockCmsContent[widgetName][fieldName]) {
|
|
||||||
return mockCmsContent[widgetName][fieldName];
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}),
|
|
||||||
setCmsContent: jest.fn()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
];
|
});
|
||||||
|
useMainStore(testingPinia);
|
||||||
|
methodToRunAfterInitializingStore();
|
||||||
|
|
||||||
|
mountOptions.global.plugins = [testingPinia];
|
||||||
|
mountOptions.data = () => (initialData);
|
||||||
|
|
||||||
|
const apiResponses = { cmsContent: {} };
|
||||||
|
|
||||||
|
settleAllPromises.mockImplementation(() => apiResponses);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
const wrapper = shallowMount(payment, mountOptions);
|
const wrapper = shallowMount(payment, mountOptions);
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {});
|
||||||
|
wrapper.vm.setCmsContent = jest.fn();
|
||||||
|
wrapper.vm.$router.navigateWithSpinner = jest.fn();
|
||||||
|
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||||
|
|
||||||
// act on vm
|
return { wrapper };
|
||||||
|
|
||||||
return wrapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('payment-page.vue', () => {
|
const defaultOrder = {
|
||||||
beforeEach(() => {
|
order: {
|
||||||
useMainStore().order =
|
vehicle: {
|
||||||
{
|
year: '2020',
|
||||||
vehicle: {
|
make: 'acura',
|
||||||
year: '2020',
|
model: 'mdx',
|
||||||
make: 'acura',
|
style: '4-door sedan',
|
||||||
model: 'mdx',
|
carId: 'dummyCarId',
|
||||||
style: '4-door sedan',
|
category: 'dummyCategory',
|
||||||
carId: 'dummyCarId',
|
vin: 'dummyVin'
|
||||||
category: 'dummyCategory',
|
},
|
||||||
vin: 'dummyVin'
|
serviceLocation: {
|
||||||
},
|
address: 'add1',
|
||||||
serviceLocation: {
|
address2: 'add2',
|
||||||
address: 'add1',
|
city: 'city',
|
||||||
address2: 'add2',
|
state: 'state',
|
||||||
city: 'city',
|
zipCode: 'zip',
|
||||||
state: 'state',
|
zipCodeCtu: 'zipCtu',
|
||||||
zipCode: 'zip',
|
appointmentType: 'IN_SHOP',
|
||||||
zipCodeCtu: 'zipCtu',
|
isVehicleProtected: true,
|
||||||
appointmentType: 'IN_SHOP',
|
provider: {
|
||||||
isVehicleProtected: true,
|
providerNumber: 2,
|
||||||
provider: {
|
address: {
|
||||||
providerNumber: 2,
|
streetAddress: 'add3',
|
||||||
address: {
|
city: 'city2',
|
||||||
streetAddress: 'add3',
|
state: 'state2',
|
||||||
city: 'city2',
|
zipCode: 'zip2',
|
||||||
state: 'state2',
|
zipCodeCtu: 'zipCtu2'
|
||||||
zipCode: 'zip2',
|
|
||||||
zipCodeCtu: 'zipCtu2'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
techNotes: ''
|
|
||||||
},
|
|
||||||
contactInfo: {
|
|
||||||
firstName: 'first',
|
|
||||||
lastName: 'last',
|
|
||||||
emailAddress: 'builddigitaltest@safelite.com',
|
|
||||||
servicePhone: '555-555-5555'
|
|
||||||
},
|
|
||||||
damage: {
|
|
||||||
isRepair: false,
|
|
||||||
numberOfChips: null,
|
|
||||||
glassToReplace: [{ location: 'windshield' }]
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [parts.windshield],
|
|
||||||
supportingItems: [],
|
|
||||||
vaps: [parts.frontWipers],
|
|
||||||
promos: []
|
|
||||||
},
|
|
||||||
payment: {
|
|
||||||
isInsurance: false,
|
|
||||||
insuranceCoverage: {
|
|
||||||
isVerified: null,
|
|
||||||
coverageStatus: null,
|
|
||||||
coverageVerificationType: null
|
|
||||||
},
|
|
||||||
isPayInAdvance: true,
|
|
||||||
payInAdvanceType: 'Afterpay',
|
|
||||||
inactivePromos: []
|
|
||||||
},
|
|
||||||
schedule: {
|
|
||||||
date: 'date',
|
|
||||||
startTime: 'start',
|
|
||||||
endTime: 'end',
|
|
||||||
jobMinMinutes: '30',
|
|
||||||
jobMaxMinutes: '45'
|
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
techNotes: ''
|
||||||
mockCmsContent = {};
|
},
|
||||||
});
|
contactInfo: {
|
||||||
|
firstName: 'first',
|
||||||
afterEach(() => {
|
lastName: 'last',
|
||||||
jest.clearAllMocks();
|
emailAddress: 'builddigitaltest@safelite.com',
|
||||||
});
|
servicePhone: '555-555-5555'
|
||||||
|
},
|
||||||
|
damage: {
|
||||||
|
isRepair: false,
|
||||||
|
numberOfChips: null,
|
||||||
|
glassToReplace: [{location: 'windshield'}]
|
||||||
|
},
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [parts.windshield],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [parts.frontWipers],
|
||||||
|
promos: []
|
||||||
|
},
|
||||||
|
payment: {
|
||||||
|
isInsurance: false,
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: null,
|
||||||
|
coverageStatus: null,
|
||||||
|
coverageVerificationType: null
|
||||||
|
},
|
||||||
|
isPayInAdvance: true,
|
||||||
|
payInAdvanceType: 'Afterpay',
|
||||||
|
inactivePromos: []
|
||||||
|
},
|
||||||
|
schedule: {
|
||||||
|
date: 'date',
|
||||||
|
startTime: 'start',
|
||||||
|
endTime: 'end',
|
||||||
|
jobMinMinutes: '30',
|
||||||
|
jobMaxMinutes: '45'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('payment-page.vue', () => {
|
||||||
describe('arePagePrerequisitesValid', () => {
|
describe('arePagePrerequisitesValid', () => {
|
||||||
test('Returns true in nominal conditions', () => {
|
test('Returns true in nominal conditions', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
// Store defaults are valid
|
// Store defaults are valid
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -233,9 +238,9 @@ describe('payment-page.vue', () => {
|
||||||
describe('Payment method cases', () => {
|
describe('Payment method cases', () => {
|
||||||
test('Returns false if pia options are not valid', () => {
|
test('Returns false if pia options are not valid', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.isPayInAdvance = null;
|
useMainStore().order.payment.isPayInAdvance = null;
|
||||||
useMainStore().order.payment.payInAdvanceType = null;
|
useMainStore().order.payment.payInAdvanceType = null;
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -246,9 +251,9 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
test('Returns false if pay at time of service', () => {
|
test('Returns false if pay at time of service', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.isPayInAdvance = false;
|
useMainStore().order.payment.isPayInAdvance = false;
|
||||||
useMainStore().order.payment.payInAdvanceType = null;
|
useMainStore().order.payment.payInAdvanceType = null;
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -263,8 +268,8 @@ describe('payment-page.vue', () => {
|
||||||
describe('getPaymentType', () => {
|
describe('getPaymentType', () => {
|
||||||
test('Maps AFTERPAY -> hopPaymentMethods.AFTERPAY', () => {
|
test('Maps AFTERPAY -> hopPaymentMethods.AFTERPAY', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.payInAdvanceType = paymentMethods.AFTERPAY;
|
useMainStore().order.payment.payInAdvanceType = paymentMethods.AFTERPAY;
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const mapped = wrapper.vm.getPaymentType();
|
const mapped = wrapper.vm.getPaymentType();
|
||||||
|
|
@ -275,8 +280,8 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
test('Maps CREDIT_CARD -> hopPaymentMethods.CREDIT_CARD', () => {
|
test('Maps CREDIT_CARD -> hopPaymentMethods.CREDIT_CARD', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.payInAdvanceType = paymentMethods.CREDIT_CARD;
|
useMainStore().order.payment.payInAdvanceType = paymentMethods.CREDIT_CARD;
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const mapped = wrapper.vm.getPaymentType();
|
const mapped = wrapper.vm.getPaymentType();
|
||||||
|
|
@ -287,8 +292,8 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
test('Maps PAYPAL -> hopPaymentMethods.PAYPAL', () => {
|
test('Maps PAYPAL -> hopPaymentMethods.PAYPAL', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.payInAdvanceType = paymentMethods.PAYPAL;
|
useMainStore().order.payment.payInAdvanceType = paymentMethods.PAYPAL;
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const mapped = wrapper.vm.getPaymentType();
|
const mapped = wrapper.vm.getPaymentType();
|
||||||
|
|
@ -299,8 +304,8 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
test('Maps other values to self', () => {
|
test('Maps other values to self', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
useMainStore().order.payment.payInAdvanceType = 'SomeOtherText';
|
useMainStore().order.payment.payInAdvanceType = 'SomeOtherText';
|
||||||
const wrapper = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const mapped = wrapper.vm.getPaymentType();
|
const mapped = wrapper.vm.getPaymentType();
|
||||||
|
|
@ -312,7 +317,7 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
describe('cart-dropdown', () => {
|
describe('cart-dropdown', () => {
|
||||||
test('Show cart dropdown if credit card', async () => {
|
test('Show cart dropdown if credit card', async () => {
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
wrapper.vm.paymentType = hopPaymentMethods.CREDIT_CARD;
|
wrapper.vm.paymentType = hopPaymentMethods.CREDIT_CARD;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -324,7 +329,7 @@ describe('payment-page.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('show cart dropdown if afterpay', async () => {
|
test('show cart dropdown if afterpay', async () => {
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
wrapper.vm.paymentType = hopPaymentMethods.AFTERPAY;
|
wrapper.vm.paymentType = hopPaymentMethods.AFTERPAY;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -336,7 +341,7 @@ describe('payment-page.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Hide cart dropdown if paypal', async () => {
|
test('Hide cart dropdown if paypal', async () => {
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
wrapper.vm.paymentType = hopPaymentMethods.PAYPAL;
|
wrapper.vm.paymentType = hopPaymentMethods.PAYPAL;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -352,7 +357,7 @@ describe('payment-page.vue', () => {
|
||||||
test('Is responsive if initial data changes', async () => {
|
test('Is responsive if initial data changes', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
// note: begins with payment-type = afterpay
|
// note: begins with payment-type = afterpay
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const preVal = wrapper.vm.isPaypal;
|
const preVal = wrapper.vm.isPaypal;
|
||||||
|
|
@ -377,7 +382,7 @@ describe('payment-page.vue', () => {
|
||||||
signature: 'SIGNATURE',
|
signature: 'SIGNATURE',
|
||||||
startDate: 'STARTDATE'
|
startDate: 'STARTDATE'
|
||||||
};
|
};
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
wrapper.vm.submitHopForm = jest.fn();
|
wrapper.vm.submitHopForm = jest.fn();
|
||||||
|
|
||||||
|
|
@ -396,7 +401,7 @@ describe('payment-page.vue', () => {
|
||||||
describe('submitHopForm', () => {
|
describe('submitHopForm', () => {
|
||||||
test('Submits form', async () => {
|
test('Submits form', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
wrapper.vm.$refs.hopForm.submit = jest.fn();
|
wrapper.vm.$refs.hopForm.submit = jest.fn();
|
||||||
wrapper.vm.$refs.paymentFrame = null;
|
wrapper.vm.$refs.paymentFrame = null;
|
||||||
|
|
@ -418,7 +423,7 @@ describe('payment-page.vue', () => {
|
||||||
data: 'afterpayClosed'
|
data: 'afterpayClosed'
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
wrapper.vm.backButtonAction = jest.fn();
|
wrapper.vm.backButtonAction = jest.fn();
|
||||||
|
|
||||||
|
|
@ -435,7 +440,7 @@ describe('payment-page.vue', () => {
|
||||||
data: 'creditCardSubmit'
|
data: 'creditCardSubmit'
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.handleIFrameContentWindowMessage(event);
|
wrapper.vm.handleIFrameContentWindowMessage(event);
|
||||||
|
|
@ -449,7 +454,7 @@ describe('payment-page.vue', () => {
|
||||||
describe('UI Blocking', () => {
|
describe('UI Blocking', () => {
|
||||||
test('UI block appears when toggled', async () => {
|
test('UI block appears when toggled', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.setUIBlock(true);
|
wrapper.vm.setUIBlock(true);
|
||||||
|
|
@ -464,7 +469,7 @@ describe('payment-page.vue', () => {
|
||||||
|
|
||||||
test("Don't propogate clicks from UI block", async () => {
|
test("Don't propogate clicks from UI block", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = setupMocks({});
|
const { wrapper } = getMountedComponent(defaultOrder);
|
||||||
|
|
||||||
const outerDiv = wrapper.find('.container-fluid');
|
const outerDiv = wrapper.find('.container-fluid');
|
||||||
const clickFn = jest.fn();
|
const clickFn = jest.fn();
|
||||||
|
|
@ -490,7 +495,7 @@ describe('payment-page.vue', () => {
|
||||||
const queryString = {
|
const queryString = {
|
||||||
[queryStrings.DISPLAY_PAY_IN_ADVANCE_ALERT]: paymentMethods.CREDIT_CARD
|
[queryStrings.DISPLAY_PAY_IN_ADVANCE_ALERT]: paymentMethods.CREDIT_CARD
|
||||||
};
|
};
|
||||||
const wrapper = setupMocks({ queryString });
|
const { wrapper } = getMountedComponent(defaultOrder, {}, () => {}, queryString);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
||||||
|
|
@ -507,7 +512,7 @@ describe('payment-page.vue', () => {
|
||||||
const queryString = {
|
const queryString = {
|
||||||
[queryStrings.DISPLAY_PAY_IN_ADVANCE_ALERT]: paymentMethods.AFTERPAY
|
[queryStrings.DISPLAY_PAY_IN_ADVANCE_ALERT]: paymentMethods.AFTERPAY
|
||||||
};
|
};
|
||||||
const wrapper = setupMocks({ queryString });
|
const { wrapper } = getMountedComponent(defaultOrder, {}, () => {}, queryString);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ export default {
|
||||||
},
|
},
|
||||||
getPremiumAppointmentTimeSlot(timeSlotData) {
|
getPremiumAppointmentTimeSlot(timeSlotData) {
|
||||||
const formattedPrice =
|
const formattedPrice =
|
||||||
`+${formatAmountInDollars(getPriceOfLineItem(this.premiumAppointmentFee, false))}`;
|
`+${formatAmountInDollars(getPriceOfLineItem(this.premiumAppointmentFee))}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Unique value is required for each <input> and the premium appoinment shares an id
|
// Unique value is required for each <input> and the premium appoinment shares an id
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ export default {
|
||||||
&& item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER)
|
&& item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER)
|
||||||
|| (priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER)
|
|| (priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER)
|
||||||
) {
|
) {
|
||||||
vapsPrice += getPriceOfLineItem(item, false);
|
vapsPrice += getPriceOfLineItem(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return vapsPrice;
|
return vapsPrice;
|
||||||
|
|
@ -206,7 +206,7 @@ export default {
|
||||||
|| (priceRainDefense
|
|| (priceRainDefense
|
||||||
&& item.partType.toUpperCase() === partTypeStrings.RAIN_DEFENSE)
|
&& item.partType.toUpperCase() === partTypeStrings.RAIN_DEFENSE)
|
||||||
) {
|
) {
|
||||||
vapsPrice += getPriceOfLineItem(item, false);
|
vapsPrice += getPriceOfLineItem(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return vapsPrice;
|
return vapsPrice;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import {
|
||||||
import partTypeStrings from '@/constants/part-type-strings';
|
import partTypeStrings from '@/constants/part-type-strings';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import bailoutCode from '@/constants/bailoutCode';
|
import bailoutCode from '@/constants/bailoutCode';
|
||||||
import partNumberStrings from "@/constants/part-number-strings";
|
import partNumberStrings from '@/constants/part-number-strings';
|
||||||
|
|
||||||
const storeId = 'main';
|
const storeId = 'main';
|
||||||
|
|
||||||
|
|
@ -276,17 +276,9 @@ export const useMainStore = defineStore({
|
||||||
hasExactlyOneChip: () => state.order.damage.numberOfChips === 1,
|
hasExactlyOneChip: () => state.order.damage.numberOfChips === 1,
|
||||||
isPolicyVehicle: () => state.order.vehicle.policyVehicleId != null,
|
isPolicyVehicle: () => state.order.vehicle.policyVehicleId != null,
|
||||||
hasWindshieldReplacement: (s) => {
|
hasWindshieldReplacement: (s) => {
|
||||||
const { damage } = s.order;
|
const { damage, lineItems } = s.order;
|
||||||
if (damage.isRepair) {
|
return !damage.isRepair
|
||||||
return false;
|
&& (lineItems.glassParts?.some((gp) => gp.partType === partTypeStrings.WINDSHIELD) ?? false);
|
||||||
}
|
|
||||||
|
|
||||||
const { glassParts } = s.order.lineItems;
|
|
||||||
if (!glassParts || glassParts.length === 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return glassParts.findIndex((gp) => gp.partType === 'WINDSHIELD') !== -1;
|
|
||||||
},
|
},
|
||||||
hasAnyNonWindshieldGlassParts: (s) => !s.order.policy.isDamageGlassOnly,
|
hasAnyNonWindshieldGlassParts: (s) => !s.order.policy.isDamageGlassOnly,
|
||||||
isMobileAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
isMobileAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
||||||
|
|
@ -1630,7 +1622,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.isNoComp || this.isITAC)) {
|
if (fee && !this.isUnverified && (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);
|
||||||
|
|
@ -1639,7 +1631,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.isNoComp || this.isITAC) && this.hasWindshieldReplacement) {
|
if (fee && !this.isUnverified && (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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue