2023-12-06 05:31:06 -08:00
|
|
|
import { INSTANCE_MEMBERS, INSTANCE_OWNER, INSTANCE_ADMIN } from '../constants';
|
2023-11-01 05:33:36 -07:00
|
|
|
import { MainSidebar, SettingsSidebar, SettingsUsersPage, WorkflowPage } from '../pages';
|
2023-02-10 04:12:06 -08:00
|
|
|
import { PersonalSettingsPage } from '../pages/settings-personal';
|
2023-12-08 03:52:25 -08:00
|
|
|
import { getVisibleSelect } from '../utils';
|
2023-02-09 07:00:55 -08: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 04:12:06 -08:00
|
|
|
const updatedPersonalData = {
|
|
|
|
newFirstName: 'Something',
|
|
|
|
newLastName: 'Else',
|
|
|
|
newEmail: 'something_else@acme.corp',
|
|
|
|
newPassword: 'Keybo4rd',
|
2023-02-24 09:07:35 -08:00
|
|
|
invalidPasswords: ['abc', 'longEnough', 'longenough123'],
|
|
|
|
};
|
2023-02-10 04:12:06 -08:00
|
|
|
|
2023-02-09 07:00:55 -08:00
|
|
|
const usersSettingsPage = new SettingsUsersPage();
|
|
|
|
const workflowPage = new WorkflowPage();
|
2023-02-10 04:12:06 -08:00
|
|
|
const personalSettingsPage = new PersonalSettingsPage();
|
2023-11-01 05:33:36 -07:00
|
|
|
const settingsSidebar = new SettingsSidebar();
|
|
|
|
const mainSidebar = new MainSidebar();
|
2023-02-09 07:00:55 -08:00
|
|
|
|
2023-06-22 15:38:12 -07:00
|
|
|
describe('User Management', { disableAutoLogin: true }, () => {
|
2023-12-08 03:52:25 -08:00
|
|
|
before(() => {
|
|
|
|
cy.enableFeature('sharing');
|
|
|
|
});
|
2023-02-09 07:00:55 -08:00
|
|
|
|
|
|
|
it('should prevent non-owners to access UM settings', () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.actions.loginAndVisit(
|
|
|
|
INSTANCE_MEMBERS[0].email,
|
|
|
|
INSTANCE_MEMBERS[0].password,
|
|
|
|
false,
|
|
|
|
);
|
2023-02-09 07:00:55 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow instance owner to access UM settings', () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
2023-02-09 07:00:55 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should properly render UM settings page for instance owners', () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
2023-02-09 07:00:55 -08:00
|
|
|
// All items in user list should be there
|
2023-12-06 05:31:06 -08:00
|
|
|
usersSettingsPage.getters.userListItems().should('have.length', 4);
|
2023-02-09 07:00:55 -08:00
|
|
|
// List item for current user should have the `Owner` badge
|
2023-02-24 09:07:35 -08:00
|
|
|
usersSettingsPage.getters
|
2023-06-22 15:38:12 -07:00
|
|
|
.userItem(INSTANCE_OWNER.email)
|
2023-02-24 09:07:35 -08:00
|
|
|
.find('.n8n-badge:contains("Owner")')
|
|
|
|
.should('exist');
|
2023-02-09 07:00:55 -08:00
|
|
|
// Other users list items should contain action pop-up list
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[0].email).should('exist');
|
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[1].email).should('exist');
|
2023-12-06 05:31:06 -08:00
|
|
|
usersSettingsPage.getters.userActionsToggle(INSTANCE_ADMIN.email).should('exist');
|
2023-02-09 07:00:55 -08:00
|
|
|
});
|
|
|
|
|
2023-12-08 03:52:25 -08: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 05:33:36 -07: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 00:35:40 -08:00
|
|
|
mainSidebar.getters
|
|
|
|
.logo()
|
|
|
|
.should('have.attr', 'src')
|
|
|
|
.then((src) => {
|
|
|
|
expect(src).to.include('/n8n-dev-logo-dark-mode.svg');
|
|
|
|
});
|
2023-11-01 05:33:36 -07:00
|
|
|
|
|
|
|
cy.visit(personalSettingsPage.url);
|
|
|
|
personalSettingsPage.actions.changeTheme('Light');
|
|
|
|
cy.get('body').should('have.attr', 'data-theme', 'light');
|
|
|
|
settingsSidebar.actions.back();
|
2023-11-29 00:35:40 -08:00
|
|
|
mainSidebar.getters
|
|
|
|
.logo()
|
|
|
|
.should('have.attr', 'src')
|
|
|
|
.then((src) => {
|
|
|
|
expect(src).to.include('/n8n-dev-logo.svg');
|
|
|
|
});
|
2023-11-01 05:33:36 -07:00
|
|
|
});
|
|
|
|
|
2023-02-09 07:00:55 -08:00
|
|
|
it('should delete user and their data', () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(INSTANCE_MEMBERS[0].email);
|
2023-07-28 00:51:07 -07:00
|
|
|
usersSettingsPage.getters.deleteDataRadioButton().click();
|
2023-02-09 07:00:55 -08:00
|
|
|
usersSettingsPage.getters.deleteDataInput().type('delete all data');
|
2023-07-28 00:51:07 -07:00
|
|
|
usersSettingsPage.getters.deleteUserButton().click();
|
2023-02-09 07:00:55 -08:00
|
|
|
workflowPage.getters.successToast().should('contain', 'User deleted');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete user and transfer their data', () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(INSTANCE_MEMBERS[1].email);
|
2023-07-28 00:51:07 -07:00
|
|
|
usersSettingsPage.getters.transferDataRadioButton().click();
|
|
|
|
usersSettingsPage.getters.userSelectDropDown().click();
|
|
|
|
usersSettingsPage.getters.userSelectOptions().first().click();
|
|
|
|
usersSettingsPage.getters.deleteUserButton().click();
|
2023-02-09 07:00:55 -08:00
|
|
|
workflowPage.getters.successToast().should('contain', 'User deleted');
|
|
|
|
});
|
2023-02-10 04:12:06 -08:00
|
|
|
|
|
|
|
it(`should allow user to change their personal data`, () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.updateFirstAndLastName(
|
|
|
|
updatedPersonalData.newFirstName,
|
|
|
|
updatedPersonalData.newLastName,
|
|
|
|
);
|
|
|
|
personalSettingsPage.getters
|
|
|
|
.currentUserName()
|
|
|
|
.should('contain', `${updatedPersonalData.newFirstName} ${updatedPersonalData.newLastName}`);
|
2023-02-10 04:12:06 -08:00
|
|
|
workflowPage.getters.successToast().should('contain', 'Personal details updated');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`shouldn't allow user to set weak password`, () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 08:57:25 -07:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2023-02-10 04:12:06 -08:00
|
|
|
for (let weakPass of updatedPersonalData.invalidPasswords) {
|
2023-06-22 15:38:12 -07:00
|
|
|
personalSettingsPage.actions.tryToSetWeakPassword(INSTANCE_OWNER.password, weakPass);
|
2023-02-10 04:12:06 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`shouldn't allow user to change password if old password is wrong`, () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 08:57:25 -07:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2023-02-10 04:12:06 -08:00
|
|
|
personalSettingsPage.actions.updatePassword('iCannotRemember', updatedPersonalData.newPassword);
|
2023-02-24 09:07:35 -08:00
|
|
|
workflowPage.getters
|
|
|
|
.errorToast()
|
|
|
|
.closest('div')
|
|
|
|
.should('contain', 'Provided current password is incorrect.');
|
2023-02-10 04:12:06 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should change current user password`, () => {
|
2023-06-22 15:38:12 -07:00
|
|
|
personalSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password);
|
2023-07-28 08:57:25 -07:00
|
|
|
personalSettingsPage.getters.changePasswordLink().click();
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.updatePassword(
|
2023-06-22 15:38:12 -07:00
|
|
|
INSTANCE_OWNER.password,
|
2023-02-24 09:07:35 -08:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 04:12:06 -08:00
|
|
|
workflowPage.getters.successToast().should('contain', 'Password updated');
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.loginWithNewData(
|
2023-06-22 15:38:12 -07:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 09:07:35 -08:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 04:12:06 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`shouldn't allow users to set invalid email`, () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.loginAndVisit(
|
2023-06-22 15:38:12 -07:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 09:07:35 -08:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 04:12:06 -08:00
|
|
|
// try without @ part
|
|
|
|
personalSettingsPage.actions.tryToSetInvalidEmail(updatedPersonalData.newEmail.split('@')[0]);
|
|
|
|
// try without domain
|
|
|
|
personalSettingsPage.actions.tryToSetInvalidEmail(updatedPersonalData.newEmail.split('.')[0]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should change user email`, () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.loginAndVisit(
|
2023-06-22 15:38:12 -07:00
|
|
|
INSTANCE_OWNER.email,
|
2023-02-24 09:07:35 -08:00
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 04:12:06 -08:00
|
|
|
personalSettingsPage.actions.updateEmail(updatedPersonalData.newEmail);
|
|
|
|
workflowPage.getters.successToast().should('contain', 'Personal details updated');
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.loginWithNewData(
|
|
|
|
updatedPersonalData.newEmail,
|
|
|
|
updatedPersonalData.newPassword,
|
|
|
|
);
|
2023-02-10 04:12:06 -08:00
|
|
|
});
|
2023-02-09 07:00:55 -08:00
|
|
|
});
|