Browse Source

chore(playwright): revise uiAction

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
deac9a9745
  1. 2
      packages/noco-docs/content/en/engineering/playwright.md
  2. 4
      tests/playwright/pages/Account/ChangePassword.ts
  3. 4
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  4. 2
      tests/playwright/pages/Dashboard/Import/ImportTemplate.ts
  5. 2
      tests/playwright/pages/Dashboard/Settings/Acl.ts
  6. 8
      tests/playwright/pages/Dashboard/TreeView.ts
  7. 2
      tests/playwright/pages/Dashboard/WebhookForm/index.ts
  8. 2
      tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts
  9. 6
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  10. 10
      tests/playwright/pages/Dashboard/common/Toolbar/Fields.ts
  11. 20
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  12. 2
      tests/playwright/pages/SharedForm/index.ts
  13. 4
      tests/playwright/tests/db/undo-redo.spec.ts

2
packages/noco-docs/content/en/engineering/playwright.md

@ -189,7 +189,7 @@ This a method which will reset/clear all the filters. Since this is an action me
```js
async resetFilter() {
await this.waitForResponse({
uiAction: () => this.get().locator('.nc-filter-item-remove-btn').click(),
uiAction: async () => await this.get().locator('.nc-filter-item-remove-btn').click(),
httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/',
});

4
tests/playwright/pages/Account/ChangePassword.ts

@ -37,8 +37,8 @@ export class ChangePasswordPage extends BasePage {
await newPassword.fill(newPass);
await confirmPassword.fill(repeatPass);
const submitChangePassword = () =>
this.get().locator('button[data-testid="nc-user-settings-form__submit"]').click();
const submitChangePassword = async () =>
await this.get().locator('button[data-testid="nc-user-settings-form__submit"]').click();
if (networkValidation) {
await this.waitForResponse({
uiAction: submitChangePassword,

4
tests/playwright/pages/Dashboard/Grid/Column/index.ts

@ -326,7 +326,7 @@ export class ColumnPageObject extends BasePage {
}
await this.waitForResponse({
uiAction: () => this.rootPage.locator('li[role="menuitem"]:has-text("Hide Field"):visible').click(),
uiAction: async() => await this.rootPage.locator('li[role="menuitem"]:has-text("Hide Field"):visible').click(),
requestUrlPathToMatch: 'api/v1/db/meta/views',
httpMethodsToMatch: ['PATCH'],
});
@ -336,7 +336,7 @@ export class ColumnPageObject extends BasePage {
async save({ isUpdated }: { isUpdated?: boolean } = {}) {
await this.waitForResponse({
uiAction: () => this.get().locator('button:has-text("Save")').click(),
uiAction: async() => await this.get().locator('button:has-text("Save")').click(),
requestUrlPathToMatch: 'api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
responseJsonMatcher: json => json['pageInfo'],

2
tests/playwright/pages/Dashboard/Import/ImportTemplate.ts

@ -63,7 +63,7 @@ export class ImportTemplatePage extends BasePage {
await this.waitForResponse({
requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
uiAction: () => this.get().locator('button:has-text("Import"):visible').click(),
uiAction: async () => await this.get().locator('button:has-text("Import"):visible').click(),
});
await this.dashboard.waitForTabRender({
title: tblList[0],

2
tests/playwright/pages/Dashboard/Settings/Acl.ts

@ -19,7 +19,7 @@ export class AclPage extends BasePage {
async save() {
await this.waitForResponse({
uiAction: () => this.get().locator(`button:has-text("Save")`).click(),
uiAction: async() => await this.get().locator(`button:has-text("Save")`).click(),
httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: '/visibility-rules',
});

8
tests/playwright/pages/Dashboard/TreeView.ts

@ -94,7 +94,7 @@ export class TreeViewPage extends BasePage {
if (networkResponse === true) {
await this.waitForResponse({
uiAction: () => this.get().locator(`.nc-project-tree-tbl-${title}`).click(),
uiAction: async () => await this.get().locator(`.nc-project-tree-tbl-${title}`).click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: json => json.pageInfo,
@ -114,7 +114,7 @@ export class TreeViewPage extends BasePage {
await this.dashboard.get().getByPlaceholder('Enter table name').fill(title);
await this.waitForResponse({
uiAction: () => this.dashboard.get().locator('button:has-text("Submit")').click(),
uiAction: async () => await this.dashboard.get().locator('button:has-text("Submit")').click(),
httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
responseJsonMatcher: json => json.title === title && json.type === 'table',
@ -141,7 +141,7 @@ export class TreeViewPage extends BasePage {
await this.dashboard.get().locator('div.nc-project-menu-item:has-text("Delete")').click();
await this.waitForResponse({
uiAction: () => this.dashboard.get().locator('button:has-text("Yes")').click(),
uiAction: async () => await this.dashboard.get().locator('button:has-text("Yes")').click(),
httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: `/api/v1/db/meta/tables/`,
});
@ -213,7 +213,7 @@ export class TreeViewPage extends BasePage {
}
await this.waitForResponse({
uiAction: () => this.rootPage.getByRole('button', { name: 'Confirm' }).click(),
uiAction: async () => await this.rootPage.getByRole('button', { name: 'Confirm' }).click(),
httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/duplicate/`,
});

2
tests/playwright/pages/Dashboard/WebhookForm/index.ts

@ -97,7 +97,7 @@ export class WebhookFormPage extends BasePage {
}
async save() {
const saveAction = () => this.saveButton.click();
const saveAction = async () => await this.saveButton.click();
await this.waitForResponse({
uiAction: saveAction,

2
tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts

@ -16,7 +16,7 @@ export class RatingCellPageObject extends BasePage {
async select({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await this.waitForResponse({
uiAction: () => this.get({ index, columnHeader }).locator('.ant-rate-star > div').nth(rating).click(),
uiAction: async () => await this.get({ index, columnHeader }).locator('.ant-rate-star > div').nth(rating).click(),
httpMethodsToMatch: ['POST', 'PATCH'],
requestUrlPathToMatch: 'api/v1/db/data/noco/',
});

6
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -84,7 +84,7 @@ export class CellPageObject extends BasePage {
async inCellExpand({ index, columnHeader }: CellProps) {
await this.get({ index, columnHeader }).hover();
await this.waitForResponse({
uiAction: () => this.get({ index, columnHeader }).locator('.nc-action-icon >> nth=0').click(),
uiAction: async () =>await this.get({ index, columnHeader }).locator('.nc-action-icon >> nth=0').click(),
requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});
@ -307,7 +307,7 @@ export class CellPageObject extends BasePage {
// arrow expand doesn't exist for bt columns
if (await arrow_expand.count()) {
await this.waitForResponse({
uiAction: () => arrow_expand.click(),
uiAction: async () => await arrow_expand.click(),
requestUrlPathToMatch: '/api/v1/db',
httpMethodsToMatch: ['GET'],
});
@ -329,7 +329,7 @@ export class CellPageObject extends BasePage {
const cell = this.get({ index, columnHeader });
await cell.click();
await this.waitForResponse({
uiAction: () => cell.locator('.unlink-icon').first().click(),
uiAction: async () => await cell.locator('.unlink-icon').first().click(),
requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});

10
tests/playwright/pages/Dashboard/common/Toolbar/Fields.ts

@ -58,8 +58,8 @@ export class ToolbarFieldsPage extends BasePage {
async click({ title, isLocallySaved }: { title: string; isLocallySaved?: boolean }) {
await this.waitForResponse({
uiAction: () =>
this.get().locator(`[data-testid="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]').click(),
uiAction: async () =>
await this.get().locator(`[data-testid="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]').click(),
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});
@ -69,7 +69,7 @@ export class ToolbarFieldsPage extends BasePage {
async hideAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields();
await this.waitForResponse({
uiAction: () => this.get().locator(`button:has-text("Hide all")`).click(),
uiAction: async () => await this.get().locator(`button:has-text("Hide all")`).click(),
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});
@ -79,7 +79,7 @@ export class ToolbarFieldsPage extends BasePage {
async showAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields();
await this.waitForResponse({
uiAction: () => this.get().locator(`button:has-text("Show all")`).click(),
uiAction: async () => await this.get().locator(`button:has-text("Show all")`).click(),
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});
@ -89,7 +89,7 @@ export class ToolbarFieldsPage extends BasePage {
async toggleShowSystemFields({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields();
await this.waitForResponse({
uiAction: () => this.get().locator(`.nc-fields-show-system-fields`).click(),
uiAction: async () => await this.get().locator(`.nc-fields-show-system-fields`).click(),
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});

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

@ -140,8 +140,8 @@ export class ToolbarFilterPage extends BasePage {
.click();
} else {
await this.waitForResponse({
uiAction: () =>
this.rootPage
uiAction: async () =>
await this.rootPage
.locator('div.ant-select-dropdown.nc-dropdown-toolbar-field-list')
.locator(`div[label="${title}"]:visible`)
.click(),
@ -164,8 +164,8 @@ export class ToolbarFilterPage extends BasePage {
.click();
} else {
await this.waitForResponse({
uiAction: () =>
this.rootPage
uiAction: async () =>
await this.rootPage
.locator('.nc-dropdown-filter-comp-op')
.locator(`.ant-select-item:has-text("${operation}")`)
.first()
@ -193,8 +193,8 @@ export class ToolbarFilterPage extends BasePage {
.click();
} else {
await this.waitForResponse({
uiAction: () =>
this.rootPage
uiAction: async () =>
await this.rootPage
.locator('.nc-dropdown-filter-comp-sub-op')
.locator(`.ant-select-item:has-text("${subOperation}")`)
.first()
@ -239,7 +239,7 @@ export class ToolbarFilterPage extends BasePage {
await this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click();
} else {
await this.waitForResponse({
uiAction: () => this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(),
uiAction: async () => await this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
@ -260,7 +260,7 @@ export class ToolbarFilterPage extends BasePage {
await this.get().locator('.nc-filter-value-select').locator('input').fill(value);
} else {
await this.waitForResponse({
uiAction: () => this.get().locator('.nc-filter-value-select').locator('input').fill(value),
uiAction: async () => await this.get().locator('.nc-filter-value-select').locator('input').fill(value),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
@ -320,7 +320,7 @@ export class ToolbarFilterPage extends BasePage {
await this.toolbar.clickFilter();
if (networkValidation) {
await this.waitForResponse({
uiAction: () => this.get().locator('.nc-filter-item-remove-btn').click(),
uiAction: async () => await this.get().locator('.nc-filter-item-remove-btn').click(),
httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/',
});
@ -333,7 +333,7 @@ export class ToolbarFilterPage extends BasePage {
async remove({ networkValidation = true }: { networkValidation?: boolean } = {}) {
if (networkValidation) {
await this.waitForResponse({
uiAction: () => this.get().locator('.nc-filter-item-remove-btn').click(),
uiAction: async () => await this.get().locator('.nc-filter-item-remove-btn').click(),
httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/',
});

2
tests/playwright/pages/SharedForm/index.ts

@ -16,7 +16,7 @@ export class SharedFormPage extends BasePage {
async submit() {
await this.waitForResponse({
uiAction: () => this.get().getByTestId('shared-form-submit-button').click(),
uiAction: async () => await this.get().getByTestId('shared-form-submit-button').click(),
httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: '/rows',
});

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

@ -40,7 +40,7 @@ async function undo({ page }: { page: Page }) {
if (validateResponse) {
await dashboard.grid.waitForResponse({
uiAction: () => page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'),
uiAction: async () => await page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: json => json.pageInfo,
@ -563,7 +563,7 @@ test.describe('Undo Redo - LTAR', () => {
async function undo({ page, values }: { page: Page; values: string[] }) {
const isMac = await grid.isMacOs();
await dashboard.grid.waitForResponse({
uiAction: () => page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'),
uiAction: async () => await page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: json => json.pageInfo,

Loading…
Cancel
Save