]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/e2e/ui/dashboard.po.ts
d/control: depend on python3-yaml for ceph-mgr
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / e2e / ui / dashboard.po.ts
1 import { $, $$, by, ElementFinder } from 'protractor';
2 import { PageHelper } from '../page-helper.po';
3
4 export class DashboardPageHelper extends PageHelper {
5 pages = {
6 index: '/#/dashboard'
7 };
8
9 async infoGroupTitle(index: number): Promise<string> {
10 return $$('.info-group-title')
11 .get(index)
12 .getText();
13 }
14
15 async clickInfoCardLink(cardName: string): Promise<void> {
16 await $(`cd-info-card[cardtitle="${cardName}"]`)
17 .element(by.linkText(cardName))
18 .click();
19 }
20
21 async infoCard(indexOrTitle: number | string): Promise<ElementFinder> {
22 let infoCards = $$('cd-info-card');
23 if (typeof indexOrTitle === 'number') {
24 if ((await infoCards.count()) <= indexOrTitle) {
25 return Promise.reject(
26 `No element found for index ${indexOrTitle}. Elements array has ` +
27 `only ${await infoCards.count()} elements.`
28 );
29 }
30 return infoCards.get(indexOrTitle);
31 } else if (typeof indexOrTitle === 'string') {
32 infoCards = infoCards.filter(
33 async (e) => (await e.$('.card-title').getText()) === indexOrTitle
34 );
35 if ((await infoCards.count()) === 0) {
36 return Promise.reject(`No element found for title "${indexOrTitle}"`);
37 }
38 return infoCards.first();
39 }
40 }
41
42 async infoCardBodyText(
43 infoCard: ElementFinder | Promise<ElementFinder> | string
44 ): Promise<string> {
45 let _infoCard: ElementFinder;
46 if (typeof infoCard === 'string') {
47 _infoCard = await this.infoCard(infoCard);
48 } else {
49 _infoCard = typeof infoCard.then === 'function' ? await infoCard : infoCard;
50 }
51 return _infoCard.$('.card-text').getText();
52 }
53 }