2023-06-22 15:38:12 -07:00
|
|
|
import { INSTANCE_MEMBERS, INSTANCE_OWNER } 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-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 }, () => {
|
|
|
|
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
|
|
|
|
usersSettingsPage.getters.userListItems().should('have.length', 3);
|
|
|
|
// 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-02-09 07:00:55 -08:00
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
mainSidebar.getters.logo().should('have.attr', 'src', '/n8n-dev-logo-dark-mode.svg');
|
|
|
|
|
|
|
|
cy.visit(personalSettingsPage.url);
|
|
|
|
personalSettingsPage.actions.changeTheme('Light');
|
|
|
|
cy.get('body').should('have.attr', 'data-theme', 'light');
|
|
|
|
settingsSidebar.actions.back();
|
|
|
|
mainSidebar.getters.logo().should('have.attr', 'src', '/n8n-dev-logo.svg');
|
|
|
|
});
|
|
|
|
|
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
|
|
|
});
|