test: add reset password tests
This commit is contained in:
@@ -6,9 +6,11 @@ export class MyProfilePage extends AuthenticatedPage {
|
|||||||
|
|
||||||
this.fullName = this.page.locator('[name="fullName"]');
|
this.fullName = this.page.locator('[name="fullName"]');
|
||||||
this.email = this.page.locator('[name="email"]');
|
this.email = this.page.locator('[name="email"]');
|
||||||
|
this.currentPassword = this.page.locator('[name="currentPassword"]');
|
||||||
this.newPassword = this.page.locator('[name="password"]');
|
this.newPassword = this.page.locator('[name="password"]');
|
||||||
this.passwordConfirmation = this.page.locator('[name="confirmPassword"]');
|
this.passwordConfirmation = this.page.locator('[name="confirmPassword"]');
|
||||||
this.updateProfileButton = this.page.getByTestId('update-profile-button');
|
this.updateProfileButton = this.page.getByTestId('update-profile-button');
|
||||||
|
this.updatePasswordButton = this.page.getByTestId('update-password-button');
|
||||||
this.settingsMenuItem = this.page.getByRole('menuitem', {
|
this.settingsMenuItem = this.page.getByRole('menuitem', {
|
||||||
name: 'Settings',
|
name: 'Settings',
|
||||||
});
|
});
|
||||||
|
@@ -1,17 +1,19 @@
|
|||||||
const { publicTest, expect } = require('../../fixtures/index');
|
const { publicTest, expect } = require('../../fixtures/index');
|
||||||
const { AdminUsersPage } = require('../../fixtures/admin/users-page');
|
const { AdminUsersPage } = require('../../fixtures/admin/users-page');
|
||||||
const { MyProfilePage } = require('../../fixtures/my-profile-page');
|
const { MyProfilePage } = require('../../fixtures/my-profile-page');
|
||||||
|
const { LoginPage } = require('../../fixtures/login-page');
|
||||||
|
|
||||||
publicTest.describe('My Profile', () => {
|
publicTest.describe('My Profile', () => {
|
||||||
publicTest(
|
let testUser;
|
||||||
'user should be able to change own data',
|
|
||||||
|
publicTest.beforeEach(
|
||||||
async ({ acceptInvitationPage, adminCreateUserPage, loginPage, page }) => {
|
async ({ acceptInvitationPage, adminCreateUserPage, loginPage, page }) => {
|
||||||
let acceptInvitationLink;
|
let acceptInvitationLink;
|
||||||
|
|
||||||
adminCreateUserPage.seed(
|
adminCreateUserPage.seed(
|
||||||
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
|
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
|
||||||
);
|
);
|
||||||
const testUser = adminCreateUserPage.generateUser();
|
testUser = adminCreateUserPage.generateUser();
|
||||||
|
|
||||||
const adminUsersPage = new AdminUsersPage(page);
|
const adminUsersPage = new AdminUsersPage(page);
|
||||||
const myProfilePage = new MyProfilePage(page);
|
const myProfilePage = new MyProfilePage(page);
|
||||||
@@ -49,27 +51,76 @@ publicTest.describe('My Profile', () => {
|
|||||||
|
|
||||||
await publicTest.step('accept invitation', async () => {
|
await publicTest.step('accept invitation', async () => {
|
||||||
await page.goto(acceptInvitationLink);
|
await page.goto(acceptInvitationLink);
|
||||||
await acceptInvitationPage.acceptInvitation(process.env.LOGIN_PASSWORD);
|
await acceptInvitationPage.acceptInvitation(LoginPage.defaultPassword);
|
||||||
});
|
});
|
||||||
|
|
||||||
await publicTest.step('login as new Admin', async () => {
|
await publicTest.step('login as new Admin', async () => {
|
||||||
await loginPage.login(testUser.email, process.env.LOGIN_PASSWORD);
|
await loginPage.login(testUser.email, LoginPage.defaultPassword);
|
||||||
await expect(loginPage.loginButton).not.toBeVisible();
|
await expect(loginPage.loginButton).not.toBeVisible();
|
||||||
await expect(page).toHaveURL('/flows');
|
await expect(page).toHaveURL('/flows');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
publicTest('user should be able to change own data', async ({ page }) => {
|
||||||
|
const myProfilePage = new MyProfilePage(page);
|
||||||
|
|
||||||
await publicTest.step('change own data', async () => {
|
await publicTest.step('change own data', async () => {
|
||||||
await myProfilePage.navigateTo();
|
await myProfilePage.navigateTo();
|
||||||
|
|
||||||
await myProfilePage.fullName.fill('abecadło');
|
await myProfilePage.fullName.fill('abecadło');
|
||||||
await myProfilePage.email.fill('a' + testUser.email);
|
await myProfilePage.email.fill('a' + testUser.email);
|
||||||
|
await myProfilePage.updateProfileButton.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('verify changed data', async () => {
|
||||||
|
await expect(myProfilePage.fullName).toHaveValue('abecadło');
|
||||||
|
await expect(myProfilePage.email).toHaveValue('a' + testUser.email);
|
||||||
|
|
||||||
|
await page.reload();
|
||||||
|
|
||||||
|
await expect(myProfilePage.fullName).toHaveValue('abecadło');
|
||||||
|
await expect(myProfilePage.email).toHaveValue('a' + testUser.email);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
publicTest(
|
||||||
|
'user should not be able to change email to already existing one',
|
||||||
|
async ({ page }) => {
|
||||||
|
const myProfilePage = new MyProfilePage(page);
|
||||||
|
|
||||||
|
await publicTest.step('change email to existing one', async () => {
|
||||||
|
await myProfilePage.navigateTo();
|
||||||
|
|
||||||
|
await myProfilePage.email.fill(LoginPage.defaultEmail);
|
||||||
|
await myProfilePage.updateProfileButton.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('verify error message', async () => {
|
||||||
|
const snackbar = await myProfilePage.getSnackbarData(
|
||||||
|
'snackbar-update-profile-settings-error'
|
||||||
|
);
|
||||||
|
await expect(snackbar.variant).toBe('error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
publicTest(
|
||||||
|
'user should be able to change own password',
|
||||||
|
async ({ loginPage, page }) => {
|
||||||
|
const myProfilePage = new MyProfilePage(page);
|
||||||
|
|
||||||
|
await publicTest.step('change own password', async () => {
|
||||||
|
await myProfilePage.navigateTo();
|
||||||
|
|
||||||
|
await myProfilePage.currentPassword.fill(LoginPage.defaultPassword);
|
||||||
await myProfilePage.newPassword.fill(
|
await myProfilePage.newPassword.fill(
|
||||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
LoginPage.defaultPassword + LoginPage.defaultPassword
|
||||||
);
|
);
|
||||||
await myProfilePage.passwordConfirmation.fill(
|
await myProfilePage.passwordConfirmation.fill(
|
||||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
LoginPage.defaultPassword + LoginPage.defaultPassword
|
||||||
);
|
);
|
||||||
await myProfilePage.updateProfileButton.click();
|
await myProfilePage.updatePasswordButton.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
await publicTest.step('logout', async () => {
|
await publicTest.step('logout', async () => {
|
||||||
@@ -78,17 +129,58 @@ publicTest.describe('My Profile', () => {
|
|||||||
|
|
||||||
await publicTest.step('login with new credentials', async () => {
|
await publicTest.step('login with new credentials', async () => {
|
||||||
await loginPage.login(
|
await loginPage.login(
|
||||||
'a' + testUser.email,
|
testUser.email,
|
||||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
LoginPage.defaultPassword + LoginPage.defaultPassword
|
||||||
);
|
);
|
||||||
await expect(loginPage.loginButton).not.toBeVisible();
|
await expect(loginPage.loginButton).not.toBeVisible();
|
||||||
await expect(page).toHaveURL('/flows');
|
await expect(page).toHaveURL('/flows');
|
||||||
});
|
});
|
||||||
|
|
||||||
await publicTest.step('verify changed data', async () => {
|
await publicTest.step('verify if user is the same', async () => {
|
||||||
await myProfilePage.navigateTo();
|
await myProfilePage.navigateTo();
|
||||||
await expect(myProfilePage.fullName).toHaveValue('abecadło');
|
await expect(myProfilePage.email).toHaveValue(testUser.email);
|
||||||
await expect(myProfilePage.email).toHaveValue('a' + testUser.email);
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
publicTest(
|
||||||
|
'user should not be able to change own password if current one is incorrect',
|
||||||
|
async ({ loginPage, page }) => {
|
||||||
|
const myProfilePage = new MyProfilePage(page);
|
||||||
|
|
||||||
|
await publicTest.step('change own password', async () => {
|
||||||
|
await myProfilePage.navigateTo();
|
||||||
|
|
||||||
|
await myProfilePage.currentPassword.fill('wrongpassword');
|
||||||
|
await myProfilePage.newPassword.fill(
|
||||||
|
LoginPage.defaultPassword + LoginPage.defaultPassword
|
||||||
|
);
|
||||||
|
await myProfilePage.passwordConfirmation.fill(
|
||||||
|
LoginPage.defaultPassword + LoginPage.defaultPassword
|
||||||
|
);
|
||||||
|
await myProfilePage.updatePasswordButton.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('verify error message', async () => {
|
||||||
|
const snackbar = await myProfilePage.getSnackbarData(
|
||||||
|
'snackbar-update-password-error'
|
||||||
|
);
|
||||||
|
await expect(snackbar.variant).toBe('error');
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('logout', async () => {
|
||||||
|
await myProfilePage.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('login with old credentials', async () => {
|
||||||
|
await loginPage.login(testUser.email, LoginPage.defaultPassword);
|
||||||
|
await expect(loginPage.loginButton).not.toBeVisible();
|
||||||
|
await expect(page).toHaveURL('/flows');
|
||||||
|
});
|
||||||
|
|
||||||
|
await publicTest.step('verify if user is the same', async () => {
|
||||||
|
await myProfilePage.navigateTo();
|
||||||
|
await expect(myProfilePage.email).toHaveValue(testUser.email);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user