Browse Source

test: retain filter modal open (optimisation for time)

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5185/head
Raju Udava 2 years ago
parent
commit
a4958bffcb
  1. 2
      tests/playwright/pages/Dashboard/Grid/index.ts
  2. 8
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  3. 247
      tests/playwright/tests/filters.spec.ts

2
tests/playwright/pages/Dashboard/Grid/index.ts

@ -212,8 +212,8 @@ export class GridPage extends BasePage {
recordCnt = records[0].split(' ')[0]; recordCnt = records[0].split(' ')[0];
// to ensure page loading is complete // to ensure page loading is complete
await this.rootPage.waitForTimeout(500);
i++; i++;
await this.rootPage.waitForTimeout(100 * i);
} }
expect(parseInt(recordCnt)).toEqual(count); expect(parseInt(recordCnt)).toEqual(count);
} }

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

@ -29,6 +29,10 @@ export class ToolbarFilterPage extends BasePage {
).toBeChecked(); ).toBeChecked();
} }
async clickAddFilter() {
await this.get().locator(`button:has-text("Add Filter")`).first().click();
}
async add({ async add({
columnTitle, columnTitle,
opType, opType,
@ -36,6 +40,7 @@ export class ToolbarFilterPage extends BasePage {
value, value,
isLocallySaved, isLocallySaved,
dataType, dataType,
openModal = false,
}: { }: {
columnTitle: string; columnTitle: string;
opType: string; opType: string;
@ -43,8 +48,9 @@ export class ToolbarFilterPage extends BasePage {
value?: string; value?: string;
isLocallySaved: boolean; isLocallySaved: boolean;
dataType?: string; dataType?: string;
openModal?: boolean;
}) { }) {
await this.get().locator(`button:has-text("Add Filter")`).first().click(); if (!openModal) await this.get().locator(`button:has-text("Add Filter")`).first().click();
const selectedField = await this.rootPage.locator('.nc-filter-field-select').textContent(); const selectedField = await this.rootPage.locator('.nc-filter-field-select').textContent();
if (selectedField !== columnTitle) { if (selectedField !== columnTitle) {

247
tests/playwright/tests/filters.spec.ts

@ -44,6 +44,35 @@ async function validateRowArray(param) {
await dashboard.grid.verifyTotalRowCount({ count: rowCount }); await dashboard.grid.verifyTotalRowCount({ count: rowCount });
} }
async function verifyFilter_withFixedModal(param: {
column: string;
opType: string;
opSubType?: string;
value?: string;
result: { rowCount: number };
dataType?: string;
}) {
// if opType was included in skip list, skip it
if (skipList[param.column]?.includes(param.opType)) {
return;
}
await toolbar.filter.add({
columnTitle: param.column,
opType: param.opType,
opSubType: param.opSubType,
value: param.value,
isLocallySaved: false,
dataType: param?.dataType,
openModal: true,
});
// verify filtered rows
await validateRowArray({
rowCount: param.result.rowCount,
});
}
async function verifyFilter(param: { async function verifyFilter(param: {
column: string; column: string;
opType: string; opType: string;
@ -348,8 +377,9 @@ test.describe('Filter Tests: Text based', () => {
}, },
]; ];
await toolbar.clickFilter();
for (let i = 0; i < filterList.length; i++) { for (let i = 0; i < filterList.length; i++) {
await verifyFilter({ await verifyFilter_withFixedModal({
column: dataType, column: dataType,
opType: filterList[i].op, opType: filterList[i].op,
value: filterList[i].value, value: filterList[i].value,
@ -612,7 +642,7 @@ test.describe('Filter Tests: Date based', () => {
const oneYearAgo = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setHours(0, 0, 0, 0); const oneYearAgo = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setHours(0, 0, 0, 0);
const oneYearFromNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)).setHours(0, 0, 0, 0); const oneYearFromNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)).setHours(0, 0, 0, 0);
async function dateTimeBasedFilterTest(dataType, suiteName) { async function dateTimeBasedFilterTest(dataType) {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'dateTimeBased' }); await dashboard.treeView.openTable({ title: 'dateTimeBased' });
@ -770,106 +800,103 @@ test.describe('Filter Tests: Date based', () => {
}, },
]; ];
switch (suiteName) { await toolbar.clickFilter();
case 'is_is_not': await toolbar.filter.clickAddFilter();
for (let i = 0; i < isFilterList.length; i++) {
await verifyFilter({ // "is" filter list
column: dataType, for (let i = 0; i < isFilterList.length; i++) {
opType: 'is', await verifyFilter_withFixedModal({
opSubType: isFilterList[i].opSub, column: dataType,
value: isFilterList[i]?.value?.toString() || '', opType: 'is',
result: { rowCount: isFilterList[i].rowCount }, opSubType: isFilterList[i].opSub,
dataType: dataType, value: isFilterList[i]?.value?.toString() || '',
}); result: { rowCount: isFilterList[i].rowCount },
} dataType: dataType,
});
// mutually exclusive of "is" filter list }
for (let i = 0; i < isFilterList.length; i++) {
await verifyFilter({ // mutually exclusive of "is" filter list
column: dataType, for (let i = 0; i < isFilterList.length; i++) {
opType: 'is not', await verifyFilter_withFixedModal({
opSubType: isFilterList[i].opSub, column: dataType,
value: isFilterList[i]?.value?.toString() || '', opType: 'is not',
result: { rowCount: 800 - isFilterList[i].rowCount }, opSubType: isFilterList[i].opSub,
dataType: dataType, value: isFilterList[i]?.value?.toString() || '',
}); result: { rowCount: 800 - isFilterList[i].rowCount },
} dataType: dataType,
break; });
}
case 'is_before_is_on_or_before':
for (let i = 0; i < isAfterFilterList.length; i++) { // "is before" filter list
await verifyFilter({ for (let i = 0; i < isAfterFilterList.length; i++) {
column: dataType, await verifyFilter_withFixedModal({
opType: 'is before', column: dataType,
opSubType: isAfterFilterList[i].opSub, opType: 'is before',
value: isAfterFilterList[i]?.value?.toString() || '', opSubType: isAfterFilterList[i].opSub,
result: { rowCount: 800 - isAfterFilterList[i].rowCount - 1 }, value: isAfterFilterList[i]?.value?.toString() || '',
dataType: dataType, result: { rowCount: 800 - isAfterFilterList[i].rowCount - 1 },
}); dataType: dataType,
} });
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({ // "is on or before" filter list
column: dataType, for (let i = 0; i < isAfterFilterList.length; i++) {
opType: 'is on or before', await verifyFilter_withFixedModal({
opSubType: isAfterFilterList[i].opSub, column: dataType,
value: isAfterFilterList[i]?.value?.toString() || '', opType: 'is on or before',
result: { rowCount: 800 - isAfterFilterList[i].rowCount }, opSubType: isAfterFilterList[i].opSub,
dataType: dataType, value: isAfterFilterList[i]?.value?.toString() || '',
}); result: { rowCount: 800 - isAfterFilterList[i].rowCount },
} dataType: dataType,
break; });
}
case 'is_after_is_on_or_after':
for (let i = 0; i < isAfterFilterList.length; i++) { // "is after" filter list
await verifyFilter({ for (let i = 0; i < isAfterFilterList.length; i++) {
column: dataType, await verifyFilter_withFixedModal({
opType: 'is after', column: dataType,
opSubType: isAfterFilterList[i].opSub, opType: 'is after',
value: isAfterFilterList[i]?.value?.toString() || '', opSubType: isAfterFilterList[i].opSub,
result: { rowCount: isAfterFilterList[i].rowCount }, value: isAfterFilterList[i]?.value?.toString() || '',
dataType: dataType, result: { rowCount: isAfterFilterList[i].rowCount },
}); dataType: dataType,
} });
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({ // "is on or after" filter list
column: dataType, for (let i = 0; i < isAfterFilterList.length; i++) {
opType: 'is on or after', await verifyFilter_withFixedModal({
opSubType: isAfterFilterList[i].opSub, column: dataType,
value: isAfterFilterList[i]?.value?.toString() || '', opType: 'is on or after',
result: { rowCount: 1 + isAfterFilterList[i].rowCount }, opSubType: isAfterFilterList[i].opSub,
dataType: dataType, value: isAfterFilterList[i]?.value?.toString() || '',
}); result: { rowCount: 1 + isAfterFilterList[i].rowCount },
} dataType: dataType,
break; });
}
case 'is_within_is_blank':
for (let i = 0; i < isWithinFilterList.length; i++) { // "is within" filter list
await verifyFilter({ for (let i = 0; i < isWithinFilterList.length; i++) {
column: dataType, await verifyFilter_withFixedModal({
opType: 'is within', column: dataType,
opSubType: isWithinFilterList[i].opSub, opType: 'is within',
value: isWithinFilterList[i]?.value?.toString() || '', opSubType: isWithinFilterList[i].opSub,
result: { rowCount: isWithinFilterList[i].rowCount }, value: isWithinFilterList[i]?.value?.toString() || '',
dataType: dataType, result: { rowCount: isWithinFilterList[i].rowCount },
}); dataType: dataType,
} });
}
for (let i = 0; i < filterList.length; i++) {
await verifyFilter({ // "is blank" and "is not blank" filter list
column: dataType, for (let i = 0; i < filterList.length; i++) {
opType: filterList[i].opType, await verifyFilter_withFixedModal({
opSubType: null, column: dataType,
value: null, opType: filterList[i].opType,
result: { rowCount: filterList[i].rowCount }, opSubType: null,
dataType: dataType, value: null,
}); result: { rowCount: filterList[i].rowCount },
} dataType: dataType,
break; });
default:
break;
} }
} }
@ -921,20 +948,8 @@ test.describe('Filter Tests: Date based', () => {
} }
}); });
test('Date : is, is not', async () => { test('Date : filters', async () => {
await dateTimeBasedFilterTest('Date', 'is_is_not'); await dateTimeBasedFilterTest('Date');
});
test('Date : is before, is on or before', async () => {
await dateTimeBasedFilterTest('Date', 'is_before_is_on_or_before');
});
test('Date : is after, is on or after', async () => {
await dateTimeBasedFilterTest('Date', 'is_after_is_on_or_after');
});
test('Date : is within, is blank', async () => {
await dateTimeBasedFilterTest('Date', 'is_within_is_blank');
}); });
}); });

Loading…
Cancel
Save