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({