Skip to content

Commit feda0ef

Browse files
committed
[O2B-1493] Add run numbers filter to the environments overview
Introduces a raw text filter for the run numbers of environments. Adds tests to verify correct filtering behaviour.
1 parent bb74d46 commit feda0ef

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
@@ -61,6 +62,17 @@ export const environmentsActiveColumns = {
6162
size: 'w-10',
6263
format: formatRunsList,
6364
balloon: true,
65+
66+
/**
67+
* Run numbers filter component
68+
*
69+
* @param {EnvironmentOverviewModel} environmentOverviewModel the environment overview model
70+
* @return {Component} the filter component
71+
*/
72+
filter: (environmentOverviewModel) => rawTextFilter(
73+
environmentOverviewModel.filteringModel.get('runNumbers'),
74+
{ classes: ['w-100'], placeholder: 'e.g. 123456, 123...' },
75+
),
6476
},
6577
updatedAt: {
6678
name: 'Last Update',

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+
runNumbers: 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 related run numbers', async () => {
298+
/**
299+
* This is the sequence to test filtering the environments based on their related run numbers.
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 filterOnRunNumbers = 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, '.runs-filter input', 'placeholder', 'e.g. 123456, 123...');
313+
314+
await filterOnRunNumbers('.runs-filter input', '10', ['TDI59So3d', 'Dxi029djX']);
315+
await resetFilters(page);
316+
317+
await filterOnRunNumbers('.runs-filter input', '103', ['TDI59So3d']);
318+
await resetFilters(page);
319+
320+
await filterOnRunNumbers('.runs-filter input', '86, 91', ['KGIS12DS', 'VODdsO12d']);
321+
await resetFilters(page);
322+
});
293323
};

0 commit comments

Comments
 (0)