-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnodes.test.ts
195 lines (140 loc) · 7.11 KB
/
nodes.test.ts
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import {expect, test} from '@playwright/test';
import {backend} from '../../utils/constants';
import {NodesPage} from '../nodes/NodesPage';
import {ClusterNodesTable} from '../paginatedTable/paginatedTable';
test.describe('Test Nodes page', async () => {
test('Nodes page is OK', async ({page}) => {
const nodesPage = new NodesPage(page);
const response = await nodesPage.goto();
expect(response?.ok()).toBe(true);
});
test('Nodes page has nodes table', async ({page}) => {
const nodesPage = new NodesPage(page);
// Get table with all nodes
await nodesPage.goto({problemFilter: 'All'});
// Check if table is present
await expect(nodesPage.table).toBeVisible();
});
});
test.describe('Test Nodes Paginated Table', async () => {
test.beforeEach(async ({page}) => {
const nodesPage = new NodesPage(page);
const response = await nodesPage.goto();
expect(response?.ok()).toBe(true);
});
test('Table loads and displays data', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const rowCount = await paginatedTable.getRowCount();
expect(rowCount).toBeGreaterThan(0);
});
test('Search by hostname filters the table', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const initialRowCount = await paginatedTable.getRowCount();
await paginatedTable.getControls().search('localhost');
await page.waitForTimeout(1000); // Wait for the table to update
const filteredRowCount = await paginatedTable.getRowCount();
expect(filteredRowCount).toBeLessThanOrEqual(initialRowCount);
});
test('Table groups displayed correctly if group by option is selected', async ({page}) => {
const nodesPage = new NodesPage(page);
const nodesTable = new ClusterNodesTable(page);
await nodesTable.waitForTableToLoad();
await nodesTable.waitForTableData();
const rowData = await nodesTable.getRowData(0);
const host = rowData['Host'];
await nodesPage.selectGroupByOption('Host');
await nodesPage.waitForTableGroupsLoaded();
await nodesPage.selectTableGroup(host).isVisible();
await nodesPage.expandTableGroup(host);
await nodesPage.selectTableGroupContent(host).isVisible();
});
test('Node count is displayed correctly', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const nodeCount = await paginatedTable.getControls().getCount();
const rowCount = await paginatedTable.getRowCount();
expect(nodeCount).toBe(rowCount);
});
test('Uptime values are displayed in correct format', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const uptimeValues = await paginatedTable.getColumnValues('Uptime');
for (const uptime of uptimeValues) {
// \d+d\xa0\d{2}:\d{2}:\d{2} - DDd HH:MM:SS, 1d 00:20:30
// \d{1,2}:\d{2}:\d{2}$ - HH:MM:SS, 1:02:02 or 12:02:02
// \d{1,2}:\d{2}$ - MM:SS, 1:02 or 12:02
// \d{1,2}s$ - SSs, 1s or 12s
expect(uptime).toMatch(
/^(\d+d\xa0\d{2}:\d{2}:\d{2}|\d{1,2}:\d{2}:\d{2}|\d{1,2}:\d{2}|\d{1,2}s)$/,
);
}
});
test('Refresh button updates the table data', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const initialUptimeValues = await paginatedTable.getColumnValues('Uptime');
await page.waitForTimeout(2000); // Wait for some time to pass
await paginatedTable.getControls().clickRefreshButton();
await paginatedTable.waitForTableData();
const updatedUptimeValues = await paginatedTable.getColumnValues('Uptime');
expect(updatedUptimeValues).not.toEqual(initialUptimeValues);
});
test('Row data can be retrieved correctly', async ({page}) => {
const nodesTable = new ClusterNodesTable(page);
await nodesTable.waitForTableToLoad();
await nodesTable.waitForTableData();
const rowData = await nodesTable.getRowData(0);
expect(rowData).toHaveProperty('Host');
expect(rowData).toHaveProperty('Uptime');
expect(rowData).toHaveProperty('CPU');
expect(rowData).toHaveProperty('RAM');
expect(rowData).toHaveProperty('Version');
expect(rowData).toHaveProperty('Tablets');
});
test('Column values can be retrieved correctly', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
const hostValues = await paginatedTable.getColumnValues('Host');
const uptimeValues = await paginatedTable.getColumnValues('Uptime');
expect(hostValues.length).toBeGreaterThan(0);
expect(uptimeValues.length).toBeGreaterThan(0);
expect(hostValues.length).toBe(uptimeValues.length);
});
test('Table displays empty data message when no entities', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
await paginatedTable.waitForTableToLoad();
await paginatedTable.waitForTableData();
await paginatedTable.getControls().search('Some Invalid search string !%#@[]');
await paginatedTable.waitForTableData();
const emptyDataMessage = await paginatedTable.getEmptyDataMessageLocator();
await expect(emptyDataMessage).toContainText('No such nodes');
});
test('Autorefresh updates data when initially empty data', async ({page}) => {
const paginatedTable = new ClusterNodesTable(page);
const emptyRequest = page.route(`${backend}/viewer/json/nodes?*`, async (route) => {
await route.fulfill({json: {FoundNodes: 0, TotalNodes: 0, Nodes: []}});
});
await paginatedTable.getControls().clickRefreshButton();
await emptyRequest;
const emptyDataMessage = await paginatedTable.getEmptyDataMessageLocator();
await expect(emptyDataMessage).toContainText('No such nodes');
await paginatedTable.getControls().setRefreshInterval('15 sec');
const requestWithData = page.route(`${backend}/viewer/json/nodes?*`, async (route) => {
await route.continue();
});
await page.waitForTimeout(15_000); // Wait for autorefresh
await requestWithData;
await paginatedTable.waitForTableData();
await expect(emptyDataMessage).toBeHidden();
const hostValues = await paginatedTable.getColumnValues('Host');
expect(hostValues.length).toBeGreaterThan(0);
});
});