Browse Source

test: fix undo filter test

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5624/head
mertmit 2 years ago
parent
commit
b07b717b30
  1. 113
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  2. 6
      tests/playwright/tests/db/undo-redo.spec.ts

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

@ -45,6 +45,7 @@ export class ToolbarFilterPage extends BasePage {
locallySaved = false, locallySaved = false,
dataType, dataType,
openModal = false, openModal = false,
skipWaitingResponse = false, // used for undo (single request, less stable)
}: { }: {
title: string; title: string;
operation: string; operation: string;
@ -53,21 +54,32 @@ export class ToolbarFilterPage extends BasePage {
locallySaved?: boolean; locallySaved?: boolean;
dataType?: string; dataType?: string;
openModal?: boolean; openModal?: 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();
const selectedField = await getTextExcludeIconText(await this.rootPage.locator('.nc-filter-field-select .ant-select-selection-item')); const selectedField = await getTextExcludeIconText(
await this.rootPage.locator('.nc-filter-field-select .ant-select-selection-item')
);
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();
await this.waitForResponse({ if (skipWaitingResponse) {
uiAction: () => this.rootPage 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`)
.click(), .click();
httpMethodsToMatch: ['GET'], } else {
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, await this.waitForResponse({
}); uiAction: () =>
this.rootPage
.locator('div.ant-select-dropdown.nc-dropdown-toolbar-field-list')
.locator(`div[label="${title}"]:visible`)
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
}
} }
const selectedOpType = await getTextExcludeIconText(await this.rootPage.locator('.nc-filter-operation-select')); const selectedOpType = await getTextExcludeIconText(await this.rootPage.locator('.nc-filter-operation-select'));
@ -75,15 +87,24 @@ 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 >, >=
await this.waitForResponse({ if (skipWaitingResponse) {
uiAction: () => this.rootPage 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}")`)
.first() .first()
.click(), .click();
httpMethodsToMatch: ['GET'], } else {
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, await this.waitForResponse({
}); uiAction: () =>
this.rootPage
.locator('.nc-dropdown-filter-comp-op')
.locator(`.ant-select-item:has-text("${operation}")`)
.first()
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
}
} }
// subtype for date // subtype for date
@ -95,15 +116,24 @@ 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 >, >=
await this.waitForResponse({ if (skipWaitingResponse) {
uiAction: () => this.rootPage 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}")`)
.first() .first()
.click(), .click();
httpMethodsToMatch: ['GET'], } else {
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, await this.waitForResponse({
}); uiAction: () =>
this.rootPage
.locator('.nc-dropdown-filter-comp-sub-op')
.locator(`.ant-select-item:has-text("${subOperation}")`)
.first()
.click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
}
} }
} }
@ -135,11 +165,16 @@ export class ToolbarFilterPage extends BasePage {
if (subOperation === 'exact date') { if (subOperation === 'exact date') {
await this.get().locator('.nc-filter-value-select').click(); await this.get().locator('.nc-filter-value-select').click();
await this.rootPage.locator(`.ant-picker-dropdown:visible`); await this.rootPage.locator(`.ant-picker-dropdown:visible`);
await this.waitForResponse({
uiAction: () => this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(), if (skipWaitingResponse) {
httpMethodsToMatch: ['GET'], this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click();
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, } else {
}); await this.waitForResponse({
uiAction: () => this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
}
} else { } else {
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({
@ -152,11 +187,15 @@ export class ToolbarFilterPage extends BasePage {
} }
break; break;
case UITypes.Duration: case UITypes.Duration:
await this.waitForResponse({ if (skipWaitingResponse) {
uiAction: () => this.get().locator('.nc-filter-value-select').locator('input').fill(value), this.get().locator('.nc-filter-value-select').locator('input').fill(value);
httpMethodsToMatch: ['GET'], } else {
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, await this.waitForResponse({
}); uiAction: () => this.get().locator('.nc-filter-value-select').locator('input').fill(value),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
}
break; break;
case UITypes.Rating: case UITypes.Rating:
await this.get() await this.get()

6
tests/playwright/tests/db/undo-redo.spec.ts

@ -273,15 +273,19 @@ test.describe('Undo Redo', () => {
} }
await toolbar.clickFilter(); await toolbar.clickFilter();
await toolbar.filter.add({ title: 'Number', operation: '=', value: '33' }); await toolbar.filter.add({ title: 'Number', operation: '=', value: '33', skipWaitingResponse: true });
await toolbar.clickFilter(); await toolbar.clickFilter();
await verifyRecords({ filtered: true }); await verifyRecords({ filtered: true });
await toolbar.filter.reset(); await toolbar.filter.reset();
await verifyRecords({ filtered: false }); await verifyRecords({ filtered: false });
// undo: remove filter
await undo({ page }); await undo({ page });
await verifyRecords({ filtered: true }); await verifyRecords({ filtered: true });
// undo: update filter
await undo({ page });
// undo: add filter
await undo({ page }); await undo({ page });
await verifyRecords({ filtered: false }); await verifyRecords({ filtered: false });
}); });

Loading…
Cancel
Save