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