2023-02-09 07:00:55 -08:00
|
|
|
import { MainSidebar } from './../pages/sidebar/main-sidebar';
|
|
|
|
import { DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD } from '../constants';
|
|
|
|
import { SettingsSidebar, SettingsUsersPage, WorkflowPage, WorkflowsPage } 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
const instanceOwner = {
|
|
|
|
email: `${DEFAULT_USER_EMAIL}A`,
|
|
|
|
password: DEFAULT_USER_PASSWORD,
|
|
|
|
firstName: 'User',
|
|
|
|
lastName: 'A',
|
|
|
|
};
|
|
|
|
|
|
|
|
const users = [
|
|
|
|
{
|
|
|
|
email: `${DEFAULT_USER_EMAIL}B`,
|
|
|
|
password: DEFAULT_USER_PASSWORD,
|
|
|
|
firstName: 'User',
|
|
|
|
lastName: 'B',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: `${DEFAULT_USER_EMAIL}C`,
|
|
|
|
password: DEFAULT_USER_PASSWORD,
|
|
|
|
firstName: 'User',
|
|
|
|
lastName: 'C',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
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-02-09 07:00:55 -08:00
|
|
|
|
|
|
|
describe('User Management', () => {
|
|
|
|
before(() => {
|
|
|
|
cy.resetAll();
|
|
|
|
cy.setupOwner(instanceOwner);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.on('uncaught:exception', (err, runnable) => {
|
|
|
|
expect(err.message).to.include('Not logged in');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should invite User B and User C to instance`, () => {
|
|
|
|
cy.inviteUsers({ instanceOwner, users });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should prevent non-owners to access UM settings', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
usersSettingsPage.actions.loginAndVisit(users[0].email, users[0].password, false);
|
2023-02-09 07:00:55 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow instance owner to access UM settings', () => {
|
|
|
|
usersSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should properly render UM settings page for instance owners', () => {
|
|
|
|
usersSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password, true);
|
|
|
|
// 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
|
|
|
|
.userItem(instanceOwner.email)
|
|
|
|
.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
|
|
|
|
usersSettingsPage.getters.userActionsToggle(users[0].email).should('exist');
|
|
|
|
usersSettingsPage.getters.userActionsToggle(users[1].email).should('exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete user and their data', () => {
|
|
|
|
usersSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(users[0].email);
|
|
|
|
usersSettingsPage.getters.deleteDataRadioButton().realClick();
|
|
|
|
usersSettingsPage.getters.deleteDataInput().type('delete all data');
|
|
|
|
usersSettingsPage.getters.deleteUserButton().realClick();
|
|
|
|
workflowPage.getters.successToast().should('contain', 'User deleted');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete user and transfer their data', () => {
|
|
|
|
usersSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password, true);
|
|
|
|
usersSettingsPage.actions.opedDeleteDialog(users[1].email);
|
|
|
|
usersSettingsPage.getters.transferDataRadioButton().realClick();
|
|
|
|
usersSettingsPage.getters.userSelectDropDown().realClick();
|
|
|
|
usersSettingsPage.getters.userSelectOptions().first().realClick();
|
|
|
|
usersSettingsPage.getters.deleteUserButton().realClick();
|
|
|
|
workflowPage.getters.successToast().should('contain', 'User deleted');
|
|
|
|
});
|
2023-02-10 04:12:06 -08:00
|
|
|
|
|
|
|
it(`should allow user to change their personal data`, () => {
|
|
|
|
personalSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.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`, () => {
|
|
|
|
personalSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password);
|
|
|
|
for (let weakPass of updatedPersonalData.invalidPasswords) {
|
|
|
|
personalSettingsPage.actions.tryToSetWeakPassword(instanceOwner.password, weakPass);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`shouldn't allow user to change password if old password is wrong`, () => {
|
|
|
|
personalSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password);
|
|
|
|
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`, () => {
|
|
|
|
personalSettingsPage.actions.loginAndVisit(instanceOwner.email, instanceOwner.password);
|
2023-02-24 09:07:35 -08:00
|
|
|
personalSettingsPage.actions.updatePassword(
|
|
|
|
instanceOwner.password,
|
|
|
|
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(
|
|
|
|
instanceOwner.email,
|
|
|
|
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(
|
|
|
|
instanceOwner.email,
|
|
|
|
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(
|
|
|
|
instanceOwner.email,
|
|
|
|
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
|
|
|
});
|