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