diff --git a/x-pack/plugins/security_solution/public/helpers.test.tsx b/x-pack/plugins/security_solution/public/helpers.test.tsx index a305434a1ff11..1e053c84ba91d 100644 --- a/x-pack/plugins/security_solution/public/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/helpers.test.tsx @@ -15,6 +15,7 @@ import { isSubPluginAvailable, getSubPluginRoutesByCapabilities, getField, + isDashboardViewPath, } from './helpers'; import type { StartedSubPlugins } from './types'; import { @@ -257,3 +258,23 @@ describe('public helpers getField', () => { expect(signalQuery).toEqual(aadQuery); }); }); + +describe('isDashboardViewPath', () => { + it('returns true for dashboard view path', () => { + expect(isDashboardViewPath('/dashboards/59c085c3-394d-49ab-a83a-56a63f38aa5f')).toEqual(true); + }); + + it('returns true for dashboard edit path', () => { + expect(isDashboardViewPath('/dashboards/59c085c3-394d-49ab-a83a-56a63f38aa5f/edit')).toEqual( + true + ); + }); + + it('returns true for dashboard creation path', () => { + expect(isDashboardViewPath('/dashboards/create')).toEqual(true); + }); + + it('returns false for dashboard listing path', () => { + expect(isDashboardViewPath('/dashboards')).toEqual(false); + }); +}); diff --git a/x-pack/plugins/security_solution/public/helpers.tsx b/x-pack/plugins/security_solution/public/helpers.tsx index b245a6ae2f6bc..9a4b6418ad2fa 100644 --- a/x-pack/plugins/security_solution/public/helpers.tsx +++ b/x-pack/plugins/security_solution/public/helpers.tsx @@ -176,7 +176,7 @@ export const isDetectionsPath = (pathname: string): boolean => { export const isDashboardViewPath = (pathname: string): boolean => matchPath(pathname, { - path: `/${DASHBOARDS_PATH}/:id`, + path: `${DASHBOARDS_PATH}/:detailName`, exact: false, strict: false, }) != null;