|
6 | 6 | * Side Public License, v 1. |
7 | 7 | */ |
8 | 8 |
|
9 | | -import { FtrProviderContext } from 'test/functional/ftr_provider_context'; |
| 9 | +import { FtrService } from '../../ftr_provider_context'; |
10 | 10 |
|
11 | | -export function ManagementMenuProvider({ getService }: FtrProviderContext) { |
12 | | - const find = getService('find'); |
| 11 | +export class ManagementMenuService extends FtrService { |
| 12 | + private readonly find = this.ctx.getService('find'); |
13 | 13 |
|
14 | | - class ManagementMenu { |
15 | | - public async getSections() { |
16 | | - const sectionsElements = await find.allByCssSelector( |
17 | | - '.mgtSideBarNav > .euiSideNav__content > .euiSideNavItem' |
18 | | - ); |
19 | | - |
20 | | - const sections = []; |
| 14 | + public async getSections() { |
| 15 | + const sectionsElements = await this.find.allByCssSelector( |
| 16 | + '.mgtSideBarNav > .euiSideNav__content > .euiSideNavItem' |
| 17 | + ); |
21 | 18 |
|
22 | | - for (const el of sectionsElements) { |
23 | | - const sectionId = await (await el.findByClassName('euiSideNavItemButton')).getAttribute( |
24 | | - 'data-test-subj' |
25 | | - ); |
26 | | - const sectionLinks = await Promise.all( |
27 | | - (await el.findAllByCssSelector('.euiSideNavItem > a.euiSideNavItemButton')).map((item) => |
28 | | - item.getAttribute('data-test-subj') |
29 | | - ) |
30 | | - ); |
| 19 | + const sections = []; |
31 | 20 |
|
32 | | - sections.push({ sectionId, sectionLinks }); |
33 | | - } |
| 21 | + for (const el of sectionsElements) { |
| 22 | + const sectionId = await (await el.findByClassName('euiSideNavItemButton')).getAttribute( |
| 23 | + 'data-test-subj' |
| 24 | + ); |
| 25 | + const sectionLinks = await Promise.all( |
| 26 | + (await el.findAllByCssSelector('.euiSideNavItem > a.euiSideNavItemButton')).map((item) => |
| 27 | + item.getAttribute('data-test-subj') |
| 28 | + ) |
| 29 | + ); |
34 | 30 |
|
35 | | - return sections; |
| 31 | + sections.push({ sectionId, sectionLinks }); |
36 | 32 | } |
37 | | - } |
38 | 33 |
|
39 | | - return new ManagementMenu(); |
| 34 | + return sections; |
| 35 | + } |
40 | 36 | } |
0 commit comments