Merge pull request #1313 from Safelite/feature/Digital/CSR-1416

CSR-1416
This commit is contained in:
AMSNEHA 2023-08-21 14:42:55 +05:30 committed by GitHub
commit 515dfd2cd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 2 deletions

View file

@ -0,0 +1 @@
export const payWithInsuranceStates = ["AZ", "CT", "FL", "KY", "MA", "MN", "NY", "SC"];

View file

@ -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 }) {

View file

@ -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 {
@ -154,11 +154,18 @@ export default {
);
},
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;