Browse Source

test: user field sort & filter operations

pull/7202/head
Ramesh Mane 10 months ago committed by mertmit
parent
commit
cfea3cf5d4
  1. 22
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  2. 99
      tests/playwright/tests/db/columns/columnUserSelect.spec.ts

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

@ -331,6 +331,28 @@ export class ToolbarFilterPage extends BasePage {
.click(); .click();
} }
break; break;
case UITypes.User:
if (!['is blank', 'is not blank'].includes(operation)) {
await this.get()
.locator('.nc-filter-value-select')
.click({
position: {
x: 1,
y: 1,
},
});
// eslint-disable-next-line no-case-declarations
const v = value.split(',');
for (let i = 0; i < v.length; i++) {
await this.rootPage
.locator(`.nc-dropdown-user-select-cell`)
.getByTestId('select-option-User-filter')
.getByText(v[i])
.click();
}
}
break;
default: default:
fillFilter = () => this.rootPage.locator('.nc-filter-value-select > input').last().fill(value); fillFilter = () => this.rootPage.locator('.nc-filter-value-select > input').last().fill(value);
await this.waitForResponse({ await this.waitForResponse({

99
tests/playwright/tests/db/columns/columnUserSelect.spec.ts

@ -5,16 +5,17 @@ import setup, { unsetup } from '../../../setup';
import { TopbarPage } from '../../../pages/Dashboard/common/Topbar'; import { TopbarPage } from '../../../pages/Dashboard/common/Topbar';
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar';
test.describe.only('User single select', () => { const users: string[] = [
'user@nocodb.com',
'user-0@nocodb.com',
'user-1@nocodb.com',
'user-2@nocodb.com',
'user-3@nocodb.com',
];
test.describe('User single select', () => {
let dashboard: DashboardPage, grid: GridPage, topbar: TopbarPage; let dashboard: DashboardPage, grid: GridPage, topbar: TopbarPage;
let context: any; let context: any;
const users: string[] = [
'user@nocodb.com',
'user-0@nocodb.com',
'user-1@nocodb.com',
'user-2@nocodb.com',
'user-3@nocodb.com',
];
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: false }); context = await setup({ page, isEmptyProject: false });
@ -162,19 +163,25 @@ test.describe.only('User single select', () => {
}); });
}); });
test.describe('Single select - filter, sort & GroupBy', () => { test.describe('User single select - filter, sort & GroupBy', () => {
// Row values // Row values
// no values (row ❶) // only user@nocodb.com (row 0)
// only Foo (row ❷) // only user-0@nocodb.com (row 1)
// only Bar (row ❸) // only user-1@nocodb.com (row 2)
// only Baz (row ❹) // only user-2@nocodb.com (row 3)
// only user-3@nocodb.com (row 4)
// Example filters: // Example filters:
// //
// where tags contains any of [Foo, Bar] // where tags contains any of [user@nocodb.com, user-0@nocodb.com]
// result: rows 2,3 // result: rows 0,1
// where tags does not contain any of [Foo, Bar] // where tags does not contain any of [user@nocodb.com, user-0@nocodb.com]
// result: rows 1,4 // result: rows 2,3,4
// where tags does not contain all of [user-0@nocodb.com]
// result: rows 0,2,3,4
// where tags is not blank
// result: rows 0,1,2,3,4
// where tags is blank
// result: null
let dashboard: DashboardPage, grid: GridPage, toolbar: ToolbarPage; let dashboard: DashboardPage, grid: GridPage, toolbar: ToolbarPage;
let context: any; let context: any;
@ -187,19 +194,12 @@ test.describe('Single select - filter, sort & GroupBy', () => {
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title }); await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
await grid.column.create({ title: 'SingleSelect', type: 'SingleSelect' }); await grid.column.create({ title: 'User', type: 'User' });
await grid.column.selectOption.addOptions({
columnTitle: 'SingleSelect', for (let i = 0; i <= 4; i++) {
options: ['foo', 'bar', 'baz'], await grid.addNewRow({ index: i, value: `${i}` });
}); await grid.cell.userOption.select({ index: i, columnHeader: 'User', option: users[i], multiSelect: false });
await grid.addNewRow({ index: 0, value: '1' }); }
await grid.addNewRow({ index: 1, value: '2' });
await grid.addNewRow({ index: 2, value: '3' });
await grid.addNewRow({ index: 3, value: '4' });
await grid.cell.selectOption.select({ index: 1, columnHeader: 'SingleSelect', option: 'foo', multiSelect: false });
await grid.cell.selectOption.select({ index: 2, columnHeader: 'SingleSelect', option: 'bar', multiSelect: false });
await grid.cell.selectOption.select({ index: 3, columnHeader: 'SingleSelect', option: 'baz', multiSelect: false });
}); });
test.afterEach(async () => { test.afterEach(async () => {
@ -221,11 +221,11 @@ test.describe('Single select - filter, sort & GroupBy', () => {
async function verifyFilter(param: { opType: string; value?: string; result: string[] }) { async function verifyFilter(param: { opType: string; value?: string; result: string[] }) {
await toolbar.clickFilter(); await toolbar.clickFilter();
await toolbar.filter.add({ await toolbar.filter.add({
title: 'SingleSelect', title: 'User',
operation: param.opType, operation: param.opType,
value: param.value, value: param.value,
locallySaved: false, locallySaved: false,
dataType: 'SingleSelect', dataType: 'User',
}); });
await toolbar.clickFilter(); await toolbar.clickFilter();
@ -236,26 +236,39 @@ test.describe('Single select - filter, sort & GroupBy', () => {
} }
test('Select and clear options and rename options', async () => { test('Select and clear options and rename options', async () => {
// fix me! single select filter value doesn't support selecting multiple options // Sort ascending and validate
// await verifyFilter({ opType: 'contains any of', value: 'foo,bar', result: ['2', '3'] });
// await verifyFilter({ opType: 'does not contain any of', value: 'foo,bar', result: ['1', '4'] });
// Sort column
await toolbar.sort.add({ await toolbar.sort.add({
title: 'SingleSelect', title: 'User',
ascending: true, ascending: true,
locallySaved: false, locallySaved: false,
}); });
await validateRowArray(['1', '3', '4', '2']); await validateRowArray(['1', '2', '3', '4', '0']);
await toolbar.sort.reset(); await toolbar.sort.reset();
// sort descending & validate // sort descending and validate
await toolbar.sort.add({ await toolbar.sort.add({
title: 'SingleSelect', title: 'User',
ascending: false, ascending: false,
locallySaved: false, locallySaved: false,
}); });
await validateRowArray(['2', '4', '3', '1']); await validateRowArray(['0', '4', '3', '2', '1']);
await toolbar.sort.reset(); await toolbar.sort.reset();
// filter
await verifyFilter({ opType: 'contains all of', value: users[0], result: ['0'] });
await verifyFilter({
opType: 'contains any of',
value: `${users[0]},${users[1]}`,
result: ['0', '1'],
});
await verifyFilter({
opType: 'does not contain any of',
value: `${users[0]},${users[1]}`,
result: ['2', '3', '4'],
});
await verifyFilter({ opType: 'does not contain all of', value: users[1], result: ['0', '2', '3', '4'] });
await verifyFilter({ opType: 'is not blank', result: ['0', '1', '2', '3', '4'] });
await verifyFilter({ opType: 'is blank', result: [] });
}); });
}); });

Loading…
Cancel
Save