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 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. 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 the user is coming in via the Safelite.Com CTA
if (toRoute.query[queryStrings.START_TYPE] === "fmg") { if (toRoute.query[queryStrings.START_TYPE] === "fmg") {
// If they have an existing order, return 'heritage' for the page name. const latestPageRoute = await getLatestPageForRedirection();
if (existingHeritageOrder) { return latestPageRoute;
return fmgPageValues.HERITAGE;
}
return await getLatestPageForRedirection();
} }
// If navigating to a specific page, and that page is not part of the vin pages. // 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. // 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. // Get the latest page for redirection.
const latestPageRoute = await getLatestPageForRedirection(); const latestPageRoute = await getLatestPageForRedirection();
return latestPageRoute; 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. 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. // Create the order (or save existing order) when navigating to Heritage Funnel.
if (shouldSaveSession) { if (shouldSaveSession) {
await saveSession({ shouldAwaitSaveSessionQueue: true }); await saveSession({ shouldAwaitSaveSessionQueue: true });

View file

@ -35,7 +35,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_YEAR); expect(result).toBe(fmgPageValues.VEHICLE_YEAR);
@ -57,7 +57,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_MAKE); expect(result).toBe(fmgPageValues.VEHICLE_MAKE);
@ -80,7 +80,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_MODEL); expect(result).toBe(fmgPageValues.VEHICLE_MODEL);
@ -104,7 +104,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_STYLE); expect(result).toBe(fmgPageValues.VEHICLE_STYLE);
@ -129,7 +129,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE);
@ -169,7 +169,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.ESTIMATE); expect(result).toBe(fmgPageValues.ESTIMATE);
@ -199,7 +199,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.ESTIMATE); expect(result).toBe(fmgPageValues.ESTIMATE);
@ -229,7 +229,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS); expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS);
@ -259,7 +259,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS); expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS);
@ -289,7 +289,7 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.VEHICLE_PARTS); expect(result).toBe(fmgPageValues.VEHICLE_PARTS);
@ -319,29 +319,11 @@ describe("getPageToRouteExistingOrderTo", () => {
}); });
// Act // Act
const result = await getPageToRouteExistingOrderTo(toRoute, false); const result = await getPageToRouteExistingOrderTo(toRoute);
//Assert //Assert
expect(result).toBe(fmgPageValues.PART_QUESTIONS); 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", () => { describe("navigateToHeritageFunnel", () => {
@ -377,7 +359,7 @@ describe("navigateToHeritageFunnel", () => {
router.navigateToExternalUrl = jest.fn(); router.navigateToExternalUrl = jest.fn();
// Act // Act
await navigateToHeritageFunnel({}); await navigateToHeritageFunnel({ loadingModal: null, shouldSaveSession: true });
// Assert // Assert
expect(saveSessionFunction).toHaveBeenCalled(); expect(saveSessionFunction).toHaveBeenCalled();

View file

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

View file

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

View file

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

View file

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

View file

@ -68,17 +68,7 @@ const routes = [
: null : null
); );
const pageToRedirectTo = await getPageToRouteExistingOrderTo( const pageToRedirectTo = await getPageToRouteExistingOrderTo(to);
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);
}
// Assign our fmgPage so it will load normally like the other pages. // Assign our fmgPage so it will load normally like the other pages.
to.query.fmgPage = pageToRedirectTo; to.query.fmgPage = pageToRedirectTo;