From 951a0de370e11122ff4e62d73d2c9ebb20d6f7ca Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 18 May 2024 17:08:24 +0530 Subject: [PATCH 1/2] test: fix user field filter test Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/common/Toolbar/Filter.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts index a39431fa92..a0986c4d05 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts @@ -328,11 +328,17 @@ export class ToolbarFilterPage extends BasePage { const v = value.split(','); for (let i = 0; i < v.length; i++) { - await this.rootPage - .locator(`.nc-dropdown-user-select-cell`) - .getByTestId('select-option-User-filter') - .getByText(v[i]) - .click({ force: true }); + const selectUser = () => + this.rootPage + .locator(`.nc-dropdown-user-select-cell`) + .getByTestId('select-option-User-filter') + .getByText(v[i]) + .click({ force: true }); + await this.waitForResponse({ + uiAction: selectUser, + httpMethodsToMatch: ['GET'], + requestUrlPathToMatch: `/api/v1/db/data/noco/`, + }); } } break; From 2266159d45fe27e108ed9d0ce8553b5011e3e09a Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 18 May 2024 18:02:25 +0530 Subject: [PATCH 2/2] test: fix account user mgmt handling Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/Account/Users.ts | 7 ++++++- tests/playwright/pages/Base.ts | 3 +++ .../tests/db/usersAccounts/accountUserManagement.spec.ts | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/playwright/pages/Account/Users.ts b/tests/playwright/pages/Account/Users.ts index af2d6b2c9e..49b7ae9360 100644 --- a/tests/playwright/pages/Account/Users.ts +++ b/tests/playwright/pages/Account/Users.ts @@ -46,7 +46,12 @@ export class AccountUsersPage extends BasePage { await this.inviteUserModal.locator(`.nc-user-roles`).click(); const userRoleModal = this.rootPage.locator(`.nc-dropdown-user-role`); await userRoleModal.locator(`.nc-role-option:has-text("${role}")`).click(); - await this.inviteUserModal.locator(`button:has-text("Invite")`).click(); + const inviteAction = () => this.inviteUserModal.locator(`button:has-text("Invite")`).click(); + await this.waitForResponse({ + uiAction: inviteAction, + httpMethodsToMatch: ['GET'], + requestUrlPathToMatch: `api/v1/users`, + }); await this.verifyToast({ message: 'Successfully added user' }); // TODO: Wait on the invite api and get the invite url a better way as we are not waiting if the url is reflected in the UI diff --git a/tests/playwright/pages/Base.ts b/tests/playwright/pages/Base.ts index 7773015669..e136de1230 100644 --- a/tests/playwright/pages/Base.ts +++ b/tests/playwright/pages/Base.ts @@ -14,6 +14,9 @@ export default abstract class BasePage { async verifyToast({ message }: { message: string }) { await this.rootPage.locator('.ant-message .ant-message-notice-content', { hasText: message }).last().isVisible(); + + // ensure that the toast is removed from the DOM + // await this.rootPage.waitForSelector('.ant-message .ant-message-notice-content', { state: 'hidden' }); } async verifyErrorMessage({ message }: { message: RegExp }) { diff --git a/tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts b/tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts index ea82fc235f..3b6faee147 100644 --- a/tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts +++ b/tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts @@ -66,7 +66,7 @@ test.describe('User roles', () => { test('Invite user, update role and delete user', async () => { test.slow(); - await accountUsersPage.goto({ waitForResponse: false }); + await accountUsersPage.goto({ waitForResponse: true }); // invite user for (let i = 0; i < roleDb.length; i++) { @@ -78,7 +78,7 @@ test.describe('User roles', () => { } await signupAndVerify(0); - await accountUsersPage.goto({ waitForResponse: false }); + await accountUsersPage.goto({ waitForResponse: true }); await signupAndVerify(1); await dashboard.signOut(); @@ -88,7 +88,7 @@ test.describe('User roles', () => { withoutPrefix: true, }); - await accountUsersPage.goto({ waitForResponse: false }); + await accountUsersPage.goto({ waitForResponse: true }); // change role for (let i = 0; i < roleDb.length; i++) { await accountUsersPage.updateRole({