Removing some unnecessary files. Moving some others.
This commit is contained in:
parent
b769e74b6c
commit
7bc6458449
9 changed files with 6 additions and 263 deletions
|
|
@ -27,11 +27,6 @@ const endpoints = {
|
||||||
url: "/vehicle/api/v1/vehicle/styles",
|
url: "/vehicle/api/v1/vehicle/styles",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
GetPageData: {
|
|
||||||
url: (applicationAbbreviation, pageName) =>
|
|
||||||
`/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
|
|
||||||
method: "GET",
|
|
||||||
},
|
|
||||||
LogExperimentExposureIfAssigned: {
|
LogExperimentExposureIfAssigned: {
|
||||||
url: "/experiments/api/v1/experiments/log-exposure",
|
url: "/experiments/api/v1/experiments/log-exposure",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
|
||||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
|
||||||
import { useMainStore } from "@/store";
|
|
||||||
|
|
||||||
import router from "@/router";
|
|
||||||
|
|
||||||
/*
|
|
||||||
If the user has visited the funnel before this method will determine the bets place to
|
|
||||||
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) {
|
|
||||||
// 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 issPageValues.HERITAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await getLatestPageForRedirection();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If navigating to a specific page, and that page is not part of the vin pages.
|
|
||||||
// Return that page, so that it can navigate like normal.
|
|
||||||
if (toRoute.query[queryStrings.FMG_PAGE] !== undefined && !isVinRelatedPage(toRoute)) {
|
|
||||||
return overrideYmmsDirectionIfNeeded(toRoute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Logic for getting the last "valid" page a user visited.
|
|
||||||
*/
|
|
||||||
async function getLatestPageForRedirection() {
|
|
||||||
// If this is a non-CTA navigation, determine where to send the user based on page prerequisites.
|
|
||||||
// This also works if a user has a 'fmg' start_type query string but no current order.
|
|
||||||
// That shouldn't happen, but it's possible.
|
|
||||||
const store = useMainStore();
|
|
||||||
|
|
||||||
const vehicleMakeComponent = await getLazyLoadedComponent(issPageValues.VEHICLE_MAKE);
|
|
||||||
const vehicleModelComponent = await getLazyLoadedComponent(issPageValues.VEHICLE_MODEL);
|
|
||||||
const vehicleStyleComponent = await getLazyLoadedComponent(issPageValues.VEHICLE_STYLE);
|
|
||||||
const vehicleDamageComponent = await getLazyLoadedComponent(issPageValues.VEHICLE_DAMAGE);
|
|
||||||
const estimateComponent = await getLazyLoadedComponent(issPageValues.ESTIMATE);
|
|
||||||
const vinLookupComponent = await getLazyLoadedComponent(issPageValues.VIN_LOOKUP);
|
|
||||||
const partQuestionsComponent = await getLazyLoadedComponent(issPageValues.PART_QUESTIONS);
|
|
||||||
const vehiclePartsComponent = await getLazyLoadedComponent(issPageValues.VEHICLE_PARTS);
|
|
||||||
const moldingQuestionsComponent = await getLazyLoadedComponent(issPageValues.MOLDING_QUESTIONS);
|
|
||||||
const capabilityQuestionsComponent = await getLazyLoadedComponent(
|
|
||||||
issPageValues.CAPABILITY_QUESTIONS
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_YEAR;
|
|
||||||
} else if (!vehicleModelComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_MAKE;
|
|
||||||
} else if (!vehicleStyleComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_MODEL;
|
|
||||||
} else if (!vehicleDamageComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_STYLE;
|
|
||||||
} else if (!estimateComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_DAMAGE;
|
|
||||||
} else {
|
|
||||||
if (capabilityQuestionsComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.CAPABILITY_QUESTIONS;
|
|
||||||
} else if (moldingQuestionsComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.MOLDING_QUESTIONS;
|
|
||||||
} else if (vehiclePartsComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.VEHICLE_PARTS;
|
|
||||||
} else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) {
|
|
||||||
return issPageValues.PART_QUESTIONS;
|
|
||||||
} else if (
|
|
||||||
vinLookupComponent.methods.arePagePrerequisitesValid() &&
|
|
||||||
!store.damage.isRepair
|
|
||||||
) {
|
|
||||||
return issPageValues.VIN_LOOKUP;
|
|
||||||
} else {
|
|
||||||
return issPageValues.ESTIMATE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Overrides functionality to go to the YMMS pages in certain cases.
|
|
||||||
If this is not one of the cases, it returns the 'to' fmgPage value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function overrideYmmsDirectionIfNeeded(toRoute) {
|
|
||||||
const issPageValue = toRoute.query[queryStrings.ISS_PAGE];
|
|
||||||
|
|
||||||
if (useMainStore.getters.payment.insuranceCoverage.isVerified) {
|
|
||||||
switch (issPageValue) {
|
|
||||||
case issPageValues.VEHICLE_YEAR:
|
|
||||||
case issPageValues.VEHICLE_MAKE:
|
|
||||||
case issPageValues.VEHICLE_MODEL:
|
|
||||||
case issPageValues.VEHICLE_STYLE: {
|
|
||||||
return issPageValues.VEHICLE_DAMAGE;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return issPageValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return issPageValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Determine if the page is a vin related page.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function isVinRelatedPage(toRoute) {
|
|
||||||
const issPageValue = toRoute.query[queryStrings.FMG_PAGE];
|
|
||||||
|
|
||||||
return (
|
|
||||||
issPageValue === issPageValues.VIN_LOOKUP ||
|
|
||||||
issPageValue === issPageValues.LICENSE_PLATE_LOOKUP ||
|
|
||||||
issPageValue === issPageValues.ADDRESS_LOOKUP ||
|
|
||||||
issPageValue === issPageValues.ADDRESS_VEHICLES ||
|
|
||||||
issPageValue === issPageValues.ESTIMATE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getLazyLoadedComponent(pageName) {
|
|
||||||
return (await lazyLoadComponent(pageName)()).default;
|
|
||||||
}
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
import {
|
|
||||||
getPageToRouteExistingOrderTo
|
|
||||||
} from "@/helpers/heritage-integration/navigation-helper";
|
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
|
||||||
|
|
||||||
import { setupMocksForJsFiles, getMockOrderInfo } from "@/helpers/unit-test-helper.js";
|
|
||||||
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
|
||||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
|
||||||
|
|
||||||
import router from "@/router";
|
|
||||||
|
|
||||||
|
|
||||||
// Mock Lazy Load
|
|
||||||
jest.mock("@/router/dynamic-routing/component-loader.js", () => ({
|
|
||||||
lazyLoadComponent: jest.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe("getPageToRouteExistingOrderTo", () => {
|
|
||||||
test("should return vehicle-year", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[issPageValues.VEHICLE_MAKE]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(issPageValues.VEHICLE_YEAR);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return vehicle-make", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[issPageValues.VEHICLE_MAKE]: true,
|
|
||||||
[issPageValues.VEHICLE_MODEL]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(issPageValues.VEHICLE_MAKE);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return vehicle-model", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[issPageValues.VEHICLE_MAKE]: true,
|
|
||||||
[issPageValues.VEHICLE_MODEL]: true,
|
|
||||||
[issPageValues.VEHICLE_STYLE]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(issPageValues.VEHICLE_MODEL);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return vehicle-style", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[issPageValues.VEHICLE_MAKE]: true,
|
|
||||||
[issPageValues.VEHICLE_MODEL]: true,
|
|
||||||
[issPageValues.VEHICLE_STYLE]: true,
|
|
||||||
[issPageValues.VEHICLE_DAMAGE]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(issPageValues.VEHICLE_STYLE);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* `arePagePrerequisitesValidObject` is an object where the keys are fmgPageValue names and the values are booleans that indicate
|
|
||||||
* whether arePagePrerequisitesValid is true or false
|
|
||||||
*/
|
|
||||||
function mockLazyLoadComponentReturnValues(arePagePrerequisitesValidObject = {}) {
|
|
||||||
lazyLoadComponent.mockImplementation((pageName) => {
|
|
||||||
return async () => {
|
|
||||||
return Promise.resolve({
|
|
||||||
default: {
|
|
||||||
methods: {
|
|
||||||
arePagePrerequisitesValid: jest
|
|
||||||
.fn()
|
|
||||||
.mockReturnValueOnce(arePagePrerequisitesValidObject[pageName]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js";
|
import { getFunnelCookie } from "@/helpers/cookie-helper.js";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Method to determine if our analytics session has timed out or not.
|
Method to determine if our analytics session has timed out or not.
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import * as cookieHelper from "@/helpers/heritage-integration/cookie-helper";
|
import * as cookieHelper from "@/helpers/cookie-helper";
|
||||||
import {
|
import {
|
||||||
isAnalyticsSessionStillActive,
|
isAnalyticsSessionStillActive,
|
||||||
isSavedSessionStillActive,
|
isSavedSessionStillActive,
|
||||||
getDateForSavedSessionTimeout,
|
getDateForSavedSessionTimeout,
|
||||||
} from "@/helpers/heritage-integration/session-helper";
|
} from "@/helpers/session-helper";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
describe("isAnalyticsSessionStillActive", () => {
|
describe("isAnalyticsSessionStillActive", () => {
|
||||||
|
|
@ -7,7 +7,7 @@ import baseMixin from "@/mixins/base-mixin";
|
||||||
import {
|
import {
|
||||||
getCookieDomainValue,
|
getCookieDomainValue,
|
||||||
setCookieProperties,
|
setCookieProperties,
|
||||||
} from "@/helpers/heritage-integration/cookie-helper";
|
} from "@/helpers/cookie-helper";
|
||||||
import {
|
import {
|
||||||
analyticsPageEvents,
|
analyticsPageEvents,
|
||||||
GaCategories,
|
GaCategories,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {
|
||||||
getDeviceIdValue,
|
getDeviceIdValue,
|
||||||
getSessionIdValue,
|
getSessionIdValue,
|
||||||
getSessionKeyValue,
|
getSessionKeyValue,
|
||||||
} from "@/helpers/heritage-integration/cookie-helper";
|
} from "@/helpers/cookie-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { experimentSettings } from "@/constants/experiments";
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { endpoints } from "@/constants/endpoints.js";
|
import { endpoints } from "@/constants/endpoints.js";
|
||||||
import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper";
|
import { getDateForSavedSessionTimeout } from "@/helpers/session-helper";
|
||||||
import globalMethods from "@/global-methods";
|
import globalMethods from "@/global-methods";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue