CASH-291
CASH-291 The issue here is that when computing the tier one price for determining which tab to select. we are including the service package discount of $50 bringing the tier one price to $287(337-50), which is less than $300 and causing the cash tab to be selected. This is not the tier one price we show but only used in the computation for determining which tab to default.
This commit is contained in:
parent
75345b9f9d
commit
eedcf4dfdd
7 changed files with 121 additions and 91 deletions
|
|
@ -361,13 +361,16 @@ export default {
|
||||||
if (!this.customerQuestions.emailOrSms) {
|
if (!this.customerQuestions.emailOrSms) {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (vinPagesMixin.methods.isPhoneNumber(this.customerQuestions.emailOrSms)) {
|
if (vinPagesMixin.methods.isPhoneNumber(this.customerQuestions.emailOrSms)) {
|
||||||
const phone = this.customerQuestions.emailOrSms.replace(/[()]/g, "");
|
const phone = this.customerQuestions.emailOrSms.replace(/[()]/g, "");
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
||||||
} else {
|
} else {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.customerQuestions.emailOrSms, false);
|
await this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_EMAIL,
|
||||||
|
this.customerQuestions.emailOrSms,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,105 +1,102 @@
|
||||||
import { shallowMount } from '@vue/test-utils';
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import InsuranceCompany from '@/layouts/insurance-company/insurance-company.vue';
|
import InsuranceCompany from "@/layouts/insurance-company/insurance-company.vue";
|
||||||
import { applicationConfig } from '@/constants/application-config.js';
|
import { applicationConfig } from "@/constants/application-config.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
|
jest.mock("@/store", () => ({
|
||||||
jest.mock('@/store', () => ({
|
|
||||||
getters: {
|
getters: {
|
||||||
order: {
|
order: {
|
||||||
payment: {
|
payment: {
|
||||||
parentAccountNumber: '12345',
|
parentAccountNumber: "12345",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var mockRouter = {
|
var mockRouter = {
|
||||||
navigateWithoutSaving: jest.fn(),
|
navigateWithoutSaving: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.mock('@/mixins/base-mixin.js', () => ({
|
jest.mock("@/mixins/base-mixin.js", () => ({
|
||||||
methods: {
|
methods: {
|
||||||
navigateWithoutSaving: jest.fn(),
|
navigateWithoutSaving: jest.fn(),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
navigationScenarios: {
|
navigationScenarios: {
|
||||||
CLICKED_BACK: 'clicked_back',
|
CLICKED_BACK: "clicked_back",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("insurance-company.vue", () => {
|
describe("insurance-company.vue", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Reset the store's parentAccountNumber before each test
|
// Reset the store's parentAccountNumber before each test
|
||||||
store.getters.order.payment.parentAccountNumber = '12345';
|
store.getters.order.payment.parentAccountNumber = "12345";
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return true when parentAccountNumber matches CASH_PARENT_ACCOUNT_NUMBER', () => {
|
test("should return true when parentAccountNumber matches CASH_PARENT_ACCOUNT_NUMBER", () => {
|
||||||
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345";
|
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345";
|
||||||
const wrapper = shallowMount(InsuranceCompany, {
|
const wrapper = shallowMount(InsuranceCompany, {
|
||||||
global: {
|
global: {
|
||||||
mocks: {
|
mocks: {
|
||||||
$store: store
|
$store: store,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.vm.isCashParentAccountNumber()).toBe(true);
|
expect(wrapper.vm.isCashParentAccountNumber()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return false when parentAccountNumber does not match CASH_PARENT_ACCOUNT_NUMBER', () => {
|
test("should return false when parentAccountNumber does not match CASH_PARENT_ACCOUNT_NUMBER", () => {
|
||||||
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345";
|
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345";
|
||||||
store.getters.order.payment.parentAccountNumber = '67890';
|
store.getters.order.payment.parentAccountNumber = "67890";
|
||||||
const wrapper = shallowMount(InsuranceCompany, {
|
const wrapper = shallowMount(InsuranceCompany, {
|
||||||
global: {
|
global: {
|
||||||
mocks: {
|
mocks: {
|
||||||
$store: store,
|
$store: store,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.vm.isCashParentAccountNumber()).toBe(false);
|
expect(wrapper.vm.isCashParentAccountNumber()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should call navigateWithoutSaving with { isCashSelected: true } when forceCashSelection is true', () => {
|
test("should call navigateWithoutSaving with { isCashSelected: true } when forceCashSelection is true", () => {
|
||||||
const wrapper = shallowMount(InsuranceCompany, {
|
const wrapper = shallowMount(InsuranceCompany, {
|
||||||
global: {
|
global: {
|
||||||
mocks: {
|
mocks: {
|
||||||
$store: store,
|
$store: store,
|
||||||
$router: mockRouter,
|
$router: mockRouter,
|
||||||
},
|
},
|
||||||
mixins: [baseMixin],
|
mixins: [baseMixin],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
wrapper.vm.backButtonAction(true);
|
wrapper.vm.backButtonAction(true);
|
||||||
expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith(
|
expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||||
wrapper.vm.navigationScenarios.CLICKED_BACK,
|
wrapper.vm.navigationScenarios.CLICKED_BACK,
|
||||||
wrapper.vm.$route,
|
wrapper.vm.$route,
|
||||||
{ isCashSelected: true }
|
{ isCashSelected: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should call navigateWithoutSaving with no extra parameter when forceCashSelection is false', () => {
|
test("should call navigateWithoutSaving with no extra parameter when forceCashSelection is false", () => {
|
||||||
const wrapper = shallowMount(InsuranceCompany, {
|
const wrapper = shallowMount(InsuranceCompany, {
|
||||||
global: {
|
global: {
|
||||||
mocks: {
|
mocks: {
|
||||||
$store: store,
|
$store: store,
|
||||||
$router: mockRouter,
|
$router: mockRouter,
|
||||||
|
},
|
||||||
|
mixins: [baseMixin],
|
||||||
},
|
},
|
||||||
mixins: [baseMixin],
|
});
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper.vm.backButtonAction(false);
|
wrapper.vm.backButtonAction(false);
|
||||||
expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith(
|
expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||||
wrapper.vm.navigationScenarios.CLICKED_BACK,
|
wrapper.vm.navigationScenarios.CLICKED_BACK,
|
||||||
wrapper.vm.$route
|
wrapper.vm.$route
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -315,8 +315,7 @@ export default {
|
||||||
if (!this.emailOrSms) {
|
if (!this.emailOrSms) {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
||||||
const phone = this.emailOrSms.replace(/[()]/g, "");
|
const phone = this.emailOrSms.replace(/[()]/g, "");
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
||||||
|
|
|
||||||
|
|
@ -361,24 +361,28 @@ export default {
|
||||||
)
|
)
|
||||||
: baseMixin.methods.filterOutFees(availableLineItems);
|
: baseMixin.methods.filterOutFees(availableLineItems);
|
||||||
|
|
||||||
|
const lineItemsNoDiscount =
|
||||||
|
baseMixin.methods.filterOutServicePackageDiscountPart(
|
||||||
|
lineItemsForCalculatingPrice
|
||||||
|
);
|
||||||
|
|
||||||
if (isInsuranceFromQueryString != null) {
|
if (isInsuranceFromQueryString != null) {
|
||||||
if (isInsuranceFromQueryString.toLowerCase() === "true") {
|
if (isInsuranceFromQueryString.toLowerCase() === "true") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tierOnePrice = baseMixin.methods.getTierOnePackagePrice(lineItemsForCalculatingPrice);
|
const tierOnePrice =
|
||||||
|
baseMixin.methods.getTierOnePackagePrice(lineItemsNoDiscount);
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
{
|
{
|
||||||
if (store.getters.applicationUser.loggingOption) {
|
if (store.getters.applicationUser.loggingOption) {
|
||||||
console.log(new Date() + " tierOnePrice type: " + typeof tierOnePrice);
|
console.log(new Date() + " quote tierOnePrice comparison: " + tierOnePrice + " > " + insuranceThreshold + "=" + (tierOnePrice > insuranceThreshold));
|
||||||
console.log(new Date() + " insuranceThreshold type: " + typeof insuranceThreshold);
|
|
||||||
console.log(new Date() + " tierOnePrice comparison: " + tierOnePrice + " > " + insuranceThreshold + "=" + (tierOnePrice > insuranceThreshold));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare base price vs arbitrary threshold (representing insurance price)
|
// compare base price vs arbitrary threshold (representing insurance price)
|
||||||
return (tierOnePrice > insuranceThreshold);
|
return tierOnePrice > insuranceThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -334,13 +334,20 @@ export default {
|
||||||
if (!this.emailOrSms) {
|
if (!this.emailOrSms) {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
||||||
const phone = this.emailOrSms.replace(/[()]/g, "");
|
const phone = this.emailOrSms.replace(/[()]/g, "");
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
await this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_PHONE_NUMBER,
|
||||||
|
phone,
|
||||||
|
false
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false);
|
await this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_EMAIL,
|
||||||
|
this.emailOrSms,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,13 +398,20 @@ export default {
|
||||||
if (!this.emailOrSms) {
|
if (!this.emailOrSms) {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) {
|
||||||
const phone = this.emailOrSms.replace(/[()]/g, "");
|
const phone = this.emailOrSms.replace(/[()]/g, "");
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false);
|
await this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_PHONE_NUMBER,
|
||||||
|
phone,
|
||||||
|
false
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false);
|
await this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_EMAIL,
|
||||||
|
this.emailOrSms,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,13 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
let totalPrice = this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice, false);
|
let totalPrice = this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice, false);
|
||||||
|
// prettier-ignore
|
||||||
|
{
|
||||||
|
if (store.getters.applicationUser.loggingOption) {
|
||||||
|
console.log(new Date() + " base-mixin getTierOnePackagePrice lineItemsToPrice: " + JSON.stringify(lineItemsToPrice));
|
||||||
|
console.log(new Date() + " base-mixin getTierOnePackagePrice totalPrice: " + totalPrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
return totalPrice;
|
return totalPrice;
|
||||||
},
|
},
|
||||||
filterOutFees(lineItems) {
|
filterOutFees(lineItems) {
|
||||||
|
|
@ -103,6 +110,12 @@ export default {
|
||||||
});
|
});
|
||||||
return filteredLineItems;
|
return filteredLineItems;
|
||||||
},
|
},
|
||||||
|
filterOutServicePackageDiscountPart(lineItems) {
|
||||||
|
const filteredLineItems = lineItems?.filter((item) => {
|
||||||
|
return !item?.partType?.includes(partTypeStrings.SERVICE_PACKAGE_DISCOUNT);
|
||||||
|
});
|
||||||
|
return filteredLineItems;
|
||||||
|
},
|
||||||
filterOutRecalibration(lineItems) {
|
filterOutRecalibration(lineItems) {
|
||||||
return getItemsWithoutRecalParts(lineItems);
|
return getItemsWithoutRecalParts(lineItems);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue