2023-02-09 07:00:55 -08:00
|
|
|
import { SettingsSidebar } from './sidebar/settings-sidebar';
|
|
|
|
import { MainSidebar } from './sidebar/main-sidebar';
|
2023-03-08 06:11:13 -08:00
|
|
|
import { WorkflowPage } from './workflow';
|
2023-03-09 06:26:27 -08:00
|
|
|
import { WorkflowsPage } from './workflows';
|
2022-12-15 07:39:59 -08:00
|
|
|
import { BasePage } from './base';
|
2022-11-24 14:22:09 -08:00
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
const workflowPage = new WorkflowPage();
|
|
|
|
const workflowsPage = new WorkflowsPage();
|
2023-02-09 07:00:55 -08:00
|
|
|
const mainSidebar = new MainSidebar();
|
|
|
|
const settingsSidebar = new SettingsSidebar();
|
|
|
|
|
2022-11-24 14:22:09 -08:00
|
|
|
export class SettingsUsersPage extends BasePage {
|
|
|
|
url = '/settings/users';
|
|
|
|
getters = {
|
2023-01-09 08:23:39 -08:00
|
|
|
setUpOwnerButton: () => cy.getByTestId('action-box').find('button').first(),
|
2023-02-08 12:41:35 -08:00
|
|
|
inviteButton: () => cy.getByTestId('settings-users-invite-button').last(),
|
|
|
|
inviteUsersModal: () => cy.getByTestId('inviteUser-modal').last(),
|
|
|
|
inviteUsersModalEmailsInput: () => cy.getByTestId('emails').find('input').first(),
|
2023-02-09 07:00:55 -08:00
|
|
|
userListItems: () => cy.get('[data-test-id^="user-list-item"]'),
|
|
|
|
userItem: (email: string) => cy.getByTestId(`user-list-item-${email.toLowerCase()}`),
|
2023-07-28 00:51:07 -07:00
|
|
|
userActionsToggle: (email: string) =>
|
|
|
|
this.getters.userItem(email).find('[data-test-id="action-toggle"]'),
|
|
|
|
deleteUserAction: () =>
|
|
|
|
cy.getByTestId('action-toggle-dropdown').find('li:contains("Delete"):visible'),
|
2023-02-09 07:00:55 -08:00
|
|
|
confirmDeleteModal: () => cy.getByTestId('deleteUser-modal').last(),
|
2023-07-28 00:51:07 -07:00
|
|
|
transferDataRadioButton: () =>
|
|
|
|
this.getters.confirmDeleteModal().find('.el-radio .el-radio__input').first(),
|
|
|
|
deleteDataRadioButton: () =>
|
|
|
|
this.getters.confirmDeleteModal().find('.el-radio .el-radio__input').last(),
|
2023-02-09 07:00:55 -08:00
|
|
|
userSelectDropDown: () => this.getters.confirmDeleteModal().find('.n8n-select'),
|
|
|
|
userSelectOptions: () => cy.get('.el-select-dropdown:visible .el-select-dropdown__item'),
|
|
|
|
deleteUserButton: () => this.getters.confirmDeleteModal().find('button:contains("Delete")'),
|
|
|
|
deleteDataInput: () => cy.getByTestId('delete-data-input').find('input').first(),
|
2022-12-15 07:39:59 -08:00
|
|
|
};
|
2022-11-24 14:22:09 -08:00
|
|
|
actions = {
|
|
|
|
goToOwnerSetup: () => this.getters.setUpOwnerButton().click(),
|
2023-02-09 07:00:55 -08:00
|
|
|
loginAndVisit: (email: string, password: string, isOwner: boolean) => {
|
|
|
|
cy.signin({ email, password });
|
2023-03-08 06:11:13 -08:00
|
|
|
workflowPage.actions.visit();
|
2023-02-09 07:00:55 -08:00
|
|
|
mainSidebar.actions.goToSettings();
|
|
|
|
if (isOwner) {
|
|
|
|
settingsSidebar.getters.menuItem('Users').click();
|
|
|
|
cy.url().should('match', new RegExp(this.url));
|
|
|
|
} else {
|
|
|
|
settingsSidebar.getters.menuItem('Users').should('not.exist');
|
|
|
|
// Should be redirected to workflows page if trying to access UM url
|
|
|
|
cy.visit('/settings/users');
|
2023-03-09 06:26:27 -08:00
|
|
|
cy.url().should('match', new RegExp(workflowsPage.url));
|
2023-02-09 07:00:55 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
opedDeleteDialog: (email: string) => {
|
|
|
|
this.getters.userActionsToggle(email).click();
|
|
|
|
this.getters.deleteUserAction().realClick();
|
|
|
|
this.getters.confirmDeleteModal().should('be.visible');
|
|
|
|
},
|
2022-12-15 07:39:59 -08:00
|
|
|
};
|
2022-11-24 14:22:09 -08:00
|
|
|
}
|