summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/dashboard.po.ts
blob: 42d63ef44117c70aa1b1090715bc29846798d046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { PageHelper } from '../page-helper.po';

export class DashboardPageHelper extends PageHelper {
  pages = { index: { url: '#/dashboard', id: 'cd-dashboard' } };

  infoGroupTitle(index: number) {
    return cy.get('.info-group-title').its(index).text();
  }

  clickInfoCardLink(cardName: string) {
    cy.get(`cd-info-card[cardtitle="${cardName}"]`).contains('a', cardName).click();
  }

  infoCard(indexOrTitle: number | string) {
    cy.get('cd-info-card').as('infoCards');

    if (typeof indexOrTitle === 'number') {
      return cy.get('@infoCards').its(indexOrTitle);
    } else {
      return cy.contains('cd-info-card a', indexOrTitle).parent().parent().parent().parent();
    }
  }

  infoCardBodyText(infoCard: string) {
    return this.infoCard(infoCard).find('.card-text').text();
  }

  infoCardBody(infoCard: string) {
    return this.infoCard(infoCard).find('.card-text');
  }
}