]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/dashboard.e2e-spec.ts
import ceph 15.2.14
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / ui / dashboard.e2e-spec.ts
1 import { IscsiPageHelper } from '../block/iscsi.po';
2 import { HostsPageHelper } from '../cluster/hosts.po';
3 import { MonitorsPageHelper } from '../cluster/monitors.po';
4 import { OSDsPageHelper } from '../cluster/osds.po';
5 import { PageHelper } from '../page-helper.po';
6 import { PoolPageHelper } from '../pools/pools.po';
7 import { DaemonsPageHelper } from '../rgw/daemons.po';
8 import { DashboardPageHelper } from './dashboard.po';
9
10 describe('Dashboard Main Page', () => {
11 const dashboard = new DashboardPageHelper();
12 const daemons = new DaemonsPageHelper();
13 const hosts = new HostsPageHelper();
14 const osds = new OSDsPageHelper();
15 const pools = new PoolPageHelper();
16 const monitors = new MonitorsPageHelper();
17 const iscsi = new IscsiPageHelper();
18
19 beforeEach(() => {
20 cy.login();
21 Cypress.Cookies.preserveOnce('token');
22 dashboard.navigateTo();
23 });
24
25 describe('Check that all hyperlinks on info cards lead to the correct page and fields exist', () => {
26 it('should ensure that all linked info cards lead to correct page', () => {
27 const expectationMap = {
28 Monitors: 'Monitors',
29 OSDs: 'OSDs',
30 Hosts: 'Hosts',
31 'Object Gateways': 'Daemons',
32 'iSCSI Gateways': 'Overview',
33 Pools: 'Pools'
34 };
35
36 for (const [linkText, breadcrumbText] of Object.entries(expectationMap)) {
37 cy.location('hash').should('eq', '#/dashboard');
38 dashboard.clickInfoCardLink(linkText);
39 dashboard.expectBreadcrumbText(breadcrumbText);
40 dashboard.navigateBack();
41 }
42 });
43
44 it('should verify that info cards exist on dashboard in proper order', () => {
45 // Ensures that info cards are all displayed on the dashboard tab while being in the proper
46 // order, checks for card title and position via indexing into a list of all info cards.
47 const order = [
48 'Cluster Status',
49 'Hosts',
50 'Monitors',
51 'OSDs',
52 'Managers',
53 'Object Gateways',
54 'Metadata Servers',
55 'iSCSI Gateways',
56 'Raw Capacity',
57 'Objects',
58 'PG Status',
59 'Pools',
60 'PGs per OSD',
61 'Client Read/Write',
62 'Client Throughput',
63 'Recovery Throughput',
64 'Scrubbing'
65 ];
66
67 for (let i = 0; i < order.length; i++) {
68 dashboard.infoCard(i).should('contain.text', order[i]);
69 }
70 });
71
72 it('should verify that info card group titles are present and in the right order', () => {
73 cy.location('hash').should('eq', '#/dashboard');
74 dashboard.infoGroupTitle(0).should('eq', 'Status');
75 dashboard.infoGroupTitle(1).should('eq', 'Capacity');
76 dashboard.infoGroupTitle(2).should('eq', 'Performance');
77 });
78 });
79
80 it('Should check that dashboard cards have correct information', () => {
81 interface TestSpec {
82 cardName: string;
83 regexMatcher?: RegExp;
84 pageObject: PageHelper;
85 }
86 const testSpecs: TestSpec[] = [
87 { cardName: 'Object Gateways', regexMatcher: /(\d+)\s+total/, pageObject: daemons },
88 { cardName: 'Monitors', regexMatcher: /(\d+)\s+\(quorum/, pageObject: monitors },
89 { cardName: 'Hosts', regexMatcher: /(\d+)\s+total/, pageObject: hosts },
90 { cardName: 'OSDs', regexMatcher: /(\d+)\s+total/, pageObject: osds },
91 { cardName: 'Pools', pageObject: pools },
92 { cardName: 'iSCSI Gateways', regexMatcher: /(\d+)\s+total/, pageObject: iscsi }
93 ];
94 for (let i = 0; i < testSpecs.length; i++) {
95 const spec = testSpecs[i];
96 dashboard.navigateTo();
97
98 dashboard.infoCardBodyText(spec.cardName).then((infoCardBodyText: string) => {
99 let dashCount = 0;
100
101 if (spec.regexMatcher) {
102 const match = infoCardBodyText.match(new RegExp(spec.regexMatcher));
103 expect(match).to.length.gt(
104 1,
105 `Regex ${spec.regexMatcher} did not find a match for card with name ` +
106 `${spec.cardName}`
107 );
108 dashCount = Number(match[1]);
109 } else {
110 dashCount = Number(infoCardBodyText);
111 }
112
113 spec.pageObject.navigateTo();
114 spec.pageObject.getTableCount('total').then((tableCount) => {
115 expect(tableCount).to.eq(
116 dashCount,
117 `Text of card "${spec.cardName}" and regex "${spec.regexMatcher}" resulted in ${dashCount} ` +
118 `but did not match table count ${tableCount}`
119 );
120 });
121 });
122 }
123 });
124 });