2023-12-06 16:31:06 +03:00
|
|
|
import { INSTANCE_MEMBERS, INSTANCE_OWNER, INSTANCE_ADMIN } from '../constants';
|
2024-06-11 11:23:30 +03:00
|
|
|
import { MainSidebar, SettingsSidebar, SettingsUsersPage } from '../pages';
|
2023-02-10 15:12:06 +03:00
|
|
|
import { PersonalSettingsPage } from '../pages/settings-personal';
|
2023-12-08 14:52:25 +03:00
|
|
|
import { getVisibleSelect } from '../utils';
|
2024-06-11 11:23:30 +03:00
|
|
|
import { errorToast, successToast } from '../pages/notifications';
|
2023-02-09 18:00:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* User A - Instance owner
|
|
|
|
* User B - User, owns C1, W1, W2
|
|
|
|
* User C - User, owns C2
|
|
|
|
*
|
|
|
|
* W1 - Workflow owned by User B, shared with User C
|
|
|
|
* W2 - Workflow owned by User B
|
|
|
|
*
|
|
|
|
* C1 - Credential owned by User B
|
|
|
|
* C2 - Credential owned by User C, shared with User A and User B
|
|
|
|
*/
|
|
|
|
|
2023-02-10 15:12:06 +03:00
|
|
|
const updatedPersonalData = {
|
|
|
|
newFirstName: 'Something',
|
|
|
|
newLastName: 'Else',
|
|
|
|
newEmail: 'something_else@acme.corp',
|
|
|
|
newPassword: 'Keybo4rd',
|
2023-02-24 20:07:35 +03:00
|
|
|
invalidPasswords: ['abc', 'longEnough', 'longenough123'],
|
|
|
|
};
|
2023-02-10 15:12:06 +03:00
|
|
|
|
2023-02-09 18:00:55 +03:00
|
|
|
const usersSettingsPage = new SettingsUsersPage();
|
2023-02-10 15:12:06 +03:00
|
|
|
const personalSettingsPage = new PersonalSettingsPage();
|
2023-11-01 15:33:36 +03:00
|
|
|
const settingsSidebar = new SettingsSidebar();
|
|
|
|
const mainSidebar = new MainSidebar();
|
2023-02-09 18:00:55 +03:00
|
|
|
|
2023-06-23 01:38:12 +03:00
|
|
|
describe('User Management', { disableAutoLogin: true }, () => {
|
2023-12-08 14:52:25 +03:00
|
|
|
before(() => {
|
|
|
|
cy.enableFeature('sharing');
|
|
|
|
});
|
2023-02-09 18:00:55 +03:00
|
|
|
|
2024-06-11 15:45:15 +03:00
|
|
|
it('should login and logout', () => {
|
2024-05-23 18:07:40 +03:00
|
|
|
cy.visit('/');
|
|
|
|
cy.get('input[name="email"]').type(INSTANCE_OWNER.email);
|
|
|
|
cy.get('input[name="password"]').type(INSTANCE_OWNER.password);
|
|
|
|
cy.getByTestId('form-submit-button').click();
|
|
|
|
mainSidebar.getters.logo().should('be.visible');
|
|
|
|
mainSidebar.actions.goToSettings();
|
|
|
|
settingsSidebar.getters.users().should('be.visible');
|
|
|
|
|
|
|
|
mainSidebar.actions.closeSettings();
|
|
|
|
mainSidebar.actions.openUserMenu();
|
|
|
|
cy.getByTestId('user-menu-item-logout').click();
|
|
|
|
|
|
|
|
cy.get('input[name="email"]').type(INSTANCE_MEMBERS[0].email);
|
|
|
|
cy.get('input[name="password"]').type(INSTANCE_MEMBERS[0].password);
|
|
|
|
cy.getByTestId('form-submit-button').click();
|
|
|
|
mainSidebar.getters.logo().should('be.visible');
|
|
|
|
mainSidebar.actions.goToSettings();
|
|
|
|
cy.getByTestId('menu-item').filter('#settings-users').should('not.exist');
|
|
|
|
});
|
|
|
|
|
2023-02-09 18:00:55 +03:00
|
|
|
it('should prevent non-owners to access UM settings', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.actions.loginAndVisit(
|
|
|
|
INSTANCE_MEMBERS[0].email,
|
|
|
|
INSTANCE_MEMBERS[0].password,
|
|
|
|
false,
|
|
|
|
);
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow instance owner to access UM settings', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should properly render UM settings page for instance owners', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
2023-02-09 18:00:55 +03:00
|
|
|
// All items in user list should be there
|
2023-12-06 16:31:06 +03:00
|
|
|
usersSettingsPage.getters.userListItems().should('have.length', 4);
|
2023-02-09 18:00:55 +03:00
|
|
|
// List item for current user should have the `Owner` badge
|
2023-02-24 20:07:35 +03:00
|
|
|
usersSettingsPage.getters
|
2023-06-23 01:38:12 +03:00
|
|
|
.userItem(INSTANCE_OWNER.email)
|
2023-02-24 20:07:35 +03:00
|
|
|
.find('.n8n-badge:contains("Owner")')
|
|
|
|
.should('exist');
|
2023-02-09 18:00:55 +03:00
|
|
|
// Other users list items should contain action pop-up list
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[0].email).should('exist');
|
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[1].email).should('exist');
|
2023-12-06 16:31:06 +03:00
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_ADMIN.email).should('exist');
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|
|
|
|
|
2023-12-08 14:52:25 +03:00
|
|
|
it('should be able to change user role to Admin and back', () => {
|
|
|
|
cy.enableFeature('advancedPermissions');
|
|
|
|
|
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
|
|
|
|
|
|
|
// Change role from Member to Admin
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_MEMBERS[0].email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Member');
|
|
|
|
usersSettingsPage.getters.userRoleSelect(INSTANCE_MEMBERS[0].email).click();
|
|
|
|
getVisibleSelect().find('li').contains('Admin').click();
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_MEMBERS[0].email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Admin');
|
|
|
|
|
|
|
|
usersSettingsPage.actions.loginAndVisit(
|
|
|
|
INSTANCE_MEMBERS[0].email,
|
|
|
|
INSTANCE_MEMBERS[0].password,
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Change role from Admin to Member, then back to Admin
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_ADMIN.email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Admin');
|
|
|
|
|
|
|
|
usersSettingsPage.getters.userRoleSelect(INSTANCE_ADMIN.email).click();
|
|
|
|
getVisibleSelect().find('li').contains('Member').click();
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_ADMIN.email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Member');
|
|
|
|
|
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_ADMIN.email, INSTANCE_ADMIN.password, false);
|
|
|
|
usersSettingsPage.actions.loginAndVisit(
|
|
|
|
INSTANCE_MEMBERS[0].email,
|
|
|
|
INSTANCE_MEMBERS[0].password,
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
|
|
|
|
usersSettingsPage.getters.userRoleSelect(INSTANCE_ADMIN.email).click();
|
|
|
|
getVisibleSelect().find('li').contains('Admin').click();
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_ADMIN.email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Admin');
|
|
|
|
|
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_ADMIN.email, INSTANCE_ADMIN.password, true);
|
|
|
|
usersSettingsPage.getters.userRoleSelect(INSTANCE_MEMBERS[0].email).click();
|
|
|
|
getVisibleSelect().find('li').contains('Member').click();
|
|
|
|
usersSettingsPage.getters
|
|
|
|
.userRoleSelect(INSTANCE_MEMBERS[0].email)
|
|
|
|
.find('input')
|
|
|
|
.should('contain.value', 'Member');
|
|
|
|
|
|
|
|
cy.disableFeature('advancedPermissions');
|
|
|
|
});
|
|
|
|
|
2023-11-01 15:33:36 +03:00
|
|
|
it('should be able to change theme', () => {
|
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
|
|
|
|
|
|
|
personalSettingsPage.actions.changeTheme('Dark');
|
|
|
|
cy.get('body').should('have.attr', 'data-theme', 'dark');
|
|
|
|
settingsSidebar.actions.back();
|
2023-11-29 11:35:40 +03:00
|
|
|
mainSidebar.getters
|
|
|
|
.logo()
|
|
|
|
.should('have.attr', 'src')
|
|
|
|
.then((src) => {
|
2024-02-16 12:42:32 +03:00
|
|
|
expect(src).to.include('/static/logo/channel/dev-dark.svg');
|
2023-11-29 11:35:40 +03:00
|
|
|
});
|
2023-11-01 15:33:36 +03:00
|
|
|
|
|
|
|
cy.visit(personalSettingsPage.url);
|
|
|
|
personalSettingsPage.actions.changeTheme('Light');
|
|
|
|
cy.get('body').should('have.attr', 'data-theme', 'light');
|
|
|
|
settingsSidebar.actions.back();
|
2023-11-29 11:35:40 +03:00
|
|
|
mainSidebar.getters
|
|
|
|
.logo()
|
|
|
|
.should('have.attr', 'src')
|
|
|
|
.then((src) => {
|
2024-02-16 12:42:32 +03:00
|
|
|
expect(src).to.include('/static/logo/channel/dev.svg');
|
2023-11-29 11:35:40 +03:00
|
|
|
});
|
2023-11-01 15:33:36 +03:00
|
|
|
});
|
|
|
|
|
2023-02-09 18:00:55 +03:00
|
|
|
it('should delete user and their data', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(INSTANCE_MEMBERS[0].email);
|
2023-07-28 10:51:07 +03:00
|
|
|
usersSettingsPage.getters.deleteDataRadioButton().click();
|
2023-02-09 18:00:55 +03:00
|
|
|
usersSettingsPage.getters.deleteDataInput().type('delete all data');
|
2023-07-28 10:51:07 +03:00
|
|
|
usersSettingsPage.getters.deleteUserButton().click();
|
2024-06-11 11:23:30 +03:00
|
|
|
successToast().should('contain', 'User deleted');
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete user and transfer their data', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(INSTANCE_MEMBERS[1].email);
|
2023-07-28 10:51:07 +03:00
|
|
|
usersSettingsPage.getters.transferDataRadioButton().click();
|
|
|
|
usersSettingsPage.getters.userSelectDropDown().click();
|
|
|
|
usersSettingsPage.getters.userSelectOptions().first().click();
|
|
|
|
usersSettingsPage.getters.deleteUserButton().click();
|
2024-06-11 11:23:30 +03:00
|
|
|
successToast().should('contain', 'User deleted');
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|
2023-02-10 15:12:06 +03:00
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it('should allow user to change their personal data', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.updateFirstAndLastName(
|
|
|
|
updatedPersonalData.newFirstName,
|
|
|
|
updatedPersonalData.newLastName,
|
|
|
|
);
|
|
|
|
personalSettingsPage.getters
|
|
|
|
.currentUserName()
|
|
|
|
.should('contain', `${updatedPersonalData.newFirstName} ${updatedPersonalData.newLastName}`);
|
2024-06-11 11:23:30 +03:00
|
|
|
successToast().should('contain', 'Personal details updated');
|
2023-02-10 15:12:06 +03:00
|
|
|
});
|
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it("shouldn't allow user to set weak password", () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 18:57:25 +03:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2024-06-10 16:49:50 +03:00
|
|
|
for (const weakPass of updatedPersonalData.invalidPasswords) {
|
2023-06-23 01:38:12 +03:00
|
|
|
personalSettingsPage.actions.tryToSetWeakPassword(INSTANCE_OWNER.password, weakPass);
|
2023-02-10 15:12:06 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it("shouldn't allow user to change password if old password is wrong", () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 18:57:25 +03:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2023-02-10 15:12:06 +03:00
|
|
|
personalSettingsPage.actions.updatePassword('iCannotRemember', updatedPersonalData.newPassword);
|
2024-06-11 11:23:30 +03:00
|
|
|
errorToast().closest('div').should('contain', 'Provided current password is incorrect.');
|
2023-02-10 15:12:06 +03:00
|
|
|
});
|
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it('should change current user password', () => {
|
2023-06-23 01:38:12 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 18:57:25 +03:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.updatePassword(
|
2023-06-23 01:38:12 +03:00
|
|
|
INSTANCE_OWNER.password,
|
2023-02-24 20:07:35 +03:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2024-06-11 11:23:30 +03:00
|
|
|
successToast().should('contain', 'Password updated');
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.loginWithNewData(
|
2023-06-23 01:38:12 +03:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 20:07:35 +03:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 15:12:06 +03:00
|
|
|
});
|
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it("shouldn't allow users to set invalid email", () => {
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(
|
2023-06-23 01:38:12 +03:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 20:07:35 +03:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 15:12:06 +03:00
|
|
|
// try without @ part
|
|
|
|
personalSettingsPage.actions.tryToSetInvalidEmail(updatedPersonalData.newEmail.split('@')[0]);
|
|
|
|
// try without domain
|
|
|
|
personalSettingsPage.actions.tryToSetInvalidEmail(updatedPersonalData.newEmail.split('.')[0]);
|
|
|
|
});
|
|
|
|
|
2024-06-10 16:49:50 +03:00
|
|
|
it('should change user email', () => {
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.loginAndVisit(
|
2023-06-23 01:38:12 +03:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 20:07:35 +03:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 15:12:06 +03:00
|
|
|
personalSettingsPage.actions.updateEmail(updatedPersonalData.newEmail);
|
2024-06-11 11:23:30 +03:00
|
|
|
successToast().should('contain', 'Personal details updated');
|
2023-02-24 20:07:35 +03:00
|
|
|
personalSettingsPage.actions.loginWithNewData(
|
|
|
|
updatedPersonalData.newEmail,
|
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 15:12:06 +03:00
|
|
|
});
|
2023-02-09 18:00:55 +03:00
|
|
|
});
|