Skip to content

Commit 75d9853

Browse files
authored
[O2B-1512] Refactor environment filtering tests into a single case (#2059)
- Consolidated multiple granular filtering tests into one comprehensive test that applies all filters in sequence. - This streamlines the test suite.
1 parent 36a05b6 commit 75d9853

1 file changed

Lines changed: 13 additions & 155 deletions

File tree

test/public/envs/overview.test.js

Lines changed: 13 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -279,180 +279,38 @@ module.exports = () => {
279279
expect(loadCallCount).to.equal(0);
280280
});
281281

282-
it('should successfully open the filtering panel', async () => {
282+
it('should successfully filter environments utilising all filters in the process', async () => {
283283
// Get the popover key from the filter button's parent
284284
const filterButton = await page.waitForSelector('#openFilterToggle');
285285
const popoverKey = await filterButton.evaluate((button) => {
286286
return button.parentElement.getAttribute('data-popover-key');
287287
});
288288
const filterPanelSelector = `.popover[data-popover-key="${popoverKey}"]`;
289289

290-
// Initially the filtering panel should be closed
291290
await page.waitForSelector(filterPanelSelector, { hidden: true });
292291

293-
// Open the filtering panel
294292
await openFilteringPanel(page);
295293
await page.waitForSelector(filterPanelSelector, { visible: true });
296-
});
297-
298-
it('should successfully filter environments by their related run numbers', async () => {
299-
/**
300-
* This is the sequence to test filtering the environments based on their related run numbers.
301-
*
302-
* @param {string} selector the filter input selector
303-
* @param {string} inputValue the value to type in the filter input
304-
* @param {string[]} expectedIds the list of expected environment IDs after filtering
305-
* @return {void}
306-
*/
307-
const filterOnRunNumbers = async (selector, inputValue, expectedIds) => {
308-
await fillInput(page, selector, inputValue, ['change']);
309-
await waitForTableLength(page, expectedIds.length);
310-
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`));
311-
}
312294

295+
await expectAttributeValue(page, '.id-filter input', 'placeholder', 'e.g. CmCvjNbg, TDI59So3d...');
313296
await expectAttributeValue(page, '.runs-filter input', 'placeholder', 'e.g. 553203, 553221, ...');
314-
315-
await filterOnRunNumbers('.runs-filter input', '10', ['TDI59So3d', 'Dxi029djX']);
316-
await resetFilters(page);
317-
318-
await filterOnRunNumbers('.runs-filter input', '103', ['TDI59So3d']);
319-
await resetFilters(page);
320-
321-
await filterOnRunNumbers('.runs-filter input', '86, 91', ['KGIS12DS', 'VODdsO12d']);
322-
await resetFilters(page);
323-
});
324-
325-
it('should successfully filter environments by their status history', async () => {
326-
/**
327-
* This is the sequence to test filtering the environments on their status history.
328-
*
329-
* @param {string} selector the filter input selector
330-
* @param {string} inputValue the value to type in the filter input
331-
* @param {string[]} expectedIds the list of expected environment IDs after filtering
332-
* @return {void}
333-
*/
334-
const filterOnStatusHistory = async (selector, inputValue, expectedIds) => {
335-
await fillInput(page, selector, inputValue, ['change']);
336-
await waitForTableLength(page, expectedIds.length);
337-
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`));
338-
};
339-
340297
await expectAttributeValue(page, '.historyItems-filter input', 'placeholder', 'e.g. D-R-X');
341298

342-
await filterOnStatusHistory('.historyItems-filter input', 'C-R-D-X', ['TDI59So3d']);
343-
await resetFilters(page);
344-
345-
await filterOnStatusHistory('.historyItems-filter input', 'S-E', ['EIDO13i3D', '8E4aZTjY']);
346-
await resetFilters(page);
347-
348-
await filterOnStatusHistory('.historyItems-filter input', 'D-E', ['KGIS12DS']);
349-
await resetFilters(page);
350-
});
351-
352-
it('should successfully filter environments by their current status', async () => {
353-
/**
354-
* Checks that all the rows of the given table have a valid current status
355-
*
356-
* @param {string[]} authorizedCurrentStatuses the list of valid current statuses
357-
* @return {void}
358-
*/
359-
const checkTableCurrentStatuses = async (authorizedCurrentStatuses) => {
360-
const rows = await page.$$('tbody tr');
361-
for (const row of rows) {
362-
expect(await row.evaluate((rowItem) => {
363-
const rowId = rowItem.id;
364-
return document.querySelector(`#${rowId}-status-text`).innerText;
365-
})).to.be.oneOf(authorizedCurrentStatuses);
366-
}
367-
};
368-
369-
const currentStatusSelectorPrefix = '.status-filter #checkboxes-checkbox-';
370-
const getCurrentStatusCheckboxSelector = (statusName) => `${currentStatusSelectorPrefix}${statusName}`;
299+
await fillInput(page, '.id-filter input', 'Dxi029djX, TDI59So3d', ['change']);
300+
await page.$eval('.status-filter #checkboxes-checkbox-DESTROYED', (element) => element.click());
301+
await fillInput(page, '.runs-filter input', '10', ['change']);
302+
await fillInput(page, '.historyItems-filter input', 'C-R-D-X', ['change']);
371303

372-
await page.$eval(getCurrentStatusCheckboxSelector("RUNNING"), (element) => element.click());
373-
await waitForTableLength(page, 2);
374-
await checkTableCurrentStatuses(["RUNNING"]);
375-
376-
await page.$eval(getCurrentStatusCheckboxSelector("DEPLOYED"), (element) => element.click());
377-
await waitForTableLength(page, 3);
378-
await checkTableCurrentStatuses(["RUNNING", "DEPLOYED"]);
379-
});
380-
381-
it('should successfully filter environments by their IDs', async () => {
382-
/**
383-
* This is the sequence to test filtering the environments on IDs.
384-
*
385-
* @param {string} selector the filter input selector
386-
* @param {string} inputValue the value to type in the filter input
387-
* @param {string[]} expectedIds the list of expected environment IDs after filtering
388-
* @return {void}
389-
*/
390-
const filterOnID = async (selector, inputValue, expectedIds) => {
391-
await fillInput(page, selector, inputValue, ['change']);
392-
await waitForTableLength(page, expectedIds.length);
393-
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`));
394-
};
395-
396-
await expectAttributeValue(page, '.id-filter input', 'placeholder', 'e.g. CmCvjNbg, TDI59So3d...');
397-
398-
await filterOnID('.id-filter input', 'CmCvjNbg', ['CmCvjNbg']);
399-
await resetFilters(page);
400-
401-
await filterOnID('.id-filter input', 'CmCvjNbg, TDI59So3d', ['CmCvjNbg', 'TDI59So3d']);
402-
await resetFilters(page);
403-
404-
await filterOnID('.id-filter input', 'j', ['CmCvjNbg', 'GIDO1jdkD', '8E4aZTjY', 'Dxi029djX']);
405-
await resetFilters(page);
406-
});
407-
408-
it('should successfully filter environments by their createdAt date', async () => {
409-
/**
410-
* This is the sequence to test filtering the environments based on their createdAt date
411-
*
412-
* @param {string} selector the filter input selector
413-
* @param {string} fromDate the from date string
414-
* @param {string} fromTime the from time string
415-
* @param {string} toDate the to date string
416-
* @param {string} toTime the to time string
417-
* @param {string[]} expectedIds the list of expected environment IDs after filtering
418-
* @return {void}
419-
*/
420-
const filterOnCreatedAt = async (selector, fromDate, fromTime, toDate, toTime, expectedIds) => {
421-
await fillInput(page, selector.fromTimeSelector, fromTime, ['change']);
422-
await fillInput(page, selector.toTimeSelector, toTime, ['change']);
423-
424-
await fillInput(page, selector.fromDateSelector, fromDate, ['change']);
425-
await fillInput(page, selector.toDateSelector, toDate, ['change']);
426-
427-
await waitForTableLength(page, expectedIds.length, 5000);
428-
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`));
429-
};
430-
431-
await openFilteringPanel(page);
432-
433304
const createdAtPopoverSelector = await getPopoverSelector(await page.$('.createdAt-filter .popover-trigger'));
434305
const periodInputsSelectors = getPeriodInputsSelectors(createdAtPopoverSelector);
306+
await fillInput(page, periodInputsSelectors.fromDateSelector, '2019-08-09', ['change']);
307+
await fillInput(page, periodInputsSelectors.toDateSelector, '2019-08-10', ['change']);
308+
await fillInput(page, periodInputsSelectors.fromTimeSelector, '00:00', ['change']);
309+
await fillInput(page, periodInputsSelectors.toTimeSelector, '23:59', ['change']);
310+
311+
await waitForTableLength(page, 1);
312+
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(['rowTDI59So3d']);
435313

436-
await filterOnCreatedAt(
437-
periodInputsSelectors,
438-
'2019-05-08',
439-
'00:00',
440-
'2019-05-10',
441-
'00:00',
442-
['eZF99lH6'],
443-
);
444-
await resetFilters(page);
445-
await waitForTableLength(page, 9, 10000);
446-
447-
await filterOnCreatedAt(
448-
periodInputsSelectors,
449-
'2019-08-09',
450-
'00:00',
451-
'2019-08-09',
452-
'14:00',
453-
['GIDO1jdkD', '8E4aZTjY', 'Dxi029djX'],
454-
);
455314
await resetFilters(page);
456-
await waitForTableLength(page, 9, 10000);
457315
});
458316
};

0 commit comments

Comments
 (0)