Browse Source

test: filter for duration

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5106/head
Raju Udava 2 years ago
parent
commit
4961d7a142
  1. 3
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  2. 2
      tests/playwright/setup/xcdb-records.ts
  3. 27
      tests/playwright/tests/filters.spec.ts

3
tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -91,6 +91,9 @@ export class ToolbarFilterPage extends BasePage {
if (value) {
let fillFilter: any = null;
switch (dataType) {
case UITypes.Duration:
await this.get().locator('.nc-filter-value-select').locator('input').fill(value);
break;
case UITypes.Rating:
await this.get()
.locator('.ant-rate-star > div')

2
tests/playwright/setup/xcdb-records.ts

@ -39,7 +39,7 @@ const rowMixedValue = (column: ColumnType, index: number) => {
// Array of random integers, not more than 10000
const numbers = [33, null, 456, 333, 267, 34, 8754, 3234, 44, 33, null];
const decimals = [33.3, 456.34, 333.3, null, 267.5674, 34.0, 8754.0, 3234.547, 44.2647, 33.98, null];
const duration = [10, 20, 30, 40, 50, 60, null, 70, 80, 90, null];
const duration = [60, 120, 180, 3600, 3660, 3720, null, 3780, 60, 120, null];
const rating = [0, 1, 2, 3, null, 0, 4, 5, 0, 1, null];
// Array of random sample email strings (not more than 100 characters)

27
tests/playwright/tests/filters.spec.ts

@ -17,6 +17,7 @@ const skipList = {
Percent: ['is null', 'is not null', 'is blank', 'is not blank'],
Currency: ['is null', 'is not null', 'is blank', 'is not blank'],
Rating: ['is null', 'is not null', 'is blank', 'is not blank'],
Duration: ['is null', 'is not null', 'is blank', 'is not blank'],
SingleLineText: ['is blank', 'is not blank'],
MultiLineText: ['is blank', 'is not blank'],
Email: ['is blank', 'is not blank'],
@ -90,16 +91,24 @@ test.describe('Filter Tests: Numerical', () => {
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'numberBased' });
let eqStringDerived = eqString;
let isLikeStringDerived = isLikeString;
if (dataType === 'Duration') {
// convert from hh:mm to seconds
eqStringDerived = parseInt(eqString.split(':')[0]) * 3600 + parseInt(eqString.split(':')[1]) * 60;
isLikeStringDerived = parseInt(isLikeString.split(':')[0]) * 3600 + parseInt(isLikeString.split(':')[1]) * 60;
}
const filterList = [
{
op: '=',
value: eqString,
rowCount: records.list.filter(r => r[dataType] === parseFloat(eqString)).length,
rowCount: records.list.filter(r => r[dataType] === parseFloat(eqStringDerived)).length,
},
{
op: '!=',
value: eqString,
rowCount: records.list.filter(r => r[dataType] !== parseFloat(eqString)).length,
rowCount: records.list.filter(r => r[dataType] !== parseFloat(eqStringDerived)).length,
},
{
op: 'is null',
@ -124,22 +133,24 @@ test.describe('Filter Tests: Numerical', () => {
{
op: '>',
value: isLikeString,
rowCount: records.list.filter(r => r[dataType] > parseFloat(isLikeString) && r[dataType] != null).length,
rowCount: records.list.filter(r => r[dataType] > parseFloat(isLikeStringDerived) && r[dataType] != null).length,
},
{
op: '>=',
value: isLikeString,
rowCount: records.list.filter(r => r[dataType] >= parseFloat(isLikeString) && r[dataType] != null).length,
rowCount: records.list.filter(r => r[dataType] >= parseFloat(isLikeStringDerived) && r[dataType] != null)
.length,
},
{
op: '<',
value: isLikeString,
rowCount: records.list.filter(r => r[dataType] < parseFloat(isLikeString) && r[dataType] != null).length,
rowCount: records.list.filter(r => r[dataType] < parseFloat(isLikeStringDerived) && r[dataType] != null).length,
},
{
op: '<=',
value: isLikeString,
rowCount: records.list.filter(r => r[dataType] <= parseFloat(isLikeString) && r[dataType] != null).length,
rowCount: records.list.filter(r => r[dataType] <= parseFloat(isLikeStringDerived) && r[dataType] != null)
.length,
},
];
@ -251,6 +262,10 @@ test.describe('Filter Tests: Numerical', () => {
test('Filter: Rating', async () => {
await numBasedFilterTest('Rating', '3', '2');
});
test('Filter: Duration', async () => {
await numBasedFilterTest('Duration', '00:01', '01:03');
});
});
// Text based filters

Loading…
Cancel
Save