Skip to content

Commit bf9d5f4

Browse files
authored
[O2B-1490] Add filtering by env ids to the environment filtering panel (#2028)
* Add filtering panel to environment overview * Integrated the filtersPanelPopover component into the environment overview UI. * Added a test to verify that the filtering panel can be successfully opened. * This is because test inputs following each other that result in the same number of rows in the table will cause incorrect functioning of the waitForTableLength whose job it is is to wait for the filter to be applied.
1 parent c8e9fde commit bf9d5f4

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

lib/public/views/Environments/ActiveColumns/environmentsActiveColumns.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { environmentStatusHistoryLegendComponent } from '../../../components/env
2424
import { infoTooltip } from '../../../components/common/popover/infoTooltip.js';
2525
import { aliEcsEnvironmentLinkComponent } from '../../../components/common/externalLinks/aliEcsEnvironmentLinkComponent.js';
2626
import { StatusAcronym } from '../../../domain/enums/statusAcronym.mjs';
27+
import { rawTextFilter } from '../../../components/Filters/common/filters/rawTextFilter.js';
2728

2829
/**
2930
* List of active columns for a generic Environments component
@@ -53,6 +54,17 @@ export const environmentsActiveColumns = {
5354
],
5455
'125px',
5556
),
57+
58+
/**
59+
* Environment IDs filter component
60+
*
61+
* @param {EnvironmentOverviewModel} environmentOverviewModel the environment overview model
62+
* @return {Component} the filter component
63+
*/
64+
filter: (environmentOverviewModel) => rawTextFilter(
65+
environmentOverviewModel.filteringModel.get('ids'),
66+
{ classes: ['w-100'], placeholder: 'e.g. CmCvjNbg, TDI59So3d...' },
67+
),
5668
},
5769
runs: {
5870
name: 'Runs',

lib/public/views/Environments/Overview/EnvironmentOverviewModel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import { buildUrl } from '/js/src/index.js';
1515
import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js';
1616
import { OverviewPageModel } from '../../../models/OverviewModel.js';
17+
import { RawTextFilterModel } from '../../../components/Filters/common/filters/RawTextFilterModel.js';
1718
import { debounce } from '../../../utilities/debounce.js';
1819

1920
/**
@@ -28,6 +29,7 @@ export class EnvironmentOverviewModel extends OverviewPageModel {
2829
super();
2930

3031
this._filteringModel = new FilteringModel({
32+
ids: new RawTextFilterModel(),
3133
});
3234

3335
this._filteringModel.observe(() => this._applyFilters(true));

test/public/envs/overview.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const {
2626
getPopoverSelector,
2727
goToPage,
2828
openFilteringPanel,
29+
fillInput,
30+
expectAttributeValue,
31+
resetFilters,
2932
} = require('../defaults.js');
3033
const dateAndTime = require('date-and-time');
3134
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');
@@ -290,4 +293,31 @@ module.exports = () => {
290293
await openFilteringPanel(page);
291294
await page.waitForSelector(filterPanelSelector, { visible: true });
292295
});
296+
297+
it('should successfully filter environments by their IDs', async () => {
298+
/**
299+
* This is the sequence to test filtering the environments on IDs.
300+
*
301+
* @param {string} selector the filter input selector
302+
* @param {string} inputValue the value to type in the filter input
303+
* @param {string[]} expectedIds the list of expected environment IDs after filtering
304+
* @return {void}
305+
*/
306+
const filterOnID = async (selector, inputValue, expectedIds) => {
307+
await fillInput(page, selector, inputValue, ['change']);
308+
await waitForTableLength(page, expectedIds.length);
309+
expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`));
310+
};
311+
312+
await expectAttributeValue(page, '.id-filter input', 'placeholder', 'e.g. CmCvjNbg, TDI59So3d...');
313+
314+
await filterOnID('.id-filter input', 'CmCvjNbg', ['CmCvjNbg']);
315+
await resetFilters(page);
316+
317+
await filterOnID('.id-filter input', 'CmCvjNbg, TDI59So3d', ['CmCvjNbg', 'TDI59So3d']);
318+
await resetFilters(page);
319+
320+
await filterOnID('.id-filter input', 'j', ['CmCvjNbg', 'GIDO1jdkD', '8E4aZTjY', 'Dxi029djX']);
321+
await resetFilters(page);
322+
});
293323
};

0 commit comments

Comments
 (0)