From deac9a9745656776471ee44bcc1ccee1e9c72bcd Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 28 Jun 2023 14:19:32 +0800 Subject: [PATCH] chore(playwright): revise uiAction --- .../content/en/engineering/playwright.md | 2 +- .../pages/Account/ChangePassword.ts | 4 ++-- .../pages/Dashboard/Grid/Column/index.ts | 4 ++-- .../pages/Dashboard/Import/ImportTemplate.ts | 2 +- .../pages/Dashboard/Settings/Acl.ts | 2 +- tests/playwright/pages/Dashboard/TreeView.ts | 8 ++++---- .../pages/Dashboard/WebhookForm/index.ts | 2 +- .../pages/Dashboard/common/Cell/RatingCell.ts | 2 +- .../pages/Dashboard/common/Cell/index.ts | 6 +++--- .../pages/Dashboard/common/Toolbar/Fields.ts | 10 +++++----- .../pages/Dashboard/common/Toolbar/Filter.ts | 20 +++++++++---------- tests/playwright/pages/SharedForm/index.ts | 2 +- tests/playwright/tests/db/undo-redo.spec.ts | 4 ++-- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/noco-docs/content/en/engineering/playwright.md b/packages/noco-docs/content/en/engineering/playwright.md index 5d38890740..9a273113d3 100644 --- a/packages/noco-docs/content/en/engineering/playwright.md +++ b/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/', }); diff --git a/tests/playwright/pages/Account/ChangePassword.ts b/tests/playwright/pages/Account/ChangePassword.ts index af414c4c25..f18bc3f72e 100644 --- a/tests/playwright/pages/Account/ChangePassword.ts +++ b/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, diff --git a/tests/playwright/pages/Dashboard/Grid/Column/index.ts b/tests/playwright/pages/Dashboard/Grid/Column/index.ts index 3e188aed76..694a9271ba 100644 --- a/tests/playwright/pages/Dashboard/Grid/Column/index.ts +++ b/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'], diff --git a/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts b/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts index bc9afbfb4f..ccde9db145 100644 --- a/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts +++ b/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], diff --git a/tests/playwright/pages/Dashboard/Settings/Acl.ts b/tests/playwright/pages/Dashboard/Settings/Acl.ts index 93384a1155..e9f25a7794 100644 --- a/tests/playwright/pages/Dashboard/Settings/Acl.ts +++ b/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', }); diff --git a/tests/playwright/pages/Dashboard/TreeView.ts b/tests/playwright/pages/Dashboard/TreeView.ts index ad0a5ba676..73c2a3db69 100644 --- a/tests/playwright/pages/Dashboard/TreeView.ts +++ b/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/`, }); diff --git a/tests/playwright/pages/Dashboard/WebhookForm/index.ts b/tests/playwright/pages/Dashboard/WebhookForm/index.ts index 4317c810a9..baa6490dbc 100644 --- a/tests/playwright/pages/Dashboard/WebhookForm/index.ts +++ b/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, diff --git a/tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts b/tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts index 0b9b059b13..245aa2756c 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts +++ b/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/', }); diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 02399664c7..ac51aa9796 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/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'], }); diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Fields.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Fields.ts index cd64933fec..79bbc4ca62 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Fields.ts +++ b/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'], }); diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts index f9ed740107..7d641b402b 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts +++ b/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/', }); diff --git a/tests/playwright/pages/SharedForm/index.ts b/tests/playwright/pages/SharedForm/index.ts index 0d6a32c2c5..bdea30bfa1 100644 --- a/tests/playwright/pages/SharedForm/index.ts +++ b/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', }); diff --git a/tests/playwright/tests/db/undo-redo.spec.ts b/tests/playwright/tests/db/undo-redo.spec.ts index 52b402bf4c..0f989ce175 100644 --- a/tests/playwright/tests/db/undo-redo.spec.ts +++ b/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,