changes for reviews

This commit is contained in:
Jason Wheeler 2022-09-23 12:16:15 -04:00
parent 548a50ae48
commit 09c6744dd8
5 changed files with 19 additions and 35 deletions

View file

@ -10,10 +10,10 @@
export default { export default {
name: 'vehicle-year', name: 'vehicle-year',
components: { navButton }, components: { navButton },
data: () => { data() {
return { return {
navigationScenarios, navigationScenarios,
}
} }
} }
}
</script> </script>

View file

@ -12,7 +12,7 @@
export default { export default {
name: "welcome-page", name: "welcome-page",
components: { navButton }, components: { navButton },
data: () => { data() {
return { return {
navigationScenarios, navigationScenarios,
} }

View file

@ -1,9 +1,10 @@
import { createWebHistory, createRouter } from "vue-router"; import { createWebHistory, createRouter } from "vue-router";
import { lazyLoadComponent } from "./dynamic-routing/component-loader"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader";
import { endpoints } from "../constants/mock-endpoints"; import { endpoints } from "@/constants/mock-endpoints";
import globalMethods from "@/global-methods"; import globalMethods from "@/global-methods";
import {issPageValues} from '@/router/router-constants/issPage-values'; import {issPageValues} from '@/router/router-constants/issPage-values';
import { routingTable } from "@/router/router-constants/routing-table"; import { routingTable } from "@/router/router-constants/routing-table";
import { useMainStore } from '@/store';
const routes = [ const routes = [
{ {
@ -79,15 +80,21 @@ async function GetRouteInfoFromPageName(pageName) {
return routeData; return routeData;
}; };
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) => {
navigate(scenario, currentRoute, false, optionalQuery, optionalParams);
}
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.
router.navigate = async function (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) { function navigate (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) {
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;
} }
// Match our maps up and navigate if we have a destination. // Match our maps up and navigate if we have a destination.
const matchingScenarioMap = router.getNavigationMap(scenario, currentRoute); const matchingScenarioMap = getNavigationMap(scenario, currentRoute);
if (!matchingScenarioMap){ if (!matchingScenarioMap){
console.error("No matching scenario found. Please review the routing table."); console.error("No matching scenario found. Please review the routing table.");
@ -124,10 +131,10 @@ function navigateToUrl(url, optionalQuery = {}) {
}; };
// Get navigation map depending on the scenario and the current 'page' you're on. // Get navigation map depending on the scenario and the current 'page' you're on.
router.getNavigationMap = function (scenario, currentRoute) { function getNavigationMap (scenario, currentRoute) {
const issPageValue = currentRoute.query.issPage; const issPageValue = currentRoute.query.issPage;
try { try {
const matchedQueryValue = routingTable() const matchedQueryValue = routingTable(useMainStore())
.filter( .filter(
(item) => (item) =>
item.issPageValue === issPageValue && item.issPageValue === issPageValue &&

View file

@ -1,23 +0,0 @@
import router from "@/router"
describe("router getNavigationMap", () => {
test("should return correct destinationUrl for welcome-page and CLICKED_TEST scenario", function() {
const currentRoute = { query: {issPage: "welcome-page"}};
expect(router.getNavigationMap("CLICKED_TEST", currentRoute)).toEqual({"destinationUrl": "https://www.google.com", "scenario": "CLICKED_TEST"});
});
test("should return undefined with bad issPage", function() {
const currentRoute = { query: {issPage: "badRoute"}};
expect(router.getNavigationMap("CLICKED_TEST", currentRoute)).toBeUndefined;
});
test("should return undefined with missing scenario", function() {
const currentRoute = { query: {issPage: "welcome-page"}};
expect(router.getNavigationMap("MISSING_SCENARIO", currentRoute)).toBeUndefined;
});
});

View file

@ -2,7 +2,7 @@ import { issPageValues } from "@/router/router-constants/issPage-values";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
// Get store from router/index.js instead of importing it here to get updated values // Get store from router/index.js instead of importing it here to get updated values
const routingTable = function() { const routingTable = function(store) {
return [ return [
{ {
issPageValue: issPageValues.VEHICLE_YEAR, issPageValue: issPageValues.VEHICLE_YEAR,