Skip to content

Commit 44c8388

Browse files
author
NarrowsProjects
committed
Merge branch 'main' into improv/O2B-1592/add-infologger-listeners-middleware-to-overview-page-endpoints
2 parents 790164e + 2296c45 commit 44c8388

5 files changed

Lines changed: 133 additions & 23 deletions

File tree

lib/public/components/Filters/common/filters/NumericalComparisonFilterModel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ export class NumericalComparisonFilterModel extends FilterModel {
9292
* @inheritDoc
9393
*/
9494
set normalized({ operator, limit }) {
95-
const parsedLimit = parseFloat(limit) / this._scale;
95+
const numericLimit = parseFloat(limit);
96+
const scaledLimit = numericLimit / this._scale;
9697

97-
if (!isNaN(parsedLimit)) {
98-
this._operandInputModel.normalized = parsedLimit;
98+
if (!isNaN(numericLimit) || !isNaN(scaledLimit)) {
99+
this._operandInputModel.normalized = { value: numericLimit, raw: scaledLimit };
99100
}
100101

101102
this._operatorSelectionModel.normalized = operator;

lib/public/components/Filters/common/filters/ProcessedTextInputModel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ export class ProcessedTextInputModel extends Observable {
109109
/**
110110
* Sets filters from normalised values.
111111
*
112-
* @param {string} value The value used to set filters
112+
* @param {string} value The value used to set the parsed value
113+
* @param {string} raw The value used to set the raw value
113114
* @return {void}
114115
* @abstract
115116
*/
116-
set normalized(value) {
117+
set normalized({ value, raw }) {
117118
this._value = value;
118-
this._raw = value;
119+
this._raw = raw;
119120
}
120121

121122
/**

test/public/Filters/FilteringModel.test.js

Lines changed: 120 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ const {
1616
defaultAfter,
1717
goToPage,
1818
fillInput,
19-
waitForTableLength,
19+
pressElement,
20+
waitForTableTotalRowsCountToEqual,
21+
getPopoverSelector,
22+
getPeriodInputsSelectors,
2023
} = require('../defaults.js');
2124

2225
module.exports = () => {
@@ -26,24 +29,128 @@ module.exports = () => {
2629
before(async () => {
2730
[page, browser] = await defaultBefore();
2831
});
32+
33+
// Not all filters for the pages will be checked, as many of them are identical between pages.
34+
// Environments is not checked at all because it has no filter implementations not allready covered by other pages
35+
const runSelectionFiltersChecks = {
36+
'tags': [{ count: 1, selector: '#tag-dropdown-option-FOOD' }, { count: 0, selector: '#tag-dropdown-option-CTP' }, { count: 1, selector: '#tag-filter-combination-operator-radio-button-or' }],
37+
'beam mode': [{ count: 1, selector: '#beam-mode-dropdown-option-NO\\ BEAM' }, { count: 2, selector: '#beam-mode-dropdown-option-UNSTABLE\\ BEAMS' }],
38+
'definitions': [{ count: 1, selector: '#run-definition-checkbox-TECHNICAL' }, { count: 3, selector: '#run-definition-checkbox-SYNTHETIC' }],
39+
'quality': [{ count: 1, selector: '#checkboxes-checkbox-none' }, { count: 3, selector: '#checkboxes-checkbox-bad' }],
40+
'detectors': [{ count: 3, selector: '#detector-filter-dropdown-option-ACO' }, { count: 0, selector: '#detector-filter-dropdown-option-FDD' }, { count: 3, selector: '#detector-filter-combination-operator-radio-button-or' }],
41+
'runTypes': [{ count: 4, selector: '#run-types-dropdown-option-14' }, { count: 5, selector: '#run-types-dropdown-option-2' }],
42+
'ddFLP': [{ count: 101, selector: '#ddFlpFilterRadioON' }, { count: 8, selector: '#ddFlpFilterRadioOFF' }],
43+
'magnets': [{ count: 1, selector: '#l3-dipole-current-dropdown-option-20003kA\\/0kA' }, { count: 3, selector: '#l3-dipole-current-dropdown-option-30003kA\\/0kA' }],
44+
};
2945

30-
it('should undo filters if the user presses go-back', async () => {
31-
const filterInputSelector = '.runNumbers-textFilter';
46+
const logSelectionFiltersChecks = {
47+
'tags': [{ count: 1, selector: '#tag-dropdown-option-DPG' }, { count: 0, selector: '#tag-dropdown-option-FOOD' }, { count: 3, selector: '#tag-filter-combination-operator-radio-button-or' } ],
48+
};
49+
50+
const lhcFillsSelectionFiltersChecks = {
51+
'hasStableBeams': [{ count: 6, selector: '.switch > input' }],
52+
'beamTypes': [{ count: 1, selector: '#beam-types-checkbox-p-p' }, { count: 2, selector: '#beam-types-checkbox-p-Pb' }]
53+
};
54+
55+
const checkSelectionFilters = async (selectionFilterObject, baseRowCount) => {
56+
for (const [_key, checks] of Object.entries(selectionFilterObject)) {
57+
await waitForTableTotalRowsCountToEqual(page, baseRowCount);
58+
59+
for (const { count, selector } of checks) {
60+
await pressElement(page, selector, true);
61+
await waitForTableTotalRowsCountToEqual(page, count);
62+
}
63+
64+
for (const { count } of checks.reverse()) {
65+
await waitForTableTotalRowsCountToEqual(page, count);
66+
await page.goBack();
67+
}
68+
69+
await waitForTableTotalRowsCountToEqual(page, baseRowCount);
70+
}
71+
};
72+
73+
it('should undo filters if the user presses go-back on the runs page', async () => {
3274
await goToPage(page, 'run-overview');
75+
const baseRowCount = 109;
76+
const startPopoverSelector = await getPopoverSelector(await page.$('.timeO2Start-filter .popover-trigger'));
77+
78+
const { fromDateSelector, fromTimeSelector } = getPeriodInputsSelectors(startPopoverSelector);
3379

34-
await waitForTableLength(page, 6);
35-
await fillInput(page, filterInputSelector, '109', ['change']);
36-
await waitForTableLength(page, 1);
37-
await fillInput(page, filterInputSelector, '109,108', ['change']);
38-
await waitForTableLength(page, 2);
39-
await fillInput(page, filterInputSelector, '109,108,107', ['change']);
40-
await waitForTableLength(page, 3);
80+
await checkSelectionFilters(runSelectionFiltersChecks, baseRowCount);
81+
82+
// Run duration
83+
await page.select('#duration-operator', '>');
84+
await fillInput(page, '#duration-operand', 500, ['change']);
85+
await waitForTableTotalRowsCountToEqual(page, 8);
86+
await page.select('#duration-operator', '=');
87+
await waitForTableTotalRowsCountToEqual(page, 0);
88+
await page.goBack();
89+
await waitForTableTotalRowsCountToEqual(page, 8);
90+
await page.goBack();
91+
await waitForTableTotalRowsCountToEqual(page, baseRowCount);
92+
93+
// EorReason filter
94+
await page.select('#eorCategories', 'DETECTORS');
95+
await waitForTableTotalRowsCountToEqual(page, 3);
96+
await page.select('#eorTitles', 'CPV');
97+
await waitForTableTotalRowsCountToEqual(page, 2);
98+
await fillInput(page, '#eorDescription', 'some', ['change']);
99+
await waitForTableTotalRowsCountToEqual(page, 1);
41100
await page.goBack();
42-
await waitForTableLength(page, 2);
101+
await waitForTableTotalRowsCountToEqual(page, 2);
102+
await page.goBack();
103+
await waitForTableTotalRowsCountToEqual(page, 3);
104+
await page.goBack();
105+
await waitForTableTotalRowsCountToEqual(page, baseRowCount);
106+
107+
// O2 Start Filter:
108+
await fillInput(page, fromTimeSelector, '11:11', ['change']);
109+
await fillInput(page, fromDateSelector, '2021-02-03', ['change']);
110+
await waitForTableTotalRowsCountToEqual(page, 1);
111+
await fillInput(page, fromDateSelector, '2020-02-03', ['change']);
112+
await waitForTableTotalRowsCountToEqual(page, 2);
113+
await page.goBack();
114+
await waitForTableTotalRowsCountToEqual(page, 1);
115+
await page.goBack();
116+
await waitForTableTotalRowsCountToEqual(page, baseRowCount);
117+
});
118+
119+
it('should undo filters if the user presses go-back on the LHC fills page', async () => {
120+
await goToPage(page, 'lhc-fill-overview');
121+
await checkSelectionFilters(lhcFillsSelectionFiltersChecks, 5)
122+
});
123+
124+
it('should undo filters if the user presses go-back on the logs page', async () => {
125+
await goToPage(page, 'log-overview');
126+
await waitForTableTotalRowsCountToEqual(page, 119);
127+
128+
// AuthorFilter
129+
await pressElement(page, '.author-filter .switch input', true);
130+
await waitForTableTotalRowsCountToEqual(page, 117);
131+
await fillInput(page, '#authorFilterText', '!Anonymous,John', ['change']);
132+
await waitForTableTotalRowsCountToEqual(page, 5);
133+
await page.goBack();
134+
await waitForTableTotalRowsCountToEqual(page, 117);
135+
await page.goBack();
136+
await waitForTableTotalRowsCountToEqual(page, 119);
137+
138+
await checkSelectionFilters(logSelectionFiltersChecks, 119);
139+
});
140+
141+
it('should undo filters if the user presses go-back on the lhc periods page', async () => {
142+
await goToPage(page, 'lhc-period-overview');
143+
await waitForTableTotalRowsCountToEqual(page, 3);
144+
145+
// Name
146+
await fillInput(page, '.name-filter input', 'LHC23f');
147+
await waitForTableTotalRowsCountToEqual(page, 1);
148+
await fillInput(page, '.name-filter input', 'bogus');
149+
await waitForTableTotalRowsCountToEqual(page, 0);
43150
await page.goBack();
44-
await waitForTableLength(page, 1);
151+
await waitForTableTotalRowsCountToEqual(page, 1);
45152
await page.goBack();
46-
await waitForTableLength(page, 6);
153+
await waitForTableTotalRowsCountToEqual(page, 3);
47154
});
48155

49156
after(async () => await defaultAfter(page, browser));

test/public/Filters/filtersToUrl.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ module.exports = () => {
343343
it('should set filters from DataPassesPerLhcPeriodOverview to the URL', async () => {
344344
await goToPage(page, 'data-passes-per-lhc-period-overview', { queryParameters: { lhcPeriodId: 2 }});
345345

346-
await fillInput(page, 'div.flex-row.items-baseline:nth-of-type(1) input[type=text]', 'LHC22b_apass1', ['change']);
346+
await fillInput(page, 'div.flex-row.items-baseline:nth-of-type(1) input[type=text]', 'LHC22b_apass1', ['input']);
347347
await pressElement(page, '#checkboxes-checkbox-test', true);
348348

349349

@@ -359,7 +359,7 @@ module.exports = () => {
359359
it('should set filters from DataPassesPerSimulationPassOverview to the URL', async () => {
360360
await goToPage(page, 'data-passes-per-simulation-pass-overview', { queryParameters: { simulationPassId: 1 }});
361361

362-
await fillInput(page, 'div.flex-row.items-baseline:nth-of-type(1) input[type=text]', 'LHC22b_apass1', ['change']);
362+
await fillInput(page, 'div.flex-row.items-baseline:nth-of-type(1) input[type=text]', 'LHC22b_apass1', ['input']);
363363
await pressElement(page, '#checkboxes-checkbox-test', true);
364364

365365
const queryParameters = getQueryParameters(page);

test/public/defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,15 @@ module.exports.waitForTableLength = waitForTableToLength;
198198
* Wait for the total number of elements to be the expected one
199199
*
200200
* @param {puppeteer.Page} page The puppeteer page where the table is located
201-
* @param {number} amount the expected amount of items
201+
* @param {number} amount the expected amount of items. If amount is 0 it is converted to undefined, as empty tables don't display a row count
202202
* @return {Promise<void>} resolves once the expected amount is present
203203
*/
204204
module.exports.waitForTableTotalRowsCountToEqual = async (page, amount) => {
205205
try {
206+
amount = amount === 0 ? undefined : `${amount}`;
206207
await page.waitForSelector('#totalRowsCount');
207208
await page.waitForFunction(
208-
(amount) => document.querySelector('#totalRowsCount').innerText === `${amount}`,
209+
(amount) => document.querySelector('#totalRowsCount')?.innerText === amount,
209210
{},
210211
amount,
211212
);

0 commit comments

Comments
 (0)