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 ```js
async resetFilter() { async resetFilter() {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/', 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 newPassword.fill(newPass);
await confirmPassword.fill(repeatPass); await confirmPassword.fill(repeatPass);
const submitChangePassword = () => const submitChangePassword = async () =>
this.get().locator('button[data-testid="nc-user-settings-form__submit"]').click(); await this.get().locator('button[data-testid="nc-user-settings-form__submit"]').click();
if (networkValidation) { if (networkValidation) {
await this.waitForResponse({ await this.waitForResponse({
uiAction: submitChangePassword, uiAction: submitChangePassword,

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

@ -326,7 +326,7 @@ export class ColumnPageObject extends BasePage {
} }
await this.waitForResponse({ 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', requestUrlPathToMatch: 'api/v1/db/meta/views',
httpMethodsToMatch: ['PATCH'], httpMethodsToMatch: ['PATCH'],
}); });
@ -336,7 +336,7 @@ export class ColumnPageObject extends BasePage {
async save({ isUpdated }: { isUpdated?: boolean } = {}) { async save({ isUpdated }: { isUpdated?: boolean } = {}) {
await this.waitForResponse({ 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/', requestUrlPathToMatch: 'api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
responseJsonMatcher: json => json['pageInfo'], responseJsonMatcher: json => json['pageInfo'],

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

@ -63,7 +63,7 @@ export class ImportTemplatePage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
requestUrlPathToMatch: '/api/v1/db/data/noco/', requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], 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({ await this.dashboard.waitForTabRender({
title: tblList[0], title: tblList[0],

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

@ -19,7 +19,7 @@ export class AclPage extends BasePage {
async save() { async save() {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: '/visibility-rules', requestUrlPathToMatch: '/visibility-rules',
}); });

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

@ -94,7 +94,7 @@ export class TreeViewPage extends BasePage {
if (networkResponse === true) { if (networkResponse === true) {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`, requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: json => json.pageInfo, 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.dashboard.get().getByPlaceholder('Enter table name').fill(title);
await this.waitForResponse({ 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'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/projects/`, requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
responseJsonMatcher: json => json.title === title && json.type === 'table', 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.dashboard.get().locator('div.nc-project-menu-item:has-text("Delete")').click();
await this.waitForResponse({ 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'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: `/api/v1/db/meta/tables/`, requestUrlPathToMatch: `/api/v1/db/meta/tables/`,
}); });
@ -213,7 +213,7 @@ export class TreeViewPage extends BasePage {
} }
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.rootPage.getByRole('button', { name: 'Confirm' }).click(), uiAction: async () => await this.rootPage.getByRole('button', { name: 'Confirm' }).click(),
httpMethodsToMatch: ['POST'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/duplicate/`, 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() { async save() {
const saveAction = () => this.saveButton.click(); const saveAction = async () => await this.saveButton.click();
await this.waitForResponse({ await this.waitForResponse({
uiAction: saveAction, 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 }) { async select({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['POST', 'PATCH'],
requestUrlPathToMatch: 'api/v1/db/data/noco/', 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) { async inCellExpand({ index, columnHeader }: CellProps) {
await this.get({ index, columnHeader }).hover(); await this.get({ index, columnHeader }).hover();
await this.waitForResponse({ 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/', requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
@ -307,7 +307,7 @@ export class CellPageObject extends BasePage {
// arrow expand doesn't exist for bt columns // arrow expand doesn't exist for bt columns
if (await arrow_expand.count()) { if (await arrow_expand.count()) {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => arrow_expand.click(), uiAction: async () => await arrow_expand.click(),
requestUrlPathToMatch: '/api/v1/db', requestUrlPathToMatch: '/api/v1/db',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
@ -329,7 +329,7 @@ export class CellPageObject extends BasePage {
const cell = this.get({ index, columnHeader }); const cell = this.get({ index, columnHeader });
await cell.click(); await cell.click();
await this.waitForResponse({ 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/', requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], 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 }) { async click({ title, isLocallySaved }: { title: string; isLocallySaved?: boolean }) {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => uiAction: async () =>
this.get().locator(`[data-testid="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]').click(), 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/', requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
@ -69,7 +69,7 @@ export class ToolbarFieldsPage extends BasePage {
async hideAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) { async hideAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields(); await this.toolbar.clickFields();
await this.waitForResponse({ 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/', requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
@ -79,7 +79,7 @@ export class ToolbarFieldsPage extends BasePage {
async showAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) { async showAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields(); await this.toolbar.clickFields();
await this.waitForResponse({ 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/', requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
@ -89,7 +89,7 @@ export class ToolbarFieldsPage extends BasePage {
async toggleShowSystemFields({ isLocallySaved }: { isLocallySaved?: boolean } = {}) { async toggleShowSystemFields({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
await this.toolbar.clickFields(); await this.toolbar.clickFields();
await this.waitForResponse({ 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/', requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });

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

@ -140,8 +140,8 @@ export class ToolbarFilterPage extends BasePage {
.click(); .click();
} else { } else {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => uiAction: async () =>
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`)
.click(), .click(),
@ -164,8 +164,8 @@ export class ToolbarFilterPage extends BasePage {
.click(); .click();
} else { } else {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => uiAction: async () =>
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}")`)
.first() .first()
@ -193,8 +193,8 @@ export class ToolbarFilterPage extends BasePage {
.click(); .click();
} else { } else {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => uiAction: async () =>
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}")`)
.first() .first()
@ -239,7 +239,7 @@ export class ToolbarFilterPage extends BasePage {
await this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(); await this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click();
} else { } else {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, 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); await this.get().locator('.nc-filter-value-select').locator('input').fill(value);
} else { } else {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
}); });
@ -320,7 +320,7 @@ export class ToolbarFilterPage extends BasePage {
await this.toolbar.clickFilter(); await this.toolbar.clickFilter();
if (networkValidation) { if (networkValidation) {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/', requestUrlPathToMatch: '/api/v1/db/meta/filters/',
}); });
@ -333,7 +333,7 @@ export class ToolbarFilterPage extends BasePage {
async remove({ networkValidation = true }: { networkValidation?: boolean } = {}) { async remove({ networkValidation = true }: { networkValidation?: boolean } = {}) {
if (networkValidation) { if (networkValidation) {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/filters/', requestUrlPathToMatch: '/api/v1/db/meta/filters/',
}); });

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

@ -16,7 +16,7 @@ export class SharedFormPage extends BasePage {
async submit() { async submit() {
await this.waitForResponse({ 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'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: '/rows', requestUrlPathToMatch: '/rows',
}); });

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

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

Loading…
Cancel
Save