Browse Source

test: filters for Rating

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5106/head
Raju Udava 2 years ago
parent
commit
de88de8155
  1. 30
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  2. 79
      tests/playwright/tests/filters.spec.ts

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

@ -1,6 +1,7 @@
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import BasePage from '../../../Base'; import BasePage from '../../../Base';
import { ToolbarPage } from './index'; import { ToolbarPage } from './index';
import { UITypes } from 'nocodb-sdk';
export class ToolbarFilterPage extends BasePage { export class ToolbarFilterPage extends BasePage {
readonly toolbar: ToolbarPage; readonly toolbar: ToolbarPage;
@ -33,11 +34,13 @@ export class ToolbarFilterPage extends BasePage {
opType, opType,
value, value,
isLocallySaved, isLocallySaved,
dataType,
}: { }: {
columnTitle: string; columnTitle: string;
opType: string; opType: string;
value?: string; value?: string;
isLocallySaved: boolean; isLocallySaved: boolean;
dataType?: string;
}) { }) {
await this.get().locator(`button:has-text("Add Filter")`).first().click(); await this.get().locator(`button:has-text("Add Filter")`).first().click();
@ -86,14 +89,25 @@ export class ToolbarFilterPage extends BasePage {
// if value field was provided, fill it // if value field was provided, fill it
if (value) { if (value) {
const fillFilter = this.rootPage.locator('.nc-filter-value-select > input').last().fill(value); let fillFilter: any = null;
await this.waitForResponse({ switch (dataType) {
uiAction: fillFilter, case UITypes.Rating:
httpMethodsToMatch: ['GET'], await this.get('.nc-filter-value-select')
requestUrlPathToMatch: isLocallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, .locator('.ant-rate-star > div')
}); .nth(parseInt(value) - 1)
await this.toolbar.parent.dashboard.waitForLoaderToDisappear(); .click();
await this.toolbar.parent.waitLoading(); break;
default:
fillFilter = this.rootPage.locator('.nc-filter-value-select > input').last().fill(value);
await this.waitForResponse({
uiAction: fillFilter,
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: isLocallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
await this.toolbar.parent.dashboard.waitForLoaderToDisappear();
await this.toolbar.parent.waitLoading();
break;
}
} }
} }

79
tests/playwright/tests/filters.spec.ts

@ -36,7 +36,13 @@ async function validateRowArray(param) {
// } // }
} }
async function verifyFilter(param: { column: string; opType: string; value?: string; result: { rowCount: number } }) { async function verifyFilter(param: {
column: string;
opType: string;
value?: string;
result: { rowCount: number };
dataType?: string;
}) {
// if opType was included in skip list, skip it // if opType was included in skip list, skip it
if (skipList[param.column]?.includes(param.opType)) { if (skipList[param.column]?.includes(param.opType)) {
return; return;
@ -48,6 +54,7 @@ async function verifyFilter(param: { column: string; opType: string; value?: str
opType: param.opType, opType: param.opType,
value: param.value, value: param.value,
isLocallySaved: false, isLocallySaved: false,
dataType: param?.dataType,
}); });
await toolbar.clickFilter(); await toolbar.clickFilter();
@ -414,4 +421,74 @@ test.describe('Filter Tests: Numerical', () => {
}); });
} }
}); });
test('Filter: Rating', async () => {
// close 'Team & Auth' tab
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'numberBased' });
const dataType = 'Rating';
const filterList = [
{
op: '=',
value: '3',
rowCount: records.list.filter(r => r[dataType] === 3).length,
},
{
op: '!=',
value: '3',
rowCount: records.list.filter(r => r[dataType] !== 3).length,
},
{
op: 'is null',
value: '',
rowCount: records.list.filter(r => r[dataType] === null).length,
},
{
op: 'is not null',
value: '',
rowCount: records.list.filter(r => r[dataType] !== null).length,
},
{
op: 'is blank',
value: '',
rowCount: records.list.filter(r => r[dataType] === null).length,
},
{
op: 'is not blank',
value: '',
rowCount: records.list.filter(r => r[dataType] !== null).length,
},
{
op: '>',
value: '2',
rowCount: records.list.filter(r => r[dataType] > 2 && r[dataType] != null).length,
},
{
op: '>=',
value: '2',
rowCount: records.list.filter(r => r[dataType] >= 2 && r[dataType] != null).length,
},
{
op: '<',
value: '2',
rowCount: records.list.filter(r => r[dataType] < 2 && r[dataType] != null).length,
},
{
op: '<=',
value: '2',
rowCount: records.list.filter(r => r[dataType] <= 2 && r[dataType] != null).length,
},
];
for (let i = 0; i < filterList.length; i++) {
await verifyFilter({
column: dataType,
opType: filterList[i].op,
value: filterList[i].value,
result: { rowCount: filterList[i].rowCount },
dataType: dataType,
});
}
});
}); });

Loading…
Cancel
Save