-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathoverviewAnchoredSimulationPasses.test.js
More file actions
126 lines (104 loc) · 5.46 KB
/
overviewAnchoredSimulationPasses.test.js
File metadata and controls
126 lines (104 loc) · 5.46 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
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
const chai = require('chai');
const {
defaultBefore,
defaultAfter,
goToPage,
fillInput,
validateTableData,
pressElement,
testTableSortingByColumn,
expectInnerText,
expectInnerTextTo,
expectColumnValues,
} = require('../defaults.js');
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');
const { expect } = chai;
const periodNameRegex = /LHC\d\d[a-zA-Z]+/;
module.exports = () => {
let page;
let browser;
before(async () => {
[page, browser] = await defaultBefore(page, browser);
await resetDatabaseContent();
});
after(async () => {
[page, browser] = await defaultAfter(page, browser);
});
it('loads page - simulation passes per LHC Period successfully', async () => {
const response = await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
expect(response.status()).to.equal(200);
const title = await page.title();
expect(title).to.equal('AliceO2 Bookkeeping');
await expectInnerText(page, '#breadcrumb-header', 'Anchored MC');
await expectInnerText(page, '#breadcrumb-simulation-pass-name', 'LHC22a_apass1');
});
it('shows correct datatypes in respective columns', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
const dataSizeUnits = new Set(['B', 'KB', 'MB', 'GB', 'TB']);
const tableDataValidators = {
name: (name) => periodNameRegex.test(name),
associatedRuns: (display) => /(No runs)|(\d+)/.test(display),
associatedDataPasses: (display) => /(No anchorage)|(\d+)/.test(display),
pwg: (pwg) => /PWG.+/.test(pwg),
jiraId: (jiraId) => /[A-Z][A-Z0-9]+-[0-9]+/.test(jiraId),
requestedEventsCount: (requestedEventsCount) => !isNaN(requestedEventsCount.replace(/,/g, '')),
generatedEventsCount: (generatedEventsCount) => !isNaN(generatedEventsCount.replace(/,/g, '')),
outputSize: (outputSize) => {
const [number, unit] = outputSize.split(' ');
return !isNaN(number) && dataSizeUnits.has(unit.trim());
},
};
await validateTableData(page, new Map(Object.entries(tableDataValidators)));
});
it('Should display the correct items counter at the bottom of the page', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await expectInnerText(page, '#firstRowIndex', '1');
await expectInnerText(page, '#lastRowIndex', '2');
await expectInnerText(page, '#totalRowsCount', '2');
});
it('can set how many simulation passes is available per page', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await expectInnerTextTo(page, '.dropup button', (text) => text.trim().endsWith('9'));
await pressElement(page, '.dropup button');
await pressElement(page, '.dropup .menu-item');
// Expect the custom per page input to have red border and text color if wrong value typed
await fillInput(page, '.dropup input[type=number]', '1111');
await page.waitForSelector('.dropup input:invalid', { timeout: 250 });
});
it('can sort by name column in ascending and descending manners', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await testTableSortingByColumn(page, 'name');
});
it('can sort by requestedEventsCount column in ascending and descending manners', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await testTableSortingByColumn(page, 'requestedEventsCount');
});
it('can sort by generatedEventsCount column in ascending and descending manners', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await testTableSortingByColumn(page, 'generatedEventsCount');
});
it('can sort by outputSize column in ascending and descending manners', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await testTableSortingByColumn(page, 'outputSize');
});
it('should successfully apply simulation passes name filter', async () => {
await goToPage(page, 'anchored-simulation-passes-overview', { queryParameters: { dataPassId: 3 } });
await pressElement(page, '#openFilterToggle');
await fillInput(page, '.name-filter input[type=text]', 'LHC23k6a', ['change']);
await expectColumnValues(page, 'name', ['LHC23k6a']);
await fillInput(page, '.name-filter input[type=text]', 'LHC23k6a, LHC23k6b', ['change']);
await expectColumnValues(page, 'name', ['LHC23k6b', 'LHC23k6a']);
});
};