From 9d21f8cb6169d7237a79a1bd936b044cad524b3d Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Mon, 9 Nov 2020 15:48:12 -0600 Subject: [PATCH 1/2] [Workplace Search] Consolidate groups routes This PR consolidates all of the groups route resgistration functions into a single export so that the `registerWorkplaceSearchRoutes` function only has to call the top-level routes --- .../routes/workplace_search/groups.test.ts | 8 ++++++++ .../server/routes/workplace_search/groups.ts | 10 ++++++++++ .../server/routes/workplace_search/index.ts | 18 ++---------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts index 2f244022be037..1aad51ea0ec9c 100644 --- a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts +++ b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts @@ -14,6 +14,7 @@ import { registerShareGroupRoute, registerAssignGroupRoute, registerBoostsGroupRoute, + registerGroupsRoutes, } from './groups'; describe('groups routes', () => { @@ -392,4 +393,11 @@ describe('groups routes', () => { }); }); }); + + describe('registerGroupsRoutes', () => { + it('runs without errors', () => { + const mockRouter = new MockRouter({} as any); + registerGroupsRoutes({ ...mockDependencies, router: mockRouter.router }); + }); + }); }); diff --git a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.ts b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.ts index 35c585eb9f781..fa01f983bbb89 100644 --- a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.ts +++ b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.ts @@ -223,3 +223,13 @@ export function registerBoostsGroupRoute({ } ); } + +export const registerGroupsRoutes = (dependencies: IRouteDependencies) => { + registerGroupsRoute(dependencies); + registerSearchGroupsRoute(dependencies); + registerGroupRoute(dependencies); + registerGroupUsersRoute(dependencies); + registerShareGroupRoute(dependencies); + registerAssignGroupRoute(dependencies); + registerBoostsGroupRoute(dependencies); +}; diff --git a/x-pack/plugins/enterprise_search/server/routes/workplace_search/index.ts b/x-pack/plugins/enterprise_search/server/routes/workplace_search/index.ts index a5ebcc0d05298..0edf0b980cf21 100644 --- a/x-pack/plugins/enterprise_search/server/routes/workplace_search/index.ts +++ b/x-pack/plugins/enterprise_search/server/routes/workplace_search/index.ts @@ -7,23 +7,9 @@ import { IRouteDependencies } from '../../plugin'; import { registerOverviewRoute } from './overview'; -import { - registerGroupsRoute, - registerSearchGroupsRoute, - registerGroupRoute, - registerGroupUsersRoute, - registerShareGroupRoute, - registerAssignGroupRoute, - registerBoostsGroupRoute, -} from './groups'; +import { registerGroupsRoutes } from './groups'; export const registerWorkplaceSearchRoutes = (dependencies: IRouteDependencies) => { registerOverviewRoute(dependencies); - registerGroupsRoute(dependencies); - registerSearchGroupsRoute(dependencies); - registerGroupRoute(dependencies); - registerGroupUsersRoute(dependencies); - registerShareGroupRoute(dependencies); - registerAssignGroupRoute(dependencies); - registerBoostsGroupRoute(dependencies); + registerGroupsRoutes(dependencies); }; From 37d10b36f2067983706ec9592d3e028bbc7416c3 Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Mon, 9 Nov 2020 16:01:45 -0600 Subject: [PATCH 2/2] Remove redundant test --- .../server/routes/workplace_search/groups.test.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts index 1aad51ea0ec9c..2f244022be037 100644 --- a/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts +++ b/x-pack/plugins/enterprise_search/server/routes/workplace_search/groups.test.ts @@ -14,7 +14,6 @@ import { registerShareGroupRoute, registerAssignGroupRoute, registerBoostsGroupRoute, - registerGroupsRoutes, } from './groups'; describe('groups routes', () => { @@ -393,11 +392,4 @@ describe('groups routes', () => { }); }); }); - - describe('registerGroupsRoutes', () => { - it('runs without errors', () => { - const mockRouter = new MockRouter({} as any); - registerGroupsRoutes({ ...mockDependencies, router: mockRouter.router }); - }); - }); });