Merge pull request #656 from Safelite/feature/CSR-722

Added flag to 'navigate' method so that we can specify that the order…
This commit is contained in:
Leah Schumann 2022-08-19 15:32:47 -04:00 committed by GitHub
commit 3175ba4251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 154 additions and 111 deletions

View file

@ -192,7 +192,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.backButtonAction(); await wrapper.vm.backButtonAction();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
}); });
@ -285,7 +285,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, undefined, {}, {}, carsFound); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, undefined, {}, {}, carsFound);
}); });
test("if the car entered matches one of the vehicles found but the zip is NOT serviceable, do not navigate forward", async () => { test("if the car entered matches one of the vehicles found but the zip is NOT serviceable, do not navigate forward", async () => {
@ -365,7 +365,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.navigateForward(carsFound); await wrapper.vm.navigateForward(carsFound);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, undefined, {}, { "displayVehicleChangeAlert": true }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, undefined, {}, { "displayVehicleChangeAlert": true });
}); });
@ -626,7 +626,9 @@ function setupMocks({ isZipValid = true, isZipServiceable = true, lookupVinbyAdd
], ],
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
store: { store: {
getters: { getters: {

View file

@ -140,7 +140,7 @@ export default {
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -309,11 +309,11 @@ export default {
// If a different vehicle is found than the one entered and the selected glass is not available for that vehicle then navigate back to "vehicle-damage" // If a different vehicle is found than the one entered and the selected glass is not available for that vehicle then navigate back to "vehicle-damage"
// display vehicle changed alert on that page. // display vehicle changed alert on that page.
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle && matchingCars.length === 1) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle && matchingCars.length === 1) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true}); this.$router.navigateWithSaving(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true});
} else if (matchingCars.length === 1) { } else if (matchingCars.length === 1) {
await this.navigateForwardWithSingleCarMatch(); await this.navigateForwardWithSingleCarMatch();
} else { } else {
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound); this.$router.navigateWithSaving(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound);
} }
}, },

View file

@ -53,7 +53,7 @@ describe("addressVehicles.vue", () => {
test("Should navigate to CLICKED_BACK if backButtonAction is run", async () => { test("Should navigate to CLICKED_BACK if backButtonAction is run", async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
wrapper.vm.$router.navigate = jest.fn(); wrapper.vm.$router.navigateWithoutSaving = jest.fn();
// Act // Act
await wrapper.setData({ await wrapper.setData({
@ -62,7 +62,7 @@ describe("addressVehicles.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toBeCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toBeCalled();
wrapper.unmount(); wrapper.unmount();
}); });
@ -111,7 +111,7 @@ describe("addressVehicles.vue", () => {
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn(); wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
wrapper.vm.lookupVin = jest.fn(() => Promise.reject(lookupVinResponse)); wrapper.vm.lookupVin = jest.fn(() => Promise.reject(lookupVinResponse));
wrapper.vm.$router.navigate = jest.fn(); wrapper.vm.$router.navigateWithSaving = jest.fn();
wrapper.vm.updateCustomerInfo = jest.fn().mockImplementation(()=> {}); wrapper.vm.updateCustomerInfo = jest.fn().mockImplementation(()=> {});
// Act // Act
@ -131,7 +131,7 @@ describe("addressVehicles.vue", () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
wrapper.vm.$router.navigate = jest.fn(); wrapper.vm.$router.navigateWithSaving = jest.fn();
// Act // Act
await wrapper.setData({ await wrapper.setData({
@ -142,7 +142,7 @@ describe("addressVehicles.vue", () => {
await wrapper.vm.navigateForward(); await wrapper.vm.navigateForward();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toBeCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toBeCalledTimes(1);
wrapper.unmount(); wrapper.unmount();
}); });

View file

@ -162,7 +162,7 @@ export default {
return false; return false;
}, },
backButtonAction() { backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async forwardButtonAction() { async forwardButtonAction() {
@ -184,7 +184,7 @@ export default {
}, },
async navigateForward() { async navigateForward() {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,this.$route,{},{[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true },); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD,this.$route,{},{[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true },);
} else { } else {
await this.navigateForwardWithSingleCarMatch(); await this.navigateForwardWithSingleCarMatch();
} }

View file

@ -76,7 +76,7 @@ describe("estimate.vue", () => {
expect(arePagePrerequisitesValid).toBe(false); expect(arePagePrerequisitesValid).toBe(false);
}); });
test("After selecting provide my home address on ForwardButtonAction triggers a router.navigate", async () => { test("After selecting provide my home address on ForwardButtonAction triggers a router.navigateWithSaving", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -88,11 +88,11 @@ describe("estimate.vue", () => {
wrapper.vm.forwardButtonAction(); wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
test("After selecting provide my manual vin on ForwardButtonAction triggers a router.navigate", async () => { test("After selecting provide my manual vin on ForwardButtonAction triggers a router.navigateWithSaving", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -104,11 +104,11 @@ describe("estimate.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
test("BackButtonAction triggers a router.navigate change", async () => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -124,10 +124,10 @@ describe("estimate.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
}); });
test("Provide my license plate on ForwardButtonAction triggers a router.navigate", async () => { test("Provide my license plate on ForwardButtonAction triggers a router.navigateWithSaving", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -139,7 +139,7 @@ describe("estimate.vue", () => {
wrapper.vm.forwardButtonAction(); wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
@ -152,6 +152,8 @@ function setupMocks({
mountOptionsMockData = { mountOptionsMockData = {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
}, },
}) { }) {

View file

@ -87,7 +87,7 @@ export default {
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -95,19 +95,19 @@ export default {
async forwardButtonAction() { async forwardButtonAction() {
if (this.selectedVinLookupMethod === vinLookupMethodSelections.MANUALVIN) { if (this.selectedVinLookupMethod === vinLookupMethodSelections.MANUALVIN) {
await this.dispatchStoreAction(storeActions.CLEAR_VIN); await this.dispatchStoreAction(storeActions.CLEAR_VIN);
return this.$router.navigate( return this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_MANUAL_VIN, this.navigationScenarios.SELECTED_MANUAL_VIN,
this.$route this.$route
); );
} }
if (this.selectedVinLookupMethod === vinLookupMethodSelections.LICENSEPLATE) { if (this.selectedVinLookupMethod === vinLookupMethodSelections.LICENSEPLATE) {
return this.$router.navigate( return this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_LICENSE_PLATE, this.navigationScenarios.SELECTED_LICENSE_PLATE,
this.$route this.$route
); );
} }
if (this.selectedVinLookupMethod === vinLookupMethodSelections.HOMEADDRESS) { if (this.selectedVinLookupMethod === vinLookupMethodSelections.HOMEADDRESS) {
return this.$router.navigate( return this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_HOME_ADDRESS, this.navigationScenarios.SELECTED_HOME_ADDRESS,
this.$route this.$route
); );

View file

@ -87,7 +87,7 @@ describe("license-plate-lookup.vue", () => {
}); });
describe("navigation", () => { describe("navigation", () => {
test("BackButtonAction triggers a router.navigate change", async () => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -103,7 +103,7 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
}); });
describe("on forwardButtonAction click", () => { describe("on forwardButtonAction click", () => {
@ -212,7 +212,7 @@ describe("license-plate-lookup.vue", () => {
}); });
describe("navigateForward", () => { describe("navigateForward", () => {
test("navigate should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when navigateForward is called", async () => { test("navigateWithSaving should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when navigateForward is called", async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -232,7 +232,7 @@ describe("license-plate-lookup.vue", () => {
await wrapper.vm.navigateForward(); await wrapper.vm.navigateForward();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
test("navigateForwardWithSingleCarMatch should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => { test("navigateForwardWithSingleCarMatch should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
@ -549,6 +549,8 @@ function setupMocks({
...mountOptionsMockData, ...mountOptionsMockData,
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithoutSaving: jest.fn(),
navigateWithSaving: jest.fn()
}, },
store: { store: {
getters: { getters: {

View file

@ -177,7 +177,7 @@ export default {
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -298,7 +298,7 @@ export default {
}, },
async navigateForward() { async navigateForward() {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
} else { } else {
await this.navigateForwardWithSingleCarMatch(); await this.navigateForwardWithSingleCarMatch();
} }

View file

@ -125,7 +125,7 @@ export default {
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -156,7 +156,7 @@ export default {
if (hasCapabilityQuestions) { if (hasCapabilityQuestions) {
// if has capability questions // if has capability questions
// go to capability-questions page // go to capability-questions page
this.$router.navigate(this.navigationScenarios.HAS_CAPABILITY_QUESTIONS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore}); this.$router.navigateWithSaving(this.navigationScenarios.HAS_CAPABILITY_QUESTIONS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore});
} else { } else {
// if single parts only // if single parts only
const collectedGlassParts = this.reducedGlassPartsArray(glassNameAndPartsForStore); const collectedGlassParts = this.reducedGlassPartsArray(glassNameAndPartsForStore);

View file

@ -40,7 +40,7 @@ export default {
methods: { methods: {
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );

View file

@ -57,7 +57,7 @@ jest.mock("@/store", () => ({
describe("vehicle-damage.vue", () => { describe("vehicle-damage.vue", () => {
describe("navigation", () => { describe("navigation", () => {
test("BackButtonAction triggers a router.navigate change", async () => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -73,7 +73,7 @@ describe("vehicle-damage.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
}); });
@ -118,7 +118,7 @@ describe("vehicle-damage.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
pageHeaderWidgetHeaderText: "", pageHeaderWidgetHeaderText: "",
mountOptionsMockData: { mountOptionsMockData: {
router: { navigate: jest.fn(), }, router: { navigate: jest.fn(), navigateWithSaving: jest.fn(), },
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },], actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },],
store: { store: {
getters: { getters: {
@ -158,7 +158,7 @@ describe("vehicle-damage.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace); expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace);
expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith(storeActions.GET_DAMAGE_OPTIONS, {"carId": "C00000000"}); expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith(storeActions.GET_DAMAGE_OPTIONS, {"carId": "C00000000"});
}); });
@ -217,7 +217,7 @@ describe("vehicle-damage.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
pageHeaderWidgetHeaderText: "", pageHeaderWidgetHeaderText: "",
mountOptionsMockData: { mountOptionsMockData: {
router: { navigate: jest.fn(), }, router: { navigate: jest.fn(), navigateWithSaving: jest.fn(), },
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },], actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },],
store: { store: {
getters: { getters: {
@ -248,7 +248,7 @@ describe("vehicle-damage.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace); expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace);
expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith(storeActions.GET_DAMAGE_OPTIONS, {"carId": "C00000000"}); expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith(storeActions.GET_DAMAGE_OPTIONS, {"carId": "C00000000"});
}); });
@ -690,6 +690,8 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo
var mountOptionsMockDataDefault = { var mountOptionsMockDataDefault = {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithoutSaving: jest.fn(),
navigateWithSaving: jest.fn(),
}, },
route: { route: {
params: { params: {

View file

@ -170,7 +170,7 @@ export default {
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -293,10 +293,10 @@ export default {
// If vin already exists, navigate directly to vin-lookup // If vin already exists, navigate directly to vin-lookup
if(store.getters.vehicle.vin) { if(store.getters.vehicle.vin) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.$route); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.$route);
} }
else { else {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.$route); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.$route);
} }
}, },

View file

@ -58,13 +58,14 @@ describe("vehicle-make.vue", () => {
}); });
describe("vehicle-make.vue", () => { describe("vehicle-make.vue", () => {
test("BackButtonAction triggers a router.navigate change", async (done) => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => {
//Arrange //Arrange
const { wrapper, apiPromise } = setupMocks({ const { wrapper, apiPromise } = setupMocks({
pageHeaderWidgetHeaderText: "Select a make to get started", pageHeaderWidgetHeaderText: "Select a make to get started",
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
}, },
}); });
@ -81,7 +82,7 @@ describe("vehicle-make.vue", () => {
//Assert //Assert
apiPromise.finally(() => { apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
done(); done();
}); });
}); });

View file

@ -70,7 +70,7 @@ export default {
methods: { methods: {
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -86,7 +86,7 @@ export default {
watch: { watch: {
selectedMake(make) { selectedMake(make) {
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false);
this.$router.navigate( this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_MAKE, this.navigationScenarios.SELECTED_MAKE,
this.$route this.$route
); );

View file

@ -56,13 +56,14 @@ describe("vehicle-model.vue", () => {
}); });
describe("vehicle-model.vue", () => { describe("vehicle-model.vue", () => {
test("BackButtonAction triggers a router.navigate change", async (done) => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => {
//Arrange //Arrange
const { wrapper, apiPromise } = setupMocks({ const { wrapper, apiPromise } = setupMocks({
pageHeaderWidgetHeaderText: "Select a model to get started", pageHeaderWidgetHeaderText: "Select a model to get started",
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithoutSaving: jest.fn()
}, },
}, },
}); });
@ -77,7 +78,7 @@ describe("vehicle-model.vue", () => {
await nextTick(); await nextTick();
//Assert //Assert
apiPromise.finally(() => { apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
done(); done();
}); });
}); });

View file

@ -71,7 +71,7 @@ export default {
methods: { methods: {
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -87,7 +87,7 @@ export default {
watch: { watch: {
selectedModel(model) { selectedModel(model) {
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MODEL, model, false); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MODEL, model, false);
this.$router.navigate( this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_MODEL, this.navigationScenarios.SELECTED_MODEL,
this.$route this.$route
); );

View file

@ -78,7 +78,9 @@ describe("vehicle-parts.vue", () => {
{ {
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -116,7 +118,9 @@ describe("vehicle-parts.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -153,7 +157,9 @@ describe("vehicle-parts.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -180,13 +186,15 @@ describe("vehicle-parts.vue", () => {
expect(wrapper.vm.glassParts).toEqual({ "Rear-Stationary": { "Rear": ['DB12209YPYNOEM'] } }); expect(wrapper.vm.glassParts).toEqual({ "Rear-Stationary": { "Rear": ['DB12209YPYNOEM'] } });
}); });
test("User had part questions > BackButtonAction triggers a router.navigate change with correct scenario", async () => { test("User had part questions > BackButtonAction triggers a router.navigateWithoutSaving change with correct scenario", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -228,17 +236,19 @@ describe("vehicle-parts.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_TO_GO_TO_PART_QUESTIONS, wrapper.vm.$route); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_TO_GO_TO_PART_QUESTIONS, wrapper.vm.$route);
}); });
test("User did not have part questions > BackButtonAction triggers a router.navigate change with correct scenario", async () => { test("User did not have part questions > BackButtonAction triggers a router.navigateWithoutSaving change with correct scenario", async () => {
//Arrange //Arrange
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -267,11 +277,11 @@ describe("vehicle-parts.vue", () => {
wrapper.vm.backButtonAction(); wrapper.vm.backButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_TO_GO_TO_VIN_LOOKUP, wrapper.vm.$route); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_TO_GO_TO_VIN_LOOKUP, wrapper.vm.$route);
}); });
test("ForwardButtonAction triggers a router.navigate change if there are child part questions", async () => { test("ForwardButtonAction triggers a router.navigateWithSaving change if there are child part questions", async () => {
//Arrange //Arrange
store.getters.pageData.mockReturnValueOnce({ store.getters.pageData.mockReturnValueOnce({
@ -317,7 +327,9 @@ describe("vehicle-parts.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -344,10 +356,10 @@ describe("vehicle-parts.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
test("ForwardButtonAction triggers a router.navigate change if there are capability questions", async () => { test("ForwardButtonAction triggers a router.navigateWithSaving change if there are capability questions", async () => {
//Arrange //Arrange
store.getters.pageData.mockReturnValueOnce({ store.getters.pageData.mockReturnValueOnce({
@ -375,7 +387,9 @@ describe("vehicle-parts.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {
@ -408,7 +422,7 @@ describe("vehicle-parts.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
}); });
test("ForwardButtonAction saves selected parts to store if no molding or capability questions", async () => { test("ForwardButtonAction saves selected parts to store if no molding or capability questions", async () => {
@ -421,7 +435,9 @@ describe("vehicle-parts.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
route: { route: {
query: { query: {

View file

@ -66,13 +66,15 @@ describe("vehicle-style.vue", () => {
}); });
describe("vehicle-style.vue", () => { describe("vehicle-style.vue", () => {
test("BackButtonAction triggers a router.navigate change", async (done) => { test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => {
//Arrange //Arrange
const { wrapper, apiPromise } = setupMocks({ const { wrapper, apiPromise } = setupMocks({
pageHeaderWidgetHeaderText: "Select a style to get started", pageHeaderWidgetHeaderText: "Select a style to get started",
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
}, },
}); });
@ -89,7 +91,7 @@ describe("vehicle-style.vue", () => {
//Assert //Assert
apiPromise.finally(() => { apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
done(); done();
}); });
}); });

View file

@ -100,7 +100,7 @@ export default {
methods: { methods: {
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
this.$router.navigate( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_BACK, this.navigationScenarios.CLICKED_BACK,
this.$route this.$route
); );
@ -128,7 +128,7 @@ export default {
selectedStyle(style) { selectedStyle(style) {
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_STYLE, style, false); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_STYLE, style, false);
this.setVehicle().then(() => { this.setVehicle().then(() => {
this.$router.navigate( this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_STYLE, this.navigationScenarios.SELECTED_STYLE,
this.$route this.$route
); );

View file

@ -90,7 +90,7 @@ export default {
selectedYear(year) { selectedYear(year) {
const parsedYear = parseInt(year); const parsedYear = parseInt(year);
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
this.$router.navigate( this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_YEAR, this.navigationScenarios.SELECTED_YEAR,
this.$route this.$route
); );

View file

@ -155,7 +155,7 @@ describe("vin-lookup.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
customMountOptions: { customMountOptions: {
router: { router: {
navigate: jest.fn() navigateWithSaving: jest.fn()
} }
} }
}); });
@ -169,8 +169,8 @@ describe("vin-lookup.vue", () => {
await wrapper.vm.navigateForward(); await wrapper.vm.navigateForward();
//Assert //Assert
expect(wrapper.vm.$router.navigate).toBeCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toBeCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, wrapper.vm.$route, expect.anything(), expect.anything()); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, wrapper.vm.$route, expect.anything(), expect.anything());
}) })
test("carId matches => navigateForwardWithSingleCarMatch", async () => { test("carId matches => navigateForwardWithSingleCarMatch", async () => {

View file

@ -211,10 +211,10 @@ export default {
}, },
backButtonAction() { backButtonAction() {
if (this.$store.getters.vehicle.vin) { if (this.$store.getters.vehicle.vin) {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route);
} }
else { else {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
} }
}, },
@ -331,7 +331,7 @@ export default {
}, },
async navigateForward(){ async navigateForward(){
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }); this.$router.navigateWithSaving(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
} else { } else {
await this.navigateForwardWithSingleCarMatch(); await this.navigateForwardWithSingleCarMatch();
} }

View file

@ -75,16 +75,16 @@ export default {
const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions); const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions);
if (hasPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.PART_QUESTIONS)) { if (hasPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.PART_QUESTIONS)) {
self.$router.navigate(self.navigationScenarios.HAS_PART_QUESTIONS, self.$route, {}, {}, {partsOrQuestions: partsOrQuestions}); self.$router.navigateWithSaving(self.navigationScenarios.HAS_PART_QUESTIONS, self.$route, {}, {}, {partsOrQuestions: partsOrQuestions});
} }
else if (hasGlassLocationWithMultipleParts && this.currentPageComesBeforePage(currentPage, fmgPageValues.VEHICLE_PARTS)) { else if (hasGlassLocationWithMultipleParts && this.currentPageComesBeforePage(currentPage, fmgPageValues.VEHICLE_PARTS)) {
// if multiple parts on any glass // if multiple parts on any glass
// go to vehicle-parts page and pass the partsData // go to vehicle-parts page and pass the partsData
self.$router.navigate(self.navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE,self.$route,{},{},{partsOrQuestions: partsOrQuestions}); self.$router.navigateWithSaving(self.navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE,self.$route,{},{},{partsOrQuestions: partsOrQuestions});
} else if (hasChildPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.MOLDING_QUESTIONS)) { } else if (hasChildPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.MOLDING_QUESTIONS)) {
// if any childpart questions // if any childpart questions
// go to molding-questions page and pass the partsData // go to molding-questions page and pass the partsData
self.$router.navigate(self.navigationScenarios.HAS_MOLDING_QUESTIONS,self.$route,{},{},{partsOrQuestions: partsOrQuestions}); self.$router.navigateWithSaving(self.navigationScenarios.HAS_MOLDING_QUESTIONS,self.$route,{},{},{partsOrQuestions: partsOrQuestions});
} else if (hasCapabilityQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.CAPABILITY_QUESTIONS)) { } else if (hasCapabilityQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.CAPABILITY_QUESTIONS)) {
// if has capability questions // if has capability questions
// go to capability-questions page and pass the partsData // go to capability-questions page and pass the partsData
@ -103,7 +103,7 @@ export default {
}) })
}); });
self.$router.navigate(self.navigationScenarios.HAS_CAPABILITY_QUESTIONS, self.$route, {}, {}, { partsOrQuestions, capabilityQuestions }); self.$router.navigateWithSaving(self.navigationScenarios.HAS_CAPABILITY_QUESTIONS, self.$route, {}, {}, { partsOrQuestions, capabilityQuestions });
} else { } else {
// if single parts only // if single parts only
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
@ -139,7 +139,7 @@ export default {
backNavigationScenario = navigationScenarios.CLICKED_BACK_TO_GO_TO_PART_QUESTIONS; backNavigationScenario = navigationScenarios.CLICKED_BACK_TO_GO_TO_PART_QUESTIONS;
} }
this.$router.navigate( this.$router.navigateWithoutSaving(
backNavigationScenario, backNavigationScenario,
this.$route this.$route
); );

View file

@ -192,8 +192,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
test("multiple glass locations have part questions => go to parts-questions", async () => { test("multiple glass locations have part questions => go to parts-questions", async () => {
@ -300,8 +300,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
test("multiple glass locations selected, one has part question => go to parts-questions", async () => { test("multiple glass locations selected, one has part question => go to parts-questions", async () => {
@ -400,8 +400,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
test("a selected glass location has part questions and multiple parts => go to parts-questions", async () => { test("a selected glass location has part questions and multiple parts => go to parts-questions", async () => {
@ -548,8 +548,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_PART_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
}); });
@ -590,8 +590,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
test("multiple glass locations selected, one of them has multiple parts => go to vehicle parts", async () => { test("multiple glass locations selected, one of them has multiple parts => go to vehicle parts", async () => {
@ -696,8 +696,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
test("multiple glass locations selected, multiple have multiple parts => go to vehicle-parts", async () => { test("multiple glass locations selected, multiple have multiple parts => go to vehicle-parts", async () => {
@ -868,8 +868,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
}); });
@ -921,8 +921,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_MOLDING_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_MOLDING_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
}); });
}); });
@ -956,8 +956,8 @@ describe("vehicle-questions-mixin", () => {
await wrapper.vm.navigateForward(partsOrQuestions); await wrapper.vm.navigateForward(partsOrQuestions);
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.HAS_CAPABILITY_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions, capabilityQuestions: [] }); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(navigationScenarios.HAS_CAPABILITY_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions, capabilityQuestions: [] });
}); });
}); });
@ -1117,7 +1117,7 @@ function setupMocks({ fmgPage = fmgPageValues.VIN_LOOKUP }) {
const mocks = getMountOptions({ const mocks = getMountOptions({
router: { router: {
navigate: jest.fn() navigate: jest.fn(), navigateWithSaving: jest.fn(), navigateWithSaving: jest.fn()
}, },
store: { store: {
commit: jest.fn(), commit: jest.fn(),

View file

@ -41,7 +41,14 @@ function setupMocks({ partsOrQuestions = [] }) {
], ],
}); });
const mocks = getMountOptions({}); const mocks = getMountOptions({
router: {
navigate: jest.fn(), navigateWithSaving: jest.fn(), navigateWithoutSaving: jest.fn(),
},
store: {
commit: jest.fn()
}
});
const mockVinComponent = { const mockVinComponent = {
components: { loadingModal }, components: { loadingModal },

View file

@ -132,6 +132,13 @@ router.afterEach((to, from) => {
// Update lastPageVisited in the store // Update lastPageVisited in the store
store.commit(storeMutations.UPDATE_LAST_PAGE_VISITED, to.name); store.commit(storeMutations.UPDATE_LAST_PAGE_VISITED, to.name);
// If saving on navigation is requested, check for saved SessionId or EmailAddress to determine if saving is appropriate
if (eval(to.params.isSavingNavigation)) {
if (store.getters.applicationUser.savedSessionId || store.getters.order.customer?.emailAddress) {
saveOrder();
}
}
// Push page view to GA // Push page view to GA
analyticsMixin.methods.pushPageViewToGA(); analyticsMixin.methods.pushPageViewToGA();
@ -140,8 +147,12 @@ router.afterEach((to, from) => {
}); });
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData) => { router.navigateWithoutSaving = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData); navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
}
router.navigateWithSaving = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
navigate(scenario, currentRoute, true, optionalQuery, optionalParams, optionalPageData);
} }
router.navigateToExternalUrl = (url, optionalQuery = {}) => { router.navigateToExternalUrl = (url, optionalQuery = {}) => {
@ -157,7 +168,7 @@ router.overrideNavigation = (scenario, currentRoute, next, optionalQuery = {}, o
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.
async function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData) { async function navigate(scenario, currentRoute, isSavingNavigation, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
if (!scenario) { if (!scenario) {
console.error("No scenario provided. Please review the routing table."); console.error("No scenario provided. Please review the routing table.");
return; return;
@ -174,10 +185,7 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue); const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue);
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData ? optionalPageData : existingPageDataForPage ?? {}); baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData ? optionalPageData : existingPageDataForPage ?? {});
// if cookie and referralNumber/Date exists OR an emailAddress has been saved optionalParams.isSavingNavigation = isSavingNavigation;
if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.order.customer?.emailAddress) {
saveOrder();
}
router.push({ router.push({
name: "root", name: "root",