commit
This commit is contained in:
parent
ef9c7af480
commit
240e450f74
3 changed files with 17 additions and 22 deletions
|
|
@ -135,7 +135,7 @@ export default {
|
|||
const glassPartsForStore = partsLookup.data.glassPieceParts;
|
||||
|
||||
// TODO KO delete for quote mvp
|
||||
this.navigateForward(glassPartsForStore, null, this.shouldGoToHeritageQuote);
|
||||
this.navigateForward(glassPartsForStore, null);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { routingTable } from "@/router/router-constants/routing-table";
|
|||
import { useMainStore } from '@/store';
|
||||
import eventBus from "@/helpers/event-bus/event-bus";
|
||||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
|
||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||
|
||||
|
|
@ -87,14 +88,14 @@ async function GetRouteInfoFromPageName(pageName) {
|
|||
return routeData;
|
||||
};
|
||||
|
||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) => {
|
||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
||||
|
||||
navigate(scenario, currentRoute, false, optionalQuery, optionalParams);
|
||||
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
|
||||
|
||||
}
|
||||
|
||||
// Navigate to the next route, depending on the scenario.
|
||||
function navigate (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) {
|
||||
function navigate (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
|
||||
if (!scenario) {
|
||||
console.error("No scenario provided. Please review the routing table.");
|
||||
return;
|
||||
|
|
@ -109,6 +110,16 @@ function navigate (scenario, currentRoute, optionalQuery = {}, optionalParams =
|
|||
}
|
||||
|
||||
if (matchingScenarioMap.destinationIssPageValue) {
|
||||
|
||||
// Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object
|
||||
const existingPageDataForPage = useMainStore().pageData(matchingScenarioMap.destinationIssPageValue);
|
||||
baseMixin.methods.savePageDataToStore(
|
||||
matchingScenarioMap.destinationIssPageValue,
|
||||
Object.keys(optionalPageData).length > 0
|
||||
? optionalPageData
|
||||
: existingPageDataForPage ?? {}
|
||||
);
|
||||
|
||||
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our issPage one.
|
||||
router.push({
|
||||
name: "root",
|
||||
|
|
|
|||
|
|
@ -1,35 +1,19 @@
|
|||
import router from "@/router/";
|
||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||
|
||||
import { createApp } from 'vue';
|
||||
import { createPinia } from "pinia";
|
||||
import App from '@/App.vue';
|
||||
|
||||
const originalLocation = global.location
|
||||
|
||||
describe("Router", () => {
|
||||
|
||||
beforeAll(() => {
|
||||
const vueApp = createApp(App);
|
||||
const pinia = createPinia();
|
||||
vueApp.use(pinia);
|
||||
})
|
||||
|
||||
it("Should change the location when navigating to external site", () => {
|
||||
delete global.location
|
||||
global.location = { assign: jest.fn() }
|
||||
|
||||
let scenario = navigationScenarios.CLICKED_TEST;
|
||||
let currentRoute = { query: { issPage: issPageValues.WELCOME_PAGE }};
|
||||
|
||||
router.navigate(scenario, currentRoute);
|
||||
|
||||
expect(global.location.assign).toHaveBeenCalledTimes(1)
|
||||
|
||||
global.location = originalLocation;
|
||||
});
|
||||
|
||||
|
||||
it("Should push next view when navigating locally", () => {
|
||||
let scenario = navigationScenarios.CLICKED_FORWARD;
|
||||
let currentRoute = { query: { issPage: issPageValues.WELCOME_PAGE }};
|
||||
|
|
@ -37,7 +21,7 @@ describe("Router", () => {
|
|||
router.push = jest.fn();
|
||||
|
||||
router.navigate(scenario, currentRoute);
|
||||
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.VEHICLE_YEAR)
|
||||
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.VEHICLE_YEAR);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue