Browse Source

Merge branch 'enhancement/filters' of https://github.com/nocodb/nocodb into enhancement/filters

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
862b91b2e6
  1. 6
      tests/playwright/pages/Dashboard/Settings/index.ts
  2. 20
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  3. 59
      tests/playwright/tests/filters.spec.ts

6
tests/playwright/pages/Dashboard/Settings/index.ts

@ -49,4 +49,10 @@ export class SettingsPage extends BasePage {
await this.get().locator('[data-testid="settings-modal-close-button"]').click(); await this.get().locator('[data-testid="settings-modal-close-button"]').click();
await this.get().waitFor({ state: 'hidden' }); await this.get().waitFor({ state: 'hidden' });
} }
async toggleNullEmptyFilters() {
await this.selectTab({ tab: SettingTab.ProjectSettings, subTab: SettingsSubTab.Miscellaneous });
await this.miscellaneous.clickShowNullEmptyFilters();
await this.close();
}
} }

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

@ -119,10 +119,22 @@ export class ToolbarFilterPage extends BasePage {
break; break;
case UITypes.SingleSelect: case UITypes.SingleSelect:
await this.get().locator('.nc-filter-value-select').click(); await this.get().locator('.nc-filter-value-select').click();
await this.rootPage // check if value was an array
.locator(`.nc-dropdown-single-select-cell`) // eslint-disable-next-line no-case-declarations
.locator(`.nc-select-option-SingleSelect-${value}`) const val = value.split(',');
.click(); if (val.length > 1) {
for (let i = 0; i < val.length; i++) {
await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`)
.locator(`.nc-select-option-SingleSelect-${val[i]}`)
.click();
}
} else {
await this.rootPage
.locator(`.nc-dropdown-single-select-cell`)
.locator(`.nc-select-option-SingleSelect-${value}`)
.click();
}
break; 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);

59
tests/playwright/tests/filters.spec.ts

@ -13,26 +13,19 @@ let api: Api<any>;
let records = []; let records = [];
const skipList = { const skipList = {
Number: ['is null', 'is not null', 'is blank', 'is not blank'], Number: ['is null', 'is not null'],
Decimal: ['is null', 'is not null', 'is blank', 'is not blank'], Decimal: ['is null', 'is not null'],
Percent: ['is null', 'is not null', 'is blank', 'is not blank'], Percent: ['is null', 'is not null'],
Currency: ['is null', 'is not null', 'is blank', 'is not blank'], Currency: ['is null', 'is not null'],
Rating: ['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'], Duration: ['is null', 'is not null'],
SingleLineText: ['is blank', 'is not blank'], SingleLineText: [],
MultiLineText: ['is blank', 'is not blank'], MultiLineText: [],
Email: ['is blank', 'is not blank'], Email: [],
PhoneNumber: ['is blank', 'is not blank'], PhoneNumber: [],
URL: ['is blank', 'is not blank'], URL: [],
SingleSelect: [ SingleSelect: ['contains all of', 'does not contain all of'],
'is blank', MultiSelect: ['is', 'is not'],
'is not blank',
'contains all of',
'does not contain all of',
'contains any of',
'does not contain any of',
],
MultiSelect: ['is blank', 'is not blank', 'is', 'is not'],
}; };
async function verifyFilterOperatorList(param: { column: string; opType: string[] }) { async function verifyFilterOperatorList(param: { column: string; opType: string[] }) {
@ -103,6 +96,10 @@ test.describe('Filter Tests: Numerical', () => {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'numberBased' }); await dashboard.treeView.openTable({ title: 'numberBased' });
// Enable NULL & EMPTY filters
await dashboard.gotoSettings();
await dashboard.settings.toggleNullEmptyFilters();
let eqStringDerived = eqString; let eqStringDerived = eqString;
let isLikeStringDerived = isLikeString; let isLikeStringDerived = isLikeString;
if (dataType === 'Duration') { if (dataType === 'Duration') {
@ -303,6 +300,10 @@ test.describe('Filter Tests: Text based', () => {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'textBased' }); await dashboard.treeView.openTable({ title: 'textBased' });
// Enable NULL & EMPTY filters
await dashboard.gotoSettings();
await dashboard.settings.toggleNullEmptyFilters();
const filterList = [ const filterList = [
{ {
op: 'is equal', op: 'is equal',
@ -467,6 +468,10 @@ test.describe('Filter Tests: Select based', () => {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'selectBased' }); await dashboard.treeView.openTable({ title: 'selectBased' });
// Enable NULL & EMPTY filters
await dashboard.gotoSettings();
await dashboard.settings.toggleNullEmptyFilters();
const filterList = [ const filterList = [
{ {
op: 'is', op: 'is',
@ -604,6 +609,10 @@ test.describe('Filter Tests: AddOn', () => {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'addOnTypes' }); await dashboard.treeView.openTable({ title: 'addOnTypes' });
// Enable NULL & EMPTY filters
await dashboard.gotoSettings();
await dashboard.settings.toggleNullEmptyFilters();
const filterList = [ const filterList = [
{ {
op: 'is checked', op: 'is checked',
@ -713,9 +722,7 @@ test.describe('Filter Tests: Toggle button', () => {
// Enable NULL & EMPTY button // Enable NULL & EMPTY button
await dashboard.gotoSettings(); await dashboard.gotoSettings();
await dashboard.settings.selectTab({ tab: SettingTab.ProjectSettings, subTab: SettingsSubTab.Miscellaneous }); await dashboard.settings.toggleNullEmptyFilters();
await dashboard.settings.miscellaneous.clickShowNullEmptyFilters();
await dashboard.settings.close();
// Verify filter options // Verify filter options
await verifyFilterOperatorList({ await verifyFilterOperatorList({
@ -746,19 +753,15 @@ test.describe('Filter Tests: Toggle button', () => {
// Disable NULL & EMPTY button // Disable NULL & EMPTY button
await dashboard.gotoSettings(); await dashboard.gotoSettings();
await dashboard.settings.selectTab({ tab: SettingTab.ProjectSettings, subTab: SettingsSubTab.Miscellaneous }); await dashboard.settings.toggleNullEmptyFilters();
await dashboard.settings.miscellaneous.clickShowNullEmptyFilters();
// wait for toast message // wait for toast message
await dashboard.verifyToast({ message: 'Null / Empty filters exist. Please remove them first.' }); await dashboard.verifyToast({ message: 'Null / Empty filters exist. Please remove them first.' });
await dashboard.settings.close();
// remove filter // remove filter
await toolbar.filter.reset(); await toolbar.filter.reset();
// Disable NULL & EMPTY button // Disable NULL & EMPTY button
await dashboard.gotoSettings(); await dashboard.gotoSettings();
await dashboard.settings.selectTab({ tab: SettingTab.ProjectSettings, subTab: SettingsSubTab.Miscellaneous }); await dashboard.settings.toggleNullEmptyFilters();
await dashboard.settings.miscellaneous.clickShowNullEmptyFilters();
await dashboard.settings.close();
}); });
}); });

Loading…
Cancel
Save