diff --git a/client/src/features/rootV2/RootV2.tsx b/client/src/features/rootV2/RootV2.tsx index c00d9e312..76199358d 100644 --- a/client/src/features/rootV2/RootV2.tsx +++ b/client/src/features/rootV2/RootV2.tsx @@ -18,11 +18,19 @@ import cx from "classnames"; import { useEffect, useState } from "react"; -import { Route, Routes, useNavigate } from "react-router-dom-v5-compat"; +import { + Route, + Routes, + generatePath, + useNavigate, +} from "react-router-dom-v5-compat"; import ContainerWrap from "../../components/container/ContainerWrap"; import LazyNotFound from "../../not-found/LazyNotFound"; -import { RELATIVE_ROUTES } from "../../routing/routes.constants"; +import { + ABSOLUTE_ROUTES, + RELATIVE_ROUTES, +} from "../../routing/routes.constants"; import useAppDispatch from "../../utils/customHooks/useAppDispatch.hook"; import useAppSelector from "../../utils/customHooks/useAppSelector.hook"; import { setFlag } from "../../utils/feature-flags/featureFlags.slice"; @@ -149,6 +157,7 @@ export default function RootV2() { function GroupsV2Routes() { return ( + } /> }> } /> @@ -178,9 +187,23 @@ function HelpV2Routes() { ); } +function RedirectToSearch({ entityType }: { entityType: string }) { + const navigate = useNavigate(); + navigate( + { + pathname: generatePath(ABSOLUTE_ROUTES.v2.search), + search: `q=type:${entityType}`, + }, + { replace: true } + ); + + return null; +} + function ProjectsV2Routes() { return ( + } /> }> } /> diff --git a/tests/cypress/e2e/searchV2.spec.ts b/tests/cypress/e2e/searchV2.spec.ts index a9dad4e86..cd47d6117 100644 --- a/tests/cypress/e2e/searchV2.spec.ts +++ b/tests/cypress/e2e/searchV2.spec.ts @@ -61,4 +61,16 @@ describe("Search V2", () => { cy.getDataCy("search-sorting-select").select("Newest"); cy.getDataCy("search-header").contains("sort:created-desc"); }); + + it("/g redirects to search", () => { + fixtures.searchV2ListProjects(); + cy.visit("/g"); + cy.location("pathname").should("eq", "/search"); + }); + + it("/p redirects to search", () => { + fixtures.searchV2ListProjects(); + cy.visit("/p"); + cy.location("pathname").should("eq", "/search"); + }); });