diff --git a/test/public/envs/overview.test.js b/test/public/envs/overview.test.js index 1b9fa872c6..f4613bbe8f 100644 --- a/test/public/envs/overview.test.js +++ b/test/public/envs/overview.test.js @@ -279,7 +279,7 @@ module.exports = () => { expect(loadCallCount).to.equal(0); }); - it('should successfully open the filtering panel', async () => { + it('should successfully filter environments utilising all filters in the process', async () => { // Get the popover key from the filter button's parent const filterButton = await page.waitForSelector('#openFilterToggle'); const popoverKey = await filterButton.evaluate((button) => { @@ -287,170 +287,30 @@ module.exports = () => { }); const filterPanelSelector = `.popover[data-popover-key="${popoverKey}"]`; - // Initially the filtering panel should be closed await page.waitForSelector(filterPanelSelector, { hidden: true }); - // Open the filtering panel await openFilteringPanel(page); await page.waitForSelector(filterPanelSelector, { visible: true }); - }); - - it('should successfully filter environments by their related run numbers', async () => { - /** - * This is the sequence to test filtering the environments based on their related run numbers. - * - * @param {string} selector the filter input selector - * @param {string} inputValue the value to type in the filter input - * @param {string[]} expectedIds the list of expected environment IDs after filtering - * @return {void} - */ - const filterOnRunNumbers = async (selector, inputValue, expectedIds) => { - await fillInput(page, selector, inputValue, ['change']); - await waitForTableLength(page, expectedIds.length); - expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`)); - } + await expectAttributeValue(page, '.id-filter input', 'placeholder', 'e.g. CmCvjNbg, TDI59So3d...'); await expectAttributeValue(page, '.runs-filter input', 'placeholder', 'e.g. 553203, 553221, ...'); - - await filterOnRunNumbers('.runs-filter input', '10', ['TDI59So3d', 'Dxi029djX']); - await resetFilters(page); - - await filterOnRunNumbers('.runs-filter input', '103', ['TDI59So3d']); - await resetFilters(page); - - await filterOnRunNumbers('.runs-filter input', '86, 91', ['KGIS12DS', 'VODdsO12d']); - await resetFilters(page); - }); - - it('should successfully filter environments by their status history', async () => { - /** - * This is the sequence to test filtering the environments on their status history. - * - * @param {string} selector the filter input selector - * @param {string} inputValue the value to type in the filter input - * @param {string[]} expectedIds the list of expected environment IDs after filtering - * @return {void} - */ - const filterOnStatusHistory = async (selector, inputValue, expectedIds) => { - await fillInput(page, selector, inputValue, ['change']); - await waitForTableLength(page, expectedIds.length); - expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`)); - }; - await expectAttributeValue(page, '.historyItems-filter input', 'placeholder', 'e.g. D-R-X'); - await filterOnStatusHistory('.historyItems-filter input', 'C-R-D-X', ['TDI59So3d']); - await resetFilters(page); - - await filterOnStatusHistory('.historyItems-filter input', 'S-E', ['EIDO13i3D', '8E4aZTjY']); - await resetFilters(page); - - await filterOnStatusHistory('.historyItems-filter input', 'D-E', ['KGIS12DS']); - await resetFilters(page); - }); - - it('should successfully filter environments by their current status', async () => { - /** - * Checks that all the rows of the given table have a valid current status - * - * @param {string[]} authorizedCurrentStatuses the list of valid current statuses - * @return {void} - */ - const checkTableCurrentStatuses = async (authorizedCurrentStatuses) => { - const rows = await page.$$('tbody tr'); - for (const row of rows) { - expect(await row.evaluate((rowItem) => { - const rowId = rowItem.id; - return document.querySelector(`#${rowId}-status-text`).innerText; - })).to.be.oneOf(authorizedCurrentStatuses); - } - }; - - const currentStatusSelectorPrefix = '.status-filter #checkboxes-checkbox-'; - const getCurrentStatusCheckboxSelector = (statusName) => `${currentStatusSelectorPrefix}${statusName}`; + await fillInput(page, '.id-filter input', 'Dxi029djX, TDI59So3d', ['change']); + await page.$eval('.status-filter #checkboxes-checkbox-DESTROYED', (element) => element.click()); + await fillInput(page, '.runs-filter input', '10', ['change']); + await fillInput(page, '.historyItems-filter input', 'C-R-D-X', ['change']); - await page.$eval(getCurrentStatusCheckboxSelector("RUNNING"), (element) => element.click()); - await waitForTableLength(page, 2); - await checkTableCurrentStatuses(["RUNNING"]); - - await page.$eval(getCurrentStatusCheckboxSelector("DEPLOYED"), (element) => element.click()); - await waitForTableLength(page, 3); - await checkTableCurrentStatuses(["RUNNING", "DEPLOYED"]); - }); - - it('should successfully filter environments by their IDs', async () => { - /** - * This is the sequence to test filtering the environments on IDs. - * - * @param {string} selector the filter input selector - * @param {string} inputValue the value to type in the filter input - * @param {string[]} expectedIds the list of expected environment IDs after filtering - * @return {void} - */ - const filterOnID = async (selector, inputValue, expectedIds) => { - await fillInput(page, selector, inputValue, ['change']); - await waitForTableLength(page, expectedIds.length); - expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`)); - }; - - await expectAttributeValue(page, '.id-filter input', 'placeholder', 'e.g. CmCvjNbg, TDI59So3d...'); - - await filterOnID('.id-filter input', 'CmCvjNbg', ['CmCvjNbg']); - await resetFilters(page); - - await filterOnID('.id-filter input', 'CmCvjNbg, TDI59So3d', ['CmCvjNbg', 'TDI59So3d']); - await resetFilters(page); - - await filterOnID('.id-filter input', 'j', ['CmCvjNbg', 'GIDO1jdkD', '8E4aZTjY', 'Dxi029djX']); - await resetFilters(page); - }); - - it('should successfully filter environments by their createdAt date', async () => { - /** - * This is the sequence to test filtering the environments based on their createdAt date - * - * @param {string} selector the filter input selector - * @param {string} fromDate the from date string - * @param {string} fromTime the from time string - * @param {string} toDate the to date string - * @param {string} toTime the to time string - * @param {string[]} expectedIds the list of expected environment IDs after filtering - * @return {void} - */ - const filterOnCreatedAt = async (selector, fromDate, fromTime, toDate, toTime, expectedIds) => { - await fillInput(page, selector.fromTimeSelector, fromTime, ['change']); - await fillInput(page, selector.toTimeSelector, toTime, ['change']); - - await fillInput(page, selector.fromDateSelector, fromDate, ['change']); - await fillInput(page, selector.toDateSelector, toDate, ['change']); - - await waitForTableLength(page, expectedIds.length); - expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`)); - }; - - await openFilteringPanel(page); - const createdAtPopoverSelector = await getPopoverSelector(await page.$('.createdAt-filter .popover-trigger')); const periodInputsSelectors = getPeriodInputsSelectors(createdAtPopoverSelector); + await fillInput(page, periodInputsSelectors.fromDateSelector, '2019-08-09', ['change']); + await fillInput(page, periodInputsSelectors.toDateSelector, '2019-08-10', ['change']); + await fillInput(page, periodInputsSelectors.fromTimeSelector, '00:00', ['change']); + await fillInput(page, periodInputsSelectors.toTimeSelector, '23:59', ['change']); - await filterOnCreatedAt( - periodInputsSelectors, - '2019-05-08', - '00:00', - '2019-05-10', - '00:00', - ['eZF99lH6'], - ); - await resetFilters(page); + await waitForTableLength(page, 1); + expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(['rowTDI59So3d']); - await filterOnCreatedAt( - periodInputsSelectors, - '2019-08-09', - '00:00', - '2019-08-09', - '14:00', - ['GIDO1jdkD', '8E4aZTjY', 'Dxi029djX'], - ); await resetFilters(page); }); };