Browse Source

refactor(test): Cleanup

pull/4393/head
Muhammed Mustafa 2 years ago
parent
commit
aabed09d04
  1. 2
      tests/playwright/pages/Account/ChangePassword.ts
  2. 3
      tests/playwright/pages/Account/Users.ts
  3. 10
      tests/playwright/pages/Account/index.ts
  4. 7
      tests/playwright/pages/ProjectsPage/index.ts
  5. 2
      tests/playwright/tests/accountUserSettings.spec.ts
  6. 14
      tests/playwright/tests/authChangePassword.spec.ts

2
tests/playwright/pages/ProjectsPage/ChangePassword.ts → 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({

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

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

7
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 }) {

2
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 () => {

14
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',

Loading…
Cancel
Save