test: check for field error instead of snackbar when editing user fails
This commit is contained in:
committed by
kasia.oczkowska
parent
d898b2ab1a
commit
71e8928812
@@ -14,8 +14,12 @@ export class AdminCreateUserPage extends AuthenticatedPage {
|
|||||||
this.roleInput = page.getByTestId('role.id-autocomplete');
|
this.roleInput = page.getByTestId('role.id-autocomplete');
|
||||||
this.createButton = page.getByTestId('create-button');
|
this.createButton = page.getByTestId('create-button');
|
||||||
this.pageTitle = page.getByTestId('create-user-title');
|
this.pageTitle = page.getByTestId('create-user-title');
|
||||||
this.invitationEmailInfoAlert = page.getByTestId('invitation-email-info-alert');
|
this.invitationEmailInfoAlert = page.getByTestId(
|
||||||
this.acceptInvitationLink = page.getByTestId('invitation-email-info-alert').getByRole('link');
|
'invitation-email-info-alert'
|
||||||
|
);
|
||||||
|
this.acceptInvitationLink = page
|
||||||
|
.getByTestId('invitation-email-info-alert')
|
||||||
|
.getByRole('link');
|
||||||
}
|
}
|
||||||
|
|
||||||
seed(seed) {
|
seed(seed) {
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ export class AdminEditUserPage extends AuthenticatedPage {
|
|||||||
super(page);
|
super(page);
|
||||||
this.fullNameInput = page.getByTestId('full-name-input');
|
this.fullNameInput = page.getByTestId('full-name-input');
|
||||||
this.emailInput = page.getByTestId('email-input');
|
this.emailInput = page.getByTestId('email-input');
|
||||||
this.roleInput = page.getByTestId('role.id-autocomplete');
|
this.roleInput = page.getByTestId('roleId-autocomplete');
|
||||||
this.updateButton = page.getByTestId('update-button');
|
this.updateButton = page.getByTestId('update-button');
|
||||||
this.pageTitle = page.getByTestId('edit-user-title');
|
this.pageTitle = page.getByTestId('edit-user-title');
|
||||||
|
this.fieldError = page.locator('p[id$="-helper-text"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,281 +5,243 @@ const { test, expect } = require('../../fixtures/index');
|
|||||||
* otherwise tests will fail since users are only *soft*-deleted
|
* otherwise tests will fail since users are only *soft*-deleted
|
||||||
*/
|
*/
|
||||||
test.describe('User management page', () => {
|
test.describe('User management page', () => {
|
||||||
|
|
||||||
test.beforeEach(async ({ adminUsersPage }) => {
|
test.beforeEach(async ({ adminUsersPage }) => {
|
||||||
await adminUsersPage.navigateTo();
|
await adminUsersPage.navigateTo();
|
||||||
await adminUsersPage.closeSnackbar();
|
await adminUsersPage.closeSnackbar();
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test('User creation and deletion process', async ({
|
||||||
'User creation and deletion process',
|
adminCreateUserPage,
|
||||||
async ({ adminCreateUserPage, adminEditUserPage, adminUsersPage }) => {
|
adminEditUserPage,
|
||||||
adminCreateUserPage.seed(9000);
|
adminUsersPage,
|
||||||
const user = adminCreateUserPage.generateUser();
|
}) => {
|
||||||
await adminUsersPage.usersLoader.waitFor({
|
adminCreateUserPage.seed(9000);
|
||||||
state: 'detached' /* Note: state: 'visible' introduces flakiness
|
const user = adminCreateUserPage.generateUser();
|
||||||
|
await adminUsersPage.usersLoader.waitFor({
|
||||||
|
state: 'detached' /* Note: state: 'visible' introduces flakiness
|
||||||
because visibility: hidden is used as part of the state transition in
|
because visibility: hidden is used as part of the state transition in
|
||||||
notistack, see
|
notistack, see
|
||||||
https://github.com/iamhosseindhv/notistack/blob/122f47057eb7ce5a1abfe923316cf8475303e99a/src/transitions/Collapse/Collapse.tsx#L110
|
https://github.com/iamhosseindhv/notistack/blob/122f47057eb7ce5a1abfe923316cf8475303e99a/src/transitions/Collapse/Collapse.tsx#L110
|
||||||
*/
|
*/,
|
||||||
|
});
|
||||||
|
await test.step('Create a user', async () => {
|
||||||
|
await adminUsersPage.createUserButton.click();
|
||||||
|
await adminCreateUserPage.fullNameInput.fill(user.fullName);
|
||||||
|
await adminCreateUserPage.emailInput.fill(user.email);
|
||||||
|
await adminCreateUserPage.roleInput.click();
|
||||||
|
await adminCreateUserPage.page
|
||||||
|
.getByRole('option', { name: 'Admin' })
|
||||||
|
.click();
|
||||||
|
await adminCreateUserPage.createButton.click();
|
||||||
|
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||||
|
state: 'attached',
|
||||||
});
|
});
|
||||||
await test.step(
|
|
||||||
'Create a user',
|
|
||||||
async () => {
|
|
||||||
await adminUsersPage.createUserButton.click();
|
|
||||||
await adminCreateUserPage.fullNameInput.fill(user.fullName);
|
|
||||||
await adminCreateUserPage.emailInput.fill(user.email);
|
|
||||||
await adminCreateUserPage.roleInput.click();
|
|
||||||
await adminCreateUserPage.page.getByRole(
|
|
||||||
'option', { name: 'Admin' }
|
|
||||||
).click();
|
|
||||||
await adminCreateUserPage.createButton.click();
|
|
||||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
|
||||||
state: 'attached'
|
|
||||||
});
|
|
||||||
|
|
||||||
const snackbar = await adminUsersPage.getSnackbarData(
|
const snackbar = await adminUsersPage.getSnackbarData(
|
||||||
'snackbar-create-user-success'
|
'snackbar-create-user-success'
|
||||||
);
|
|
||||||
await expect(snackbar.variant).toBe('success');
|
|
||||||
await adminUsersPage.navigateTo();
|
|
||||||
await adminUsersPage.closeSnackbar();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
await test.step(
|
await expect(snackbar.variant).toBe('success');
|
||||||
'Check the user exists with the expected properties',
|
await adminUsersPage.navigateTo();
|
||||||
async () => {
|
await adminUsersPage.closeSnackbar();
|
||||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
});
|
||||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
await test.step('Check the user exists with the expected properties', async () => {
|
||||||
const data = await adminUsersPage.getRowData(userRow);
|
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||||
await expect(data.email).toBe(user.email);
|
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||||
await expect(data.fullName).toBe(user.fullName);
|
const data = await adminUsersPage.getRowData(userRow);
|
||||||
await expect(data.role).toBe('Admin');
|
await expect(data.email).toBe(user.email);
|
||||||
}
|
await expect(data.fullName).toBe(user.fullName);
|
||||||
|
await expect(data.role).toBe('Admin');
|
||||||
|
});
|
||||||
|
await test.step('Edit user info and make sure the edit works correctly', async () => {
|
||||||
|
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||||
|
|
||||||
|
let userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||||
|
await adminUsersPage.clickEditUser(userRow);
|
||||||
|
await adminEditUserPage.waitForLoad(user.fullName);
|
||||||
|
const newUserInfo = adminEditUserPage.generateUser();
|
||||||
|
await adminEditUserPage.fullNameInput.fill(newUserInfo.fullName);
|
||||||
|
await adminEditUserPage.updateButton.click();
|
||||||
|
|
||||||
|
const snackbar = await adminUsersPage.getSnackbarData(
|
||||||
|
'snackbar-edit-user-success'
|
||||||
);
|
);
|
||||||
await test.step(
|
await expect(snackbar.variant).toBe('success');
|
||||||
'Edit user info and make sure the edit works correctly',
|
await adminUsersPage.closeSnackbar();
|
||||||
async () => {
|
|
||||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
|
||||||
|
|
||||||
let userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||||
await adminUsersPage.clickEditUser(userRow);
|
userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||||
await adminEditUserPage.waitForLoad(user.fullName);
|
const rowData = await adminUsersPage.getRowData(userRow);
|
||||||
const newUserInfo = adminEditUserPage.generateUser();
|
await expect(rowData.fullName).toBe(newUserInfo.fullName);
|
||||||
await adminEditUserPage.fullNameInput.fill(newUserInfo.fullName);
|
});
|
||||||
await adminEditUserPage.updateButton.click();
|
await test.step('Delete user and check the page confirms this deletion', async () => {
|
||||||
|
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||||
|
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||||
|
await adminUsersPage.clickDeleteUser(userRow);
|
||||||
|
const modal = adminUsersPage.deleteUserModal;
|
||||||
|
await modal.deleteButton.click();
|
||||||
|
|
||||||
const snackbar = await adminUsersPage.getSnackbarData(
|
const snackbar = await adminUsersPage.getSnackbarData(
|
||||||
'snackbar-edit-user-success'
|
'snackbar-delete-user-success'
|
||||||
);
|
|
||||||
await expect(snackbar.variant).toBe('success');
|
|
||||||
await adminUsersPage.closeSnackbar();
|
|
||||||
|
|
||||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
|
||||||
userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
|
||||||
const rowData = await adminUsersPage.getRowData(userRow);
|
|
||||||
await expect(rowData.fullName).toBe(newUserInfo.fullName);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
await test.step(
|
await expect(snackbar.variant).toBe('success');
|
||||||
'Delete user and check the page confirms this deletion',
|
await adminUsersPage.closeSnackbar();
|
||||||
async () => {
|
await expect(userRow).not.toBeVisible(false);
|
||||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
});
|
||||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
});
|
||||||
await adminUsersPage.clickDeleteUser(userRow);
|
|
||||||
const modal = adminUsersPage.deleteUserModal;
|
|
||||||
await modal.deleteButton.click();
|
|
||||||
|
|
||||||
const snackbar = await adminUsersPage.getSnackbarData(
|
test('Creating a user which has been deleted', async ({
|
||||||
'snackbar-delete-user-success'
|
adminCreateUserPage,
|
||||||
);
|
adminUsersPage,
|
||||||
await expect(snackbar.variant).toBe('success');
|
}) => {
|
||||||
await adminUsersPage.closeSnackbar();
|
adminCreateUserPage.seed(9100);
|
||||||
await expect(userRow).not.toBeVisible(false);
|
const testUser = adminCreateUserPage.generateUser();
|
||||||
}
|
|
||||||
|
await test.step('Create the test 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 adminUsersPage.closeSnackbar();
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
await test.step('Delete the created user', async () => {
|
||||||
'Creating a user which has been deleted',
|
await adminUsersPage.navigateTo();
|
||||||
async ({ adminCreateUserPage, adminUsersPage }) => {
|
await adminUsersPage.findUserPageWithEmail(testUser.email);
|
||||||
adminCreateUserPage.seed(9100);
|
const userRow = await adminUsersPage.getUserRowByEmail(testUser.email);
|
||||||
const testUser = adminCreateUserPage.generateUser();
|
await adminUsersPage.clickDeleteUser(userRow);
|
||||||
|
const modal = adminUsersPage.deleteUserModal;
|
||||||
await test.step(
|
await modal.deleteButton.click();
|
||||||
'Create the test user',
|
const snackbar = await adminUsersPage.getSnackbarData(
|
||||||
async () => {
|
'snackbar-delete-user-success'
|
||||||
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 adminUsersPage.closeSnackbar();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
await expect(snackbar).not.toBeNull();
|
||||||
|
await expect(snackbar.variant).toBe('success');
|
||||||
|
await adminUsersPage.closeSnackbar();
|
||||||
|
await expect(userRow).not.toBeVisible(false);
|
||||||
|
});
|
||||||
|
|
||||||
await test.step(
|
await test.step('Create the user again', async () => {
|
||||||
'Delete the created user',
|
await adminUsersPage.createUserButton.click();
|
||||||
async () => {
|
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||||
await adminUsersPage.navigateTo();
|
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||||
await adminUsersPage.findUserPageWithEmail(testUser.email);
|
await adminCreateUserPage.roleInput.click();
|
||||||
const userRow = await adminUsersPage.getUserRowByEmail(testUser.email);
|
await adminCreateUserPage.page
|
||||||
await adminUsersPage.clickDeleteUser(userRow);
|
.getByRole('option', { name: 'Admin' })
|
||||||
const modal = adminUsersPage.deleteUserModal;
|
.click();
|
||||||
await modal.deleteButton.click();
|
await adminCreateUserPage.createButton.click();
|
||||||
const snackbar = await adminUsersPage.getSnackbarData(
|
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
||||||
'snackbar-delete-user-success'
|
await expect(snackbar.variant).toBe('error');
|
||||||
);
|
await adminUsersPage.closeSnackbar();
|
||||||
await expect(snackbar).not.toBeNull();
|
});
|
||||||
await expect(snackbar.variant).toBe('success');
|
});
|
||||||
await adminUsersPage.closeSnackbar();
|
|
||||||
await expect(userRow).not.toBeVisible(false);
|
test('Creating a user which already exists', async ({
|
||||||
}
|
adminCreateUserPage,
|
||||||
|
adminUsersPage,
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
adminCreateUserPage.seed(9200);
|
||||||
|
const testUser = adminCreateUserPage.generateUser();
|
||||||
|
|
||||||
|
await test.step('Create the test user', async () => {
|
||||||
|
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 adminUsersPage.closeSnackbar();
|
||||||
|
});
|
||||||
|
|
||||||
await test.step(
|
await test.step('Create the user again', async () => {
|
||||||
'Create the user again',
|
await adminUsersPage.navigateTo();
|
||||||
async () => {
|
await adminUsersPage.createUserButton.click();
|
||||||
await adminUsersPage.createUserButton.click();
|
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
const createUserPageUrl = page.url();
|
||||||
await adminCreateUserPage.roleInput.click();
|
await adminCreateUserPage.roleInput.click();
|
||||||
await adminCreateUserPage.page.getByRole(
|
await adminCreateUserPage.page
|
||||||
'option', { name: 'Admin' }
|
.getByRole('option', { name: 'Admin' })
|
||||||
).click();
|
.click();
|
||||||
await adminCreateUserPage.createButton.click();
|
await adminCreateUserPage.createButton.click();
|
||||||
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
|
||||||
await expect(snackbar.variant).toBe('error');
|
await expect(page.url()).toBe(createUserPageUrl);
|
||||||
await adminUsersPage.closeSnackbar();
|
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
||||||
}
|
await expect(snackbar.variant).toBe('error');
|
||||||
|
await adminUsersPage.closeSnackbar();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Editing a user to have the same email as another user should not be allowed', async ({
|
||||||
|
adminCreateUserPage,
|
||||||
|
adminEditUserPage,
|
||||||
|
adminUsersPage,
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
adminCreateUserPage.seed(9300);
|
||||||
|
const user1 = adminCreateUserPage.generateUser();
|
||||||
|
const user2 = adminCreateUserPage.generateUser();
|
||||||
|
await test.step('Create the first user', async () => {
|
||||||
|
await adminUsersPage.navigateTo();
|
||||||
|
await adminUsersPage.createUserButton.click();
|
||||||
|
await adminCreateUserPage.fullNameInput.fill(user1.fullName);
|
||||||
|
await adminCreateUserPage.emailInput.fill(user1.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 adminUsersPage.closeSnackbar();
|
||||||
|
});
|
||||||
|
|
||||||
test(
|
await test.step('Create the second user', async () => {
|
||||||
'Creating a user which already exists',
|
await adminUsersPage.navigateTo();
|
||||||
async ({ adminCreateUserPage, adminUsersPage, page }) => {
|
await adminUsersPage.createUserButton.click();
|
||||||
adminCreateUserPage.seed(9200);
|
await adminCreateUserPage.fullNameInput.fill(user2.fullName);
|
||||||
const testUser = adminCreateUserPage.generateUser();
|
await adminCreateUserPage.emailInput.fill(user2.email);
|
||||||
|
await adminCreateUserPage.roleInput.click();
|
||||||
await test.step(
|
await adminCreateUserPage.page
|
||||||
'Create the test user',
|
.getByRole('option', { name: 'Admin' })
|
||||||
async () => {
|
.click();
|
||||||
await adminUsersPage.createUserButton.click();
|
await adminCreateUserPage.createButton.click();
|
||||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
const snackbar = await adminUsersPage.getSnackbarData(
|
||||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
'snackbar-create-user-success'
|
||||||
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 adminUsersPage.closeSnackbar();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
await expect(snackbar.variant).toBe('success');
|
||||||
|
await adminUsersPage.closeSnackbar();
|
||||||
|
});
|
||||||
|
|
||||||
await test.step(
|
await test.step('Try editing the second user to have the email of the first user', async () => {
|
||||||
'Create the user again',
|
await adminUsersPage.navigateTo();
|
||||||
async () => {
|
await adminUsersPage.findUserPageWithEmail(user2.email);
|
||||||
await adminUsersPage.navigateTo();
|
let userRow = await adminUsersPage.getUserRowByEmail(user2.email);
|
||||||
await adminUsersPage.createUserButton.click();
|
await adminUsersPage.clickEditUser(userRow);
|
||||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
await adminEditUserPage.waitForLoad(user2.fullName);
|
||||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
await adminEditUserPage.emailInput.fill(user1.email);
|
||||||
const createUserPageUrl = page.url();
|
const editPageUrl = page.url();
|
||||||
await adminCreateUserPage.roleInput.click();
|
await adminEditUserPage.updateButton.click();
|
||||||
await adminCreateUserPage.page.getByRole(
|
|
||||||
'option', { name: 'Admin' }
|
|
||||||
).click();
|
|
||||||
await adminCreateUserPage.createButton.click();
|
|
||||||
|
|
||||||
await expect(page.url()).toBe(createUserPageUrl);
|
await expect(adminEditUserPage.fieldError).toHaveCount(1);
|
||||||
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
await expect(page.url()).toBe(editPageUrl);
|
||||||
await expect(snackbar.variant).toBe('error');
|
});
|
||||||
await adminUsersPage.closeSnackbar();
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'Editing a user to have the same email as another user should not be allowed',
|
|
||||||
async ({
|
|
||||||
adminCreateUserPage, adminEditUserPage, adminUsersPage, page
|
|
||||||
}) => {
|
|
||||||
adminCreateUserPage.seed(9300);
|
|
||||||
const user1 = adminCreateUserPage.generateUser();
|
|
||||||
const user2 = adminCreateUserPage.generateUser();
|
|
||||||
await test.step(
|
|
||||||
'Create the first user',
|
|
||||||
async () => {
|
|
||||||
await adminUsersPage.navigateTo();
|
|
||||||
await adminUsersPage.createUserButton.click();
|
|
||||||
await adminCreateUserPage.fullNameInput.fill(user1.fullName);
|
|
||||||
await adminCreateUserPage.emailInput.fill(user1.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 adminUsersPage.closeSnackbar();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await test.step(
|
|
||||||
'Create the second user',
|
|
||||||
async () => {
|
|
||||||
await adminUsersPage.navigateTo();
|
|
||||||
await adminUsersPage.createUserButton.click();
|
|
||||||
await adminCreateUserPage.fullNameInput.fill(user2.fullName);
|
|
||||||
await adminCreateUserPage.emailInput.fill(user2.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 adminUsersPage.closeSnackbar();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await test.step(
|
|
||||||
'Try editing the second user to have the email of the first user',
|
|
||||||
async () => {
|
|
||||||
await adminUsersPage.navigateTo();
|
|
||||||
await adminUsersPage.findUserPageWithEmail(user2.email);
|
|
||||||
let userRow = await adminUsersPage.getUserRowByEmail(user2.email);
|
|
||||||
await adminUsersPage.clickEditUser(userRow);
|
|
||||||
await adminEditUserPage.waitForLoad(user2.fullName);
|
|
||||||
await adminEditUserPage.emailInput.fill(user1.email);
|
|
||||||
const editPageUrl = page.url();
|
|
||||||
await adminEditUserPage.updateButton.click();
|
|
||||||
|
|
||||||
const snackbar = await adminUsersPage.getSnackbarData(
|
|
||||||
'snackbar-error'
|
|
||||||
);
|
|
||||||
await expect(snackbar.variant).toBe('error');
|
|
||||||
await adminUsersPage.closeSnackbar();
|
|
||||||
await expect(page.url()).toBe(editPageUrl);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user