diff --git a/tests/playwright/pages/ProjectsPage/ChangePassword.ts b/tests/playwright/pages/Account/ChangePassword.ts similarity index 96% rename from tests/playwright/pages/ProjectsPage/ChangePassword.ts rename to tests/playwright/pages/Account/ChangePassword.ts index d98e68205d..00b3b6f2de 100644 --- a/tests/playwright/pages/ProjectsPage/ChangePassword.ts +++ b/tests/playwright/pages/Account/ChangePassword.ts @@ -7,7 +7,7 @@ export class ChangePasswordPage extends BasePage { } get() { - return this.rootPage.getByTestId('user-change-password'); + return this.rootPage.getByTestId('nc-user-settings-form'); } async changePassword({ diff --git a/tests/playwright/pages/Account/Users.ts b/tests/playwright/pages/Account/Users.ts index cfccd459a1..1618c98b6e 100644 --- a/tests/playwright/pages/Account/Users.ts +++ b/tests/playwright/pages/Account/Users.ts @@ -1,10 +1,12 @@ import { Locator } from '@playwright/test'; import BasePage from '../Base'; +import { ChangePasswordPage } from './ChangePassword'; import { AccountPage } from './index'; export class AccountUsersPage extends BasePage { readonly inviteUserBtn: Locator; readonly inviteUserModal: Locator; + readonly changePasswordPage: ChangePasswordPage; private accountPage: AccountPage; constructor(accountPage: AccountPage) { @@ -12,6 +14,7 @@ export class AccountUsersPage extends BasePage { this.accountPage = accountPage; this.inviteUserBtn = this.get().locator(`[data-testid="nc-super-user-invite"]`); this.inviteUserModal = accountPage.rootPage.locator(`.nc-modal-invite-user`); + this.changePasswordPage = new ChangePasswordPage(this.rootPage); } async goto() { diff --git a/tests/playwright/pages/Account/index.ts b/tests/playwright/pages/Account/index.ts index c2f4da62bb..34c321160d 100644 --- a/tests/playwright/pages/Account/index.ts +++ b/tests/playwright/pages/Account/index.ts @@ -1,9 +1,19 @@ import { Page } from '@playwright/test'; import BasePage from '../Base'; +import { AccountSettingsPage } from './Settings'; +import { AccountTokenPage } from './Token'; +import { AccountUsersPage } from './Users'; export class AccountPage extends BasePage { + readonly settings: AccountSettingsPage; + readonly token: AccountTokenPage; + readonly users: AccountUsersPage; + constructor(page: Page) { super(page); + this.settings = new AccountSettingsPage(this); + this.token = new AccountTokenPage(this); + this.users = new AccountUsersPage(this); } get() { diff --git a/tests/playwright/pages/ProjectsPage/index.ts b/tests/playwright/pages/ProjectsPage/index.ts index f44eab3283..7c5d24383d 100644 --- a/tests/playwright/pages/ProjectsPage/index.ts +++ b/tests/playwright/pages/ProjectsPage/index.ts @@ -1,14 +1,10 @@ import { expect, Page } from '@playwright/test'; import BasePage from '../Base'; import { DashboardPage } from '../Dashboard'; -import { ChangePasswordPage } from './ChangePassword'; export class ProjectsPage extends BasePage { - readonly changePasswordPage: ChangePasswordPage; - constructor(rootPage: Page) { super(rootPage); - this.changePasswordPage = new ChangePasswordPage(rootPage); } prefixTitle(title: string) { @@ -51,6 +47,9 @@ export class ProjectsPage extends BasePage { httpMethodsToMatch: ['POST'], requestUrlPathToMatch: '/api/v1/db/meta/projects/', }); + + // wait for dashboard to render + await this.rootPage.locator('.nc-container').waitFor({ state: 'visible' }); } async checkProjectCreateButton({ exists = true }) { diff --git a/tests/playwright/tests/accountUserSettings.spec.ts b/tests/playwright/tests/accountUserSettings.spec.ts index c6fe4b06cb..e8034e5448 100644 --- a/tests/playwright/tests/accountUserSettings.spec.ts +++ b/tests/playwright/tests/accountUserSettings.spec.ts @@ -13,7 +13,7 @@ test.describe('App settings', () => { test.beforeEach(async ({ page }) => { context = await setup({ page }); accountPage = new AccountPage(page); - accountSettingsPage = new AccountSettingsPage(accountPage); + accountSettingsPage = accountPage.settings; }); test('Toggle invite only signup', async () => { diff --git a/tests/playwright/tests/authChangePassword.spec.ts b/tests/playwright/tests/authChangePassword.spec.ts index c3be00eaed..da947665aa 100644 --- a/tests/playwright/tests/authChangePassword.spec.ts +++ b/tests/playwright/tests/authChangePassword.spec.ts @@ -5,6 +5,7 @@ import { LoginPage } from '../pages/LoginPage'; import { SettingsPage, SettingTab } from '../pages/Dashboard/Settings'; import { SignupPage } from '../pages/SignupPage'; import { ProjectsPage } from '../pages/ProjectsPage'; +import { AccountPage } from '../pages/Account'; test.describe('Auth', () => { let context: any; @@ -12,12 +13,15 @@ test.describe('Auth', () => { let settings: SettingsPage; let signupPage: SignupPage; let projectsPage: ProjectsPage; + let accountPage: AccountPage; test.beforeEach(async ({ page }) => { context = await setup({ page }); dashboard = new DashboardPage(page, context.project); signupPage = new SignupPage(page); projectsPage = new ProjectsPage(page); + accountPage = new AccountPage(page); + settings = dashboard.settings; }); @@ -43,24 +47,24 @@ test.describe('Auth', () => { await projectsPage.openPasswordChangeModal(); // Existing active pass incorrect - await projectsPage.changePasswordPage.changePassword({ + await accountPage.users.changePasswordPage.changePassword({ oldPass: '123456789', newPass: '123456789', repeatPass: '123456789', }); - await projectsPage.changePasswordPage.verifyFormError({ error: 'Current password is wrong' }); + await accountPage.users.changePasswordPage.verifyFormError({ error: 'Current password is wrong' }); // New pass and repeat pass mismatch - await projectsPage.changePasswordPage.changePassword({ + await accountPage.users.changePasswordPage.changePassword({ oldPass: 'Password123.', newPass: '123456789', repeatPass: '987654321', networkValidation: false, }); - await projectsPage.changePasswordPage.verifyPasswordDontMatchError(); + await accountPage.users.changePasswordPage.verifyPasswordDontMatchError(); // All good - await projectsPage.changePasswordPage.changePassword({ + await accountPage.users.changePasswordPage.changePassword({ oldPass: 'Password123.', newPass: 'NewPasswordConfigured', repeatPass: 'NewPasswordConfigured',