test: add change own user data test
This commit is contained in:
@@ -8,6 +8,7 @@ export class AuthenticatedPage extends BasePage {
|
||||
super(page);
|
||||
|
||||
this.profileMenuButton = this.page.getByTestId('profile-menu-button');
|
||||
this.logoutMenuItem = this.page.getByTestId('logout-item');
|
||||
this.adminMenuItem = this.page.getByRole('menuitem', { name: 'Admin' });
|
||||
this.userInterfaceDrawerItem = this.page.getByTestId(
|
||||
'user-interface-drawer-link'
|
||||
@@ -18,4 +19,9 @@ export class AuthenticatedPage extends BasePage {
|
||||
this.typographyLogo = this.page.getByTestId('typography-logo');
|
||||
this.customLogo = this.page.getByTestId('custom-logo');
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this.profileMenuButton.click();
|
||||
await this.logoutMenuItem.click();
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ exports.test = test.extend({
|
||||
userInterfacePage: async ({ page }, use) => {
|
||||
await use(new UserInterfacePage(page));
|
||||
},
|
||||
...adminFixtures
|
||||
...adminFixtures,
|
||||
});
|
||||
|
||||
exports.publicTest = test.extend({
|
||||
@@ -49,21 +49,18 @@ exports.publicTest = test.extend({
|
||||
|
||||
await use(loginPage);
|
||||
},
|
||||
|
||||
acceptInvitationPage: async ({ page }, use) => {
|
||||
const acceptInvitationPage = new AcceptInvitation(page);
|
||||
await use(acceptInvitationPage);
|
||||
},
|
||||
|
||||
adminSetupPage: async ({ page }, use) => {
|
||||
const adminSetupPage = new AdminSetupPage(page);
|
||||
await use(adminSetupPage);
|
||||
},
|
||||
|
||||
adminCreateUserPage: async ({ page }, use) => {
|
||||
const adminCreateUserPage = new AdminCreateUserPage(page);
|
||||
await use(adminCreateUserPage);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
expect.extend({
|
||||
|
21
packages/e2e-tests/fixtures/my-profile-page.js
Normal file
21
packages/e2e-tests/fixtures/my-profile-page.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { AuthenticatedPage } = require('./authenticated-page');
|
||||
|
||||
export class MyProfilePage extends AuthenticatedPage {
|
||||
constructor(page) {
|
||||
super(page);
|
||||
|
||||
this.fullName = this.page.locator('[name="fullName"]');
|
||||
this.email = this.page.locator('[name="email"]');
|
||||
this.newPassword = this.page.locator('[name="password"]');
|
||||
this.passwordConfirmation = this.page.locator('[name="confirmPassword"]');
|
||||
this.updateProfileButton = this.page.getByTestId('update-profile-button');
|
||||
this.settingsMenuItem = this.page.getByRole('menuitem', {
|
||||
name: 'Settings',
|
||||
});
|
||||
}
|
||||
|
||||
async navigateTo() {
|
||||
await this.profileMenuButton.click();
|
||||
await this.settingsMenuItem.click();
|
||||
}
|
||||
}
|
95
packages/e2e-tests/tests/my-profile/profile-updates.spec.js
Normal file
95
packages/e2e-tests/tests/my-profile/profile-updates.spec.js
Normal file
@@ -0,0 +1,95 @@
|
||||
const { publicTest, expect } = require('../../fixtures/index');
|
||||
const { AdminUsersPage } = require('../../fixtures/admin/users-page');
|
||||
const { MyProfilePage } = require('../../fixtures/my-profile-page');
|
||||
|
||||
publicTest.describe('My Profile', () => {
|
||||
publicTest(
|
||||
'user should be able to change own data',
|
||||
async ({ acceptInvitationPage, adminCreateUserPage, loginPage, page }) => {
|
||||
let acceptInvitationLink;
|
||||
|
||||
adminCreateUserPage.seed(
|
||||
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
|
||||
);
|
||||
const testUser = adminCreateUserPage.generateUser();
|
||||
|
||||
const adminUsersPage = new AdminUsersPage(page);
|
||||
const myProfilePage = new MyProfilePage(page);
|
||||
|
||||
await publicTest.step('login as Admin', async () => {
|
||||
await loginPage.login();
|
||||
await expect(loginPage.page).toHaveURL('/flows');
|
||||
});
|
||||
|
||||
await publicTest.step('create new user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
});
|
||||
|
||||
await publicTest.step('copy invitation link', async () => {
|
||||
const invitationMessage =
|
||||
await adminCreateUserPage.acceptInvitationLink;
|
||||
acceptInvitationLink = await invitationMessage.getAttribute('href');
|
||||
});
|
||||
|
||||
await publicTest.step('logout', async () => {
|
||||
await myProfilePage.logout();
|
||||
});
|
||||
|
||||
await publicTest.step('accept invitation', async () => {
|
||||
await page.goto(acceptInvitationLink);
|
||||
await acceptInvitationPage.acceptInvitation(process.env.LOGIN_PASSWORD);
|
||||
});
|
||||
|
||||
await publicTest.step('login as new Admin', async () => {
|
||||
await loginPage.login(testUser.email, process.env.LOGIN_PASSWORD);
|
||||
await expect(loginPage.loginButton).not.toBeVisible();
|
||||
await expect(page).toHaveURL('/flows');
|
||||
});
|
||||
|
||||
await publicTest.step('change own data', async () => {
|
||||
await myProfilePage.navigateTo();
|
||||
|
||||
await myProfilePage.fullName.fill('abecadło');
|
||||
await myProfilePage.email.fill('a' + testUser.email);
|
||||
await myProfilePage.newPassword.fill(
|
||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
||||
);
|
||||
await myProfilePage.passwordConfirmation.fill(
|
||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
||||
);
|
||||
await myProfilePage.updateProfileButton.click();
|
||||
});
|
||||
|
||||
await publicTest.step('logout', async () => {
|
||||
await myProfilePage.logout();
|
||||
});
|
||||
|
||||
await publicTest.step('login with new credentials', async () => {
|
||||
await loginPage.login(
|
||||
'a' + testUser.email,
|
||||
process.env.LOGIN_PASSWORD + process.env.LOGIN_PASSWORD
|
||||
);
|
||||
await expect(loginPage.loginButton).not.toBeVisible();
|
||||
await expect(page).toHaveURL('/flows');
|
||||
});
|
||||
|
||||
await publicTest.step('verify changed data', async () => {
|
||||
await myProfilePage.navigateTo();
|
||||
await expect(myProfilePage.fullName).toHaveValue('abecadło');
|
||||
await expect(myProfilePage.email).toHaveValue('a' + testUser.email);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
@@ -160,6 +160,7 @@ function ProfileSettings() {
|
||||
variant="contained"
|
||||
type="submit"
|
||||
disabled={!isDirty || !isValid || isSubmitting}
|
||||
data-test="update-profile-button"
|
||||
>
|
||||
{formatMessage('profileSettings.updateProfile')}
|
||||
</Button>
|
||||
|
Reference in New Issue
Block a user