-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsorting-endpoints.spec.ts
More file actions
496 lines (407 loc) · 24.3 KB
/
sorting-endpoints.spec.ts
File metadata and controls
496 lines (407 loc) · 24.3 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
import { expect } from "vitest";
import { test, describe } from "../../drivers/vitest/driver";
import { waitFor } from "@testing-library/vue";
import { groupEndpointsBy } from "./actions/groupEndpointsBy";
import { endpointGroupNames } from "./questions/endpointGroupNames";
import { endpointGroup } from "./questions/endpointGroup";
import { sortEndpointsBy } from "./actions/sortEndpointsBy";
import { findSortImageInColumn } from "./questions/sortDirection";
import { smallGraphAverageValuesByColumn, columnName } from "./questions/smallGraphAverageValuesByColumn";
import * as precondition from "../../preconditions";
import { monitoredEndpointTemplate } from "../../mocks/monitored-endpoint-template";
import { Endpoint } from "@/resources/MonitoringEndpoint";
import { endpointsNames } from "./questions/endpointsNames";
describe("FEATURE: Endpoint sorting", () => {
describe("RULE: Grouped endpoints should be able to be sorted in ascending and descending order by group name and by endpoint name inside the group", () => {
// Skipping for now, this is constantly failing randomly
// test("EXAMPLE: Endpoints inside of the groups and group names should be sorted in the same direction as the ungrouped endpoints", async ({ driver }) => {
// //Arrange
// await driver.setUp(precondition.serviceControlWithMonitoring);
// await driver.setUp(
// precondition.monitoredEndpointsNamed([
// "Universe.Solarsystem.Earth.Endpoint5",
// "Universe.Solarsystem.Earth.Endpoint6",
// "Universe.Solarsystem.Mercury.Endpoint1",
// "Universe.Solarsystem.Mercury.Endpoint2",
// "Universe.Solarsystem.Venus.Endpoint3",
// "Universe.Solarsystem.Venus.Endpoint4",
// ])
// );
//
// //Act
// await driver.goTo("monitoring");
// await groupEndpointsBy({ numberOfSegments: 3 });
// //Assert
// expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Earth", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Venus"]);
// expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint5", "Endpoint6"]);
// expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint1", "Endpoint2"]);
// expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint3", "Endpoint4"]);
//
// //Act
// await groupEndpointsBy({ numberOfSegments: 0 });
// await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); //Descending
// await groupEndpointsBy({ numberOfSegments: 3 });
// //Assert
// expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Venus", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Earth"]);
// expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint4", "Endpoint3"]);
// expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint2", "Endpoint1"]);
// expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint6", "Endpoint5"]);
// });
test("EXAMPLE: Endpoints inside of the groups and group names should be sorted in descending order when clicking the endpoint name column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(
precondition.monitoredEndpointsNamed([
"Universe.Solarsystem.Earth.Endpoint5",
"Universe.Solarsystem.Earth.Endpoint6",
"Universe.Solarsystem.Mercury.Endpoint1",
"Universe.Solarsystem.Mercury.Endpoint2",
"Universe.Solarsystem.Venus.Endpoint3",
"Universe.Solarsystem.Venus.Endpoint4",
])
);
//Act
await driver.goTo("monitoring");
await groupEndpointsBy({ numberOfSegments: 3 });
await sortEndpointsBy({ column: columnName.ENDPOINTNAME });
//Assert
await waitFor(() => {
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Venus", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Earth"]);
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint4", "Endpoint3"]);
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint2", "Endpoint1"]);
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint6", "Endpoint5"]);
});
});
test("EXAMPLE: Endpoints inside of the groups and group names should be sorted in ascending order when clicking twice on the endpoint name column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(
precondition.monitoredEndpointsNamed([
"Universe.Solarsystem.Venus.Endpoint3",
"Universe.Solarsystem.Venus.Endpoint4",
"Universe.Solarsystem.Mercury.Endpoint1",
"Universe.Solarsystem.Mercury.Endpoint2",
"Universe.Solarsystem.Earth.Endpoint5",
"Universe.Solarsystem.Earth.Endpoint6",
])
);
//Act
await driver.goTo("monitoring");
await groupEndpointsBy({ numberOfSegments: 3 });
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); //Click the column title once for descending
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); //Click the column title again for ascending
//Assert
await waitFor(() => {
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Earth", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Venus"]);
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint5", "Endpoint6"]);
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint1", "Endpoint2"]);
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint3", "Endpoint4"]);
});
});
});
describe("RULE: Sort arrow images should only be visible on the column that is being sorted", () => {
test("EXAMPLE: Sort up arrow should only be visible on endpoint name column on page load", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.monitoredEndpointsNamed(["Universe.Solarsystem.Earth.Endpoint1", "Universe.Solarsystem.Earth.Endpoint2", "Universe.Solarsystem.Earth.Endpoint3"]));
//Act
await driver.goTo("monitoring");
//retrieve the endpoint names as a way to ensure the monitoring page finished rendering the endpoint list
await endpointsNames();
//Assert
assertSortImageState(columnName.ENDPOINTNAME, "up");
for (const otherColumn of Object.values(columnName).filter((col) => col !== columnName.ENDPOINTNAME)) {
assertSortImageState(otherColumn, null); // Assert that all other columns don't have sorting images
}
});
Object.values(columnName).forEach((column) => {
test(`EXAMPLE: Sort up and down arrow images should alternate visibility only on the column "${column.toUpperCase()}"`, async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.monitoredEndpointsNamed(["Universe.Solarsystem.Earth.Endpoint1", "Universe.Solarsystem.Earth.Endpoint2", "Universe.Solarsystem.Earth.Endpoint3"]));
//Act
await driver.goTo("monitoring");
//retrieve the endpoint names as a way to ensure the monitoring page finished rendering the endpoint list
await endpointsNames();
//Assert sorting of Endpoint name first since it sorts in ascending order by default, while all the other columns sort in descending order by default
assertSortImageState(columnName.ENDPOINTNAME, "up");
await sortEndpointsBy({ column }); // Click the column title being tested once for descending
assertSortImageState(column, "down");
for (const otherColumn of Object.values(columnName).filter((col) => col !== column)) {
assertSortImageState(otherColumn, null); // Assert that all other columns don't have sorting images
}
await sortEndpointsBy({ column }); // Click the column title once for ascending
assertSortImageState(column, "up");
for (const otherColumn of Object.values(columnName).filter((col) => col !== column)) {
assertSortImageState(otherColumn, null); // Assert that all other columns don't have sorting images
}
});
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on endpoint name", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking name on the Endpoint name column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.monitoredEndpointsNamed(["Universe.Solarsystem.Earth.Endpoint1", "Universe.Solarsystem.Earth.Endpoint2", "Universe.Solarsystem.Earth.Endpoint3"]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); // Act: Click the column title once for descending
assertSortImageState(columnName.ENDPOINTNAME, "down");
//Assert
for (const otherColumn of Object.values(columnName).filter((col) => col !== columnName.ENDPOINTNAME)) {
assertSortImageState(otherColumn, null); // Assert that all other columns don't have sorting images
}
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking name on the Endpoint name column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.monitoredEndpointsNamed(["Universe.Solarsystem.Earth.Endpoint1", "Universe.Solarsystem.Earth.Endpoint2", "Universe.Solarsystem.Earth.Endpoint3"]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); // Act: Click the column title once for ascending
assertSortImageState(columnName.ENDPOINTNAME, "up");
//Assert
for (const otherColumn of Object.values(columnName).filter((col) => col !== columnName.ENDPOINTNAME)) {
assertSortImageState(otherColumn, null); // Assert that all other columns don't have sorting images
}
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on average queue length", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking the queue length column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.queueLength.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.queueLength.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.queueLength.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.QUEUELENGTH }); // Act: Click the column title once for descending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint2", "Endpoint1", "Endpoint3"]);
const avgValues = await smallGraphAverageValuesByColumn({ column: columnName.QUEUELENGTH });
expect(avgValues).toEqual(["4.1", "2.1", "1.1"]);
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking the queue length column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.queueLength.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.queueLength.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.queueLength.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.QUEUELENGTH }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.QUEUELENGTH }); // Act: Click the column title once for ascending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint3", "Endpoint1", "Endpoint2"]);
const ascendingAvgValues = await smallGraphAverageValuesByColumn({ column: columnName.QUEUELENGTH });
expect(ascendingAvgValues).toEqual(["1.1", "2.1", "4.1"]);
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on average throughput per second", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking the throughput column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.throughput.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.throughput.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.throughput.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.THROUGHPUT }); // Act: Click the column title once for descending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint2", "Endpoint1", "Endpoint3"]);
const avgValues = await smallGraphAverageValuesByColumn({ column: columnName.THROUGHPUT });
expect(avgValues).toEqual(["4.1", "2.1", "1.1"]);
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking the throughput column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.throughput.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.throughput.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.throughput.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.THROUGHPUT }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.THROUGHPUT }); // Act: Click the column title once for ascending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint3", "Endpoint1", "Endpoint2"]);
const ascendingAvgValues = await smallGraphAverageValuesByColumn({ column: columnName.THROUGHPUT });
expect(ascendingAvgValues).toEqual(["1.1", "2.1", "4.1"]);
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on average scheduled retries per second", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking the scheduled retries column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.retries.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.retries.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.retries.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.SCHEDULEDRETRIES }); // Act: Click the column title once for descending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint2", "Endpoint1", "Endpoint3"]);
const avgValues = await smallGraphAverageValuesByColumn({ column: columnName.SCHEDULEDRETRIES });
expect(avgValues).toEqual(["4.1", "2.1", "1.1"]);
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking the scheduled retries column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.retries.average = 2.1;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.retries.average = 4.1;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.retries.average = 1.1;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.SCHEDULEDRETRIES }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.SCHEDULEDRETRIES }); // Act: Click the column title once for ascending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint3", "Endpoint1", "Endpoint2"]);
const ascendingAvgValues = await smallGraphAverageValuesByColumn({ column: columnName.SCHEDULEDRETRIES });
expect(ascendingAvgValues).toEqual(["1.1", "2.1", "4.1"]);
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on average processing time", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking the scheduled retries column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.processingTime.average = 350;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.processingTime.average = 800;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.processingTime.average = 225;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.PROCESSINGTIME }); // Act: Click the column title once for descending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint2", "Endpoint1", "Endpoint3"]);
const avgValues = await smallGraphAverageValuesByColumn({ column: columnName.PROCESSINGTIME });
expect(avgValues).toEqual(["800", "350", "225"]);
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking the scheduled retries column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1: Endpoint = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.processingTime.average = 350;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.processingTime.average = 800;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.processingTime.average = 225;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.PROCESSINGTIME }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.PROCESSINGTIME }); // Act: Click the column title once for ascending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint3", "Endpoint1", "Endpoint2"]);
const ascendingAvgValues = await smallGraphAverageValuesByColumn({ column: columnName.PROCESSINGTIME });
expect(ascendingAvgValues).toEqual(["225", "350", "800"]);
});
});
describe("RULE: Ungrouped endpoints should be able to be sorted in ascending and descending order based on average critical time", () => {
test("EXAMPLE: Endpoints are sorted in descending order by clicking the scheduled retries column title", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.criticalTime.average = 350;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.criticalTime.average = 800;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.criticalTime.average = 225;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.CRITICALTIME }); // Act: Click the column title once for descending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint2", "Endpoint1", "Endpoint3"]);
const avgValues = await smallGraphAverageValuesByColumn({ column: columnName.CRITICALTIME });
expect(avgValues).toEqual(["800", "350", "225"]);
});
test("EXAMPLE: Endpoints are sorted in ascending order by clicking the scheduled retries column title twice", async ({ driver }) => {
//Arrange
await driver.setUp(precondition.serviceControlWithMonitoring);
const endpoint1 = structuredClone(monitoredEndpointTemplate);
endpoint1.name = "Endpoint1";
endpoint1.metrics.criticalTime.average = 350;
const endpoint2 = structuredClone(monitoredEndpointTemplate);
endpoint2.name = "Endpoint2";
endpoint2.metrics.criticalTime.average = 800;
const endpoint3 = structuredClone(monitoredEndpointTemplate);
endpoint3.name = "Endpoint3";
endpoint3.metrics.criticalTime.average = 225;
await driver.setUp(precondition.hasMonitoredEndpointsList([endpoint1, endpoint2, endpoint3]));
//Act
await driver.goTo("monitoring");
await sortEndpointsBy({ column: columnName.CRITICALTIME }); // Act: Click the column title once for descending
await sortEndpointsBy({ column: columnName.CRITICALTIME }); // Act: Click the column title once for ascending
//Assert
expect(await endpointsNames()).toEqual(["Endpoint3", "Endpoint1", "Endpoint2"]);
const ascendingAvgValues = await smallGraphAverageValuesByColumn({ column: columnName.CRITICALTIME });
expect(ascendingAvgValues).toEqual(["225", "350", "800"]);
});
});
});
function assertSortImageState(column: string, direction: "up" | "down" | null) {
if (direction === null) {
expect(findSortImageInColumn(column, "up")).toBeNull();
expect(findSortImageInColumn(column, "down")).toBeNull();
} else if (direction === "up") {
expect(findSortImageInColumn(column, "up")).toBeInTheDocument();
expect(findSortImageInColumn(column, "down")).toBeNull();
} else {
expect(findSortImageInColumn(column, "up")).toBeNull();
expect(findSortImageInColumn(column, "down")).toBeInTheDocument();
}
}