Skip to content

Commit

Permalink
[ftr] migrate management services to FtrService class (#100521)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored May 26, 2021
1 parent c166dae commit 7270c3b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions test/functional/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -83,7 +83,7 @@ export const services = {
savedQueryManagementComponent: SavedQueryManagementComponentProvider,
elasticChart: ElasticChartService,
supertest: KibanaSupertestProvider,
managementMenu: ManagementMenuProvider,
managementMenu: ManagementMenuService,
monacoEditor: MonacoEditorProvider,
MenuToggle: MenuToggleProvider,
};
2 changes: 1 addition & 1 deletion test/functional/services/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export { ManagementMenuProvider } from './management_menu';
export { ManagementMenuService } from './management_menu';
44 changes: 20 additions & 24 deletions test/functional/services/management/management_menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 7270c3b

Please sign in to comment.