Skip to content

Commit

Permalink
fix dashboard view path check
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Jan 25, 2024
1 parent 4704007 commit 2c5a076
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions x-pack/plugins/security_solution/public/helpers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isSubPluginAvailable,
getSubPluginRoutesByCapabilities,
getField,
isDashboardViewPath,
} from './helpers';
import type { StartedSubPlugins } from './types';
import {
Expand Down Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/public/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c5a076

Please sign in to comment.