From 93b1d489d13446754a2fb9c6ba267dd87a5abb52 Mon Sep 17 00:00:00 2001 From: hiteshkumar87 Date: Mon, 21 Aug 2023 13:38:05 +0530 Subject: [PATCH] CSR-1416 Quote page - Default to Insurance Tab if user Service zip is from certain States --- src/constants/pay-with-insurance-states.js | 1 + src/layouts/quote/quote.spec.js | 45 ++++++++++++++++++++++ src/layouts/quote/quote.vue | 13 +++++-- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/constants/pay-with-insurance-states.js diff --git a/src/constants/pay-with-insurance-states.js b/src/constants/pay-with-insurance-states.js new file mode 100644 index 000000000..e65589557 --- /dev/null +++ b/src/constants/pay-with-insurance-states.js @@ -0,0 +1 @@ +export const payWithInsuranceStates = ["AZ", "CT", "FL", "KY", "MA", "MN", "NY", "SC"]; diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index 6895b5d0b..b4a3df9fb 100644 --- a/src/layouts/quote/quote.spec.js +++ b/src/layouts/quote/quote.spec.js @@ -263,6 +263,9 @@ describe("quote.vue", () => { payment: { isInsurance: null, }, + serviceLocation: { + state: null, + }, }, }; wrapper.vm.$route = { query: { isInsurance: "true" } }; @@ -290,6 +293,9 @@ describe("quote.vue", () => { payment: { isInsurance: null, }, + serviceLocation: { + state: null, + }, }, }; wrapper.vm.$route = { query: { isInsurance: "false" } }; @@ -317,6 +323,9 @@ describe("quote.vue", () => { payment: { isInsurance: true, }, + serviceLocation: { + state: null, + }, }, }; // Ensure that query param isn't overriding selection @@ -345,6 +354,9 @@ describe("quote.vue", () => { payment: { isInsurance: false, }, + serviceLocation: { + state: null, + }, }, }; // Ensure that query param isn't overriding selection @@ -374,6 +386,9 @@ describe("quote.vue", () => { payment: { isInsurance: null, // Ensure that previous selection isn't overriding selection }, + serviceLocation: { + state: null, + }, }, }; mockTierOnePrice = 200; @@ -404,6 +419,9 @@ describe("quote.vue", () => { payment: { isInsurance: null, // Ensure that previous selection isn't overriding selection }, + serviceLocation: { + state: null, + }, }, }; mockTierOnePrice = 505; @@ -421,6 +439,33 @@ describe("quote.vue", () => { //Assert expect(wrapper.vm.isInsuranceSelected).toBe(true); }); + test("Should default to insurence if user Service zip is from certain States", async () => { + //Arrange + const { wrapper } = setupMocks({}); + store.getters = { + order: { + lineItems: { + glassParts: ["item", "item2"], + }, + payment: { + isInsurance: null, + }, + serviceLocation: { + state: "AZ", + }, + }, + }; + wrapper.vm.$route = { query: null }; + //Act + await quote.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "quote" } }, + undefined, + (c) => c(wrapper.vm) + ); + //Assert + expect(wrapper.vm.isInsuranceSelected).toBe(true); + }); }); function setupMocks({ customMountOptions }) { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index b17b0f3ac..eb4fe3917 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -67,7 +67,7 @@ import { errorMessages } from "@/constants/error-messages"; import { Form, defineRule } from "vee-validate"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { applicationConfig } from "@/constants/application-config"; - +import { payWithInsuranceStates } from "@/constants/pay-with-insurance-states"; defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); export default { @@ -153,12 +153,19 @@ export default { store.getters.order.referralNumber?.length !== 6 ); }, - getDefaultIsInsuranceSelectedValue(availableLineItems) { + getDefaultIsInsuranceSelectedValue(availableLineItems) { + const serviceLocationState = store.getters.order.serviceLocation.state; // Override if coming back from QuoteDetails. Remove override after Quote release const isInsuranceOverrideValue = this.$route.query?.isInsurance; const defaultIsInsuranceSelectedValue = this.$store.getters.order.payment.isInsurance; - if (isInsuranceOverrideValue != null) { + //Default to Insurance Tab if user Service zip is from certain States + if ( + serviceLocationState != null && + payWithInsuranceStates.find((item) => item === serviceLocationState) + ) + return true; + else if (isInsuranceOverrideValue != null) { return isInsuranceOverrideValue == "true"; } else if (defaultIsInsuranceSelectedValue != null) { return defaultIsInsuranceSelectedValue;