]>
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(); | |
adb31ebb | 21 | Cypress.Cookies.preserveOnce('token'); |
e306af50 | 22 | dashboard.navigateTo(); |
9f95a23c TL |
23 | }); |
24 | ||
25 | describe('Check that all hyperlinks on info cards lead to the correct page and fields exist', () => { | |
e306af50 | 26 | it('should ensure that all linked info cards lead to correct page', () => { |
9f95a23c TL |
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)) { | |
e306af50 TL |
37 | cy.location('hash').should('eq', '#/dashboard'); |
38 | dashboard.clickInfoCardLink(linkText); | |
39 | dashboard.expectBreadcrumbText(breadcrumbText); | |
40 | dashboard.navigateBack(); | |
9f95a23c TL |
41 | } |
42 | }); | |
43 | ||
e306af50 | 44 | it('should verify that info cards exist on dashboard in proper order', () => { |
9f95a23c TL |
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', | |
f91f0fd5 | 49 | 'Hosts', |
9f95a23c TL |
50 | 'Monitors', |
51 | 'OSDs', | |
f91f0fd5 | 52 | 'Managers', |
9f95a23c TL |
53 | 'Object Gateways', |
54 | 'Metadata Servers', | |
55 | 'iSCSI Gateways', | |
9f95a23c TL |
56 | 'Raw Capacity', |
57 | 'Objects', | |
f91f0fd5 TL |
58 | 'PG Status', |
59 | 'Pools', | |
9f95a23c | 60 | 'PGs per OSD', |
f91f0fd5 TL |
61 | 'Client Read/Write', |
62 | 'Client Throughput', | |
63 | 'Recovery Throughput', | |
64 | 'Scrubbing' | |
9f95a23c TL |
65 | ]; |
66 | ||
67 | for (let i = 0; i < order.length; i++) { | |
e306af50 | 68 | dashboard.infoCard(i).should('contain.text', order[i]); |
9f95a23c TL |
69 | } |
70 | }); | |
71 | ||
e306af50 TL |
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'); | |
f91f0fd5 TL |
75 | dashboard.infoGroupTitle(1).should('eq', 'Capacity'); |
76 | dashboard.infoGroupTitle(2).should('eq', 'Performance'); | |
9f95a23c TL |
77 | }); |
78 | }); | |
79 | ||
e306af50 | 80 | it('Should check that dashboard cards have correct information', () => { |
9f95a23c TL |
81 | interface TestSpec { |
82 | cardName: string; | |
83 | regexMatcher?: RegExp; | |
84 | pageObject: PageHelper; | |
85 | } | |
9f95a23c TL |
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 | ]; | |
9f95a23c TL |
94 | for (let i = 0; i < testSpecs.length; i++) { |
95 | const spec = testSpecs[i]; | |
e306af50 TL |
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, | |
9f95a23c TL |
105 | `Regex ${spec.regexMatcher} did not find a match for card with name ` + |
106 | `${spec.cardName}` | |
107 | ); | |
e306af50 TL |
108 | dashCount = Number(match[1]); |
109 | } else { | |
110 | dashCount = Number(infoCardBodyText); | |
9f95a23c | 111 | } |
e306af50 TL |
112 | |
113 | spec.pageObject.navigateTo(); | |
6d8e3169 | 114 | spec.pageObject.getTableCount('total').then((tableCount) => { |
e306af50 TL |
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 | }); | |
9f95a23c TL |
122 | } |
123 | }); | |
124 | }); |