From 7270c3bf40b1c1c5f302de8fb910a61aa0979321 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 26 May 2021 12:10:14 -0700 Subject: [PATCH] [ftr] migrate management services to FtrService class (#100521) Co-authored-by: spalger --- test/functional/services/index.ts | 4 +- test/functional/services/management/index.ts | 2 +- .../services/management/management_menu.ts | 44 +++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/test/functional/services/index.ts b/test/functional/services/index.ts index a483dd4f21ba9..b2e0a3e0f473e 100644 --- a/test/functional/services/index.ts +++ b/test/functional/services/index.ts @@ -32,7 +32,7 @@ import { FlyoutProvider } from './flyout'; import { GlobalNavService } from './global_nav'; import { InspectorProvider } from './inspector'; import { FieldEditorService } from './field_editor'; -import { ManagementMenuProvider } from './management'; +import { ManagementMenuService } from './management'; import { QueryBarProvider } from './query_bar'; import { RemoteProvider } from './remote'; import { RenderableProvider } from './renderable'; @@ -83,7 +83,7 @@ export const services = { savedQueryManagementComponent: SavedQueryManagementComponentProvider, elasticChart: ElasticChartService, supertest: KibanaSupertestProvider, - managementMenu: ManagementMenuProvider, + managementMenu: ManagementMenuService, monacoEditor: MonacoEditorProvider, MenuToggle: MenuToggleProvider, }; diff --git a/test/functional/services/management/index.ts b/test/functional/services/management/index.ts index 988ac06f1ca18..8fc1a88ee5892 100644 --- a/test/functional/services/management/index.ts +++ b/test/functional/services/management/index.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export { ManagementMenuProvider } from './management_menu'; +export { ManagementMenuService } from './management_menu'; diff --git a/test/functional/services/management/management_menu.ts b/test/functional/services/management/management_menu.ts index eb8c6901ffa66..738a8d55439ec 100644 --- a/test/functional/services/management/management_menu.ts +++ b/test/functional/services/management/management_menu.ts @@ -6,35 +6,31 @@ * Side Public License, v 1. */ -import { FtrProviderContext } from 'test/functional/ftr_provider_context'; +import { FtrService } from '../../ftr_provider_context'; -export function ManagementMenuProvider({ getService }: FtrProviderContext) { - const find = getService('find'); +export class ManagementMenuService extends FtrService { + private readonly find = this.ctx.getService('find'); - class ManagementMenu { - public async getSections() { - const sectionsElements = await find.allByCssSelector( - '.mgtSideBarNav > .euiSideNav__content > .euiSideNavItem' - ); - - const sections = []; + public async getSections() { + const sectionsElements = await this.find.allByCssSelector( + '.mgtSideBarNav > .euiSideNav__content > .euiSideNavItem' + ); - for (const el of sectionsElements) { - const sectionId = await (await el.findByClassName('euiSideNavItemButton')).getAttribute( - 'data-test-subj' - ); - const sectionLinks = await Promise.all( - (await el.findAllByCssSelector('.euiSideNavItem > a.euiSideNavItemButton')).map((item) => - item.getAttribute('data-test-subj') - ) - ); + const sections = []; - sections.push({ sectionId, sectionLinks }); - } + for (const el of sectionsElements) { + const sectionId = await (await el.findByClassName('euiSideNavItemButton')).getAttribute( + 'data-test-subj' + ); + const sectionLinks = await Promise.all( + (await el.findAllByCssSelector('.euiSideNavItem > a.euiSideNavItemButton')).map((item) => + item.getAttribute('data-test-subj') + ) + ); - return sections; + sections.push({ sectionId, sectionLinks }); } - } - return new ManagementMenu(); + return sections; + } }