Browse Source

Merge pull request #8894 from nocodb/nc-test/flaky-filters

Nc test/flaky filters
fix/8667-wh-pay
Ramesh Mane 6 months ago committed by GitHub
parent
commit
254972cc96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 73
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

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

@ -131,19 +131,20 @@ export class ToolbarFilterPage extends BasePage {
openModal?: boolean; openModal?: boolean;
skipWaitingResponse?: boolean; skipWaitingResponse?: boolean;
}) { }) {
if (!openModal) await this.get().locator(`button:has-text("Add Filter")`).first().click(); if (!openModal) {
await this.get().locator(`button:has-text("Add Filter")`).first().click();
}
// TODO: Integrated the draft filter logic here as well, since when we add a filter its not saved till all const filterCount = await this.get().locator('.nc-filter-wrapper').count();
// its values are filled
skipWaitingResponse = true;
const selectedField = await getTextExcludeIconText( const selectedField = await getTextExcludeIconText(
this.rootPage.locator('.nc-filter-field-select .ant-select-selection-item').first() this.rootPage.locator('.nc-filter-field-select .ant-select-selection-item').first()
); );
if (selectedField !== title) { if (selectedField !== title) {
await this.rootPage.locator('.nc-filter-field-select').last().click(); await this.rootPage.locator('.nc-filter-field-select').last().click();
if (skipWaitingResponse) { if (skipWaitingResponse || filterCount === 1) {
await this.rootPage await this.rootPage
.locator('div.ant-select-dropdown.nc-dropdown-toolbar-field-list') .locator('div.ant-select-dropdown.nc-dropdown-toolbar-field-list')
.locator(`div[label="${title}"]:visible`) .locator(`div[label="${title}"]:visible`)
@ -168,7 +169,7 @@ export class ToolbarFilterPage extends BasePage {
await this.rootPage.locator('.nc-filter-operation-select').click(); await this.rootPage.locator('.nc-filter-operation-select').click();
// first() : filter list has >, >= // first() : filter list has >, >=
if (skipWaitingResponse) { if (skipWaitingResponse || filterCount === 1) {
await this.rootPage await this.rootPage
.locator('.nc-dropdown-filter-comp-op') .locator('.nc-dropdown-filter-comp-op')
.locator(`.ant-select-item:has-text("${operation}")`) .locator(`.ant-select-item:has-text("${operation}")`)
@ -197,7 +198,7 @@ export class ToolbarFilterPage extends BasePage {
await this.rootPage.locator('.nc-filter-sub_operation-select').click(); await this.rootPage.locator('.nc-filter-sub_operation-select').click();
// first() : filter list has >, >= // first() : filter list has >, >=
if (skipWaitingResponse) { if (skipWaitingResponse || filterCount === 1) {
await this.rootPage await this.rootPage
.locator('.nc-dropdown-filter-comp-sub-op') .locator('.nc-dropdown-filter-comp-sub-op')
.locator(`.ant-select-item:has-text("${subOperation}")`) .locator(`.ant-select-item:has-text("${subOperation}")`)
@ -309,10 +310,22 @@ export class ToolbarFilterPage extends BasePage {
// eslint-disable-next-line no-case-declarations // eslint-disable-next-line no-case-declarations
const v = value.split(','); const v = value.split(',');
for (let i = 0; i < v.length; i++) { for (let i = 0; i < v.length; i++) {
await this.rootPage if (skipWaitingResponse) {
.locator(`.nc-dropdown-multi-select-cell`) await this.rootPage
.locator(`[data-testid="select-option-MultiSelect-filter"].nc-select-option-MultiSelect-${v[i]}`) .locator(`.nc-dropdown-multi-select-cell`)
.click(); .locator(`[data-testid="select-option-MultiSelect-filter"].nc-select-option-MultiSelect-${v[i]}`)
.click();
} else {
await this.waitForResponse({
uiAction: async () =>
await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`)
.locator(`[data-testid="select-option-MultiSelect-filter"].nc-select-option-MultiSelect-${v[i]}`)
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
});
}
} }
break; break;
case UITypes.SingleSelect: case UITypes.SingleSelect:
@ -327,16 +340,40 @@ export class ToolbarFilterPage extends BasePage {
const val = value.split(','); const val = value.split(',');
if (val.length > 1) { if (val.length > 1) {
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
if (skipWaitingResponse) {
await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`)
.locator(`.nc-select-option-SingleSelect-${val[i]}`)
.click();
} else {
await this.waitForResponse({
uiAction: async () =>
await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`)
.locator(`.nc-select-option-SingleSelect-${val[i]}`)
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
});
}
}
} else {
if (skipWaitingResponse) {
await this.rootPage await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`) .locator(`.nc-dropdown-single-select-cell`)
.locator(`.nc-select-option-SingleSelect-${val[i]}`) .locator(`.nc-select-option-${title}-${value}`)
.click(); .click();
} else {
await this.waitForResponse({
uiAction: async () =>
await this.rootPage
.locator(`.nc-dropdown-single-select-cell`)
.locator(`.nc-select-option-${title}-${value}`)
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
});
} }
} else {
await this.rootPage
.locator(`.nc-dropdown-single-select-cell`)
.locator(`.nc-select-option-${title}-${value}`)
.click();
} }
break; break;
case UITypes.User: case UITypes.User:

Loading…
Cancel
Save