Merge pull request #1334 from Safelite/feature/CSR-1625

CSR-1625
This commit is contained in:
CarlNation 2023-09-08 08:37:59 -04:00 committed by GitHub
commit d960b38602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 55 deletions

View file

@ -17,15 +17,11 @@ import router from "@/router";
drop them so they don't start at the beginning again. This method will return 'heritage' if
the user has an existing order and they come back in from the Safelite.com CTA.
*/
export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHeritageOrder = false) {
export async function getPageToRouteExistingOrderTo(toRoute = {}) {
// If the user is coming in via the Safelite.Com CTA
if (toRoute.query[queryStrings.START_TYPE] === "fmg") {
// If they have an existing order, return 'heritage' for the page name.
if (existingHeritageOrder) {
return fmgPageValues.HERITAGE;
}
return await getLatestPageForRedirection();
const latestPageRoute = await getLatestPageForRedirection();
return latestPageRoute;
}
// If navigating to a specific page, and that page is not part of the vin pages.
@ -42,7 +38,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
// If this is not a direct link to a page using fmgPage, not from Safelite.com CTA or this is a vin related page.
// Get the latest page for redirection.
const latestPageRoute = await getLatestPageForRedirection();
return latestPageRoute;
}
@ -50,7 +45,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
Used to navigate to the heritage funnel with the correct query string and url.
*/
export async function navigateToHeritageFunnel({ shouldSaveSession = true, loadingModal }) {
export async function navigateToHeritageFunnel({ shouldSaveSession, loadingModal }) {
// Create the order (or save existing order) when navigating to Heritage Funnel.
if (shouldSaveSession) {
await saveSession({ shouldAwaitSaveSessionQueue: true });

View file

@ -35,7 +35,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_YEAR);
@ -57,7 +57,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_MAKE);
@ -80,7 +80,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_MODEL);
@ -104,7 +104,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_STYLE);
@ -129,7 +129,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE);
@ -169,7 +169,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.ESTIMATE);
@ -199,7 +199,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.ESTIMATE);
@ -229,7 +229,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS);
@ -259,7 +259,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS);
@ -289,7 +289,7 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.VEHICLE_PARTS);
@ -319,29 +319,11 @@ describe("getPageToRouteExistingOrderTo", () => {
});
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, false);
const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert
expect(result).toBe(fmgPageValues.PART_QUESTIONS);
});
test("existing order > should return heritage", async () => {
// Arrange
const toRoute = {
query: {
[queryStrings.START_TYPE]: "fmg",
},
};
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
store.commit(storeMutations.UPDATE_MAKE, "acura");
// Act
const result = await getPageToRouteExistingOrderTo(toRoute, true);
// Assert
expect(result).toBe(fmgPageValues.HERITAGE);
});
});
describe("navigateToHeritageFunnel", () => {
@ -377,7 +359,7 @@ describe("navigateToHeritageFunnel", () => {
router.navigateToExternalUrl = jest.fn();
// Act
await navigateToHeritageFunnel({});
await navigateToHeritageFunnel({ loadingModal: null, shouldSaveSession: true });
// Assert
expect(saveSessionFunction).toHaveBeenCalled();

View file

@ -255,7 +255,10 @@ export default {
const vehicleChangedDuringPolicyLookupInHeritage =
payment.isInsurance && payment.insuranceCoverage.coverageStatus;
if (vehicleChangedDuringPolicyLookupInHeritage) {
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
navigateToHeritageFunnel({
shouldSaveSession: true,
loadingModal: this.$refs.loadingModal,
});
} else if (this.$store.getters.order.referralNumber?.length === 6) {
await this.navigateForwardWithSingleCarMatch();
} else if (this.isRepair) {

View file

@ -216,7 +216,10 @@ export default {
const payment = this.$store.getters.payment;
if (payment.isInsurance) {
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
navigateToHeritageFunnel({
shouldSaveSession: true,
loadingModal: this.$refs.loadingModal,
});
} else {
this.$router.navigateWithSaving(
this.navigationScenarios.CLICKED_FORWARD_WITH_CASH,

View file

@ -418,7 +418,10 @@ export default {
this.appointmentDateAndTime,
false
);
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
navigateToHeritageFunnel({
shouldSaveSession: true,
loadingModal: this.$refs.loadingModal,
});
},
updateSupportingItems() {

View file

@ -447,9 +447,15 @@ export default {
const payment = store.getters.payment;
if (store.getters.order.referralNumber?.length === 6) {
navigateToHeritageFunnel({ loadingModal: self.$refs.loadingModal });
navigateToHeritageFunnel({
shouldSaveSession: true,
loadingModal: self.$refs.loadingModal,
});
} else if (payment.isInsurance && payment.insuranceCoverage.isVerified) {
navigateToHeritageFunnel({ loadingModal: self.$refs.loadingModal });
navigateToHeritageFunnel({
shouldSaveSession: true,
loadingModal: self.$refs.loadingModal,
});
} else {
self.$router.navigateWithSaving(
self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,

View file

@ -68,17 +68,7 @@ const routes = [
: null
);
const pageToRedirectTo = await getPageToRouteExistingOrderTo(
to,
loadSessionResponse
);
// If getPageToRouteExistingOrderTo determines that the return user needs to
// go back to heritage funnel, send them there and stop our current navigation.
if (pageToRedirectTo === "heritage") {
await navigateToHeritageFunnel();
return next(false);
}
const pageToRedirectTo = await getPageToRouteExistingOrderTo(to);
// Assign our fmgPage so it will load normally like the other pages.
to.query.fmgPage = pageToRedirectTo;