2022-12-15 07:39:59 -08:00
|
|
|
import { BasePage } from '../base';
|
2023-12-08 03:52:25 -08:00
|
|
|
import { getVisibleSelect } from '../../utils';
|
2022-11-22 01:37:26 -08:00
|
|
|
|
|
|
|
export class CredentialsModal extends BasePage {
|
|
|
|
getters = {
|
|
|
|
newCredentialModal: () => cy.getByTestId('selectCredential-modal', { timeout: 5000 }),
|
2022-11-28 02:11:39 -08:00
|
|
|
editCredentialModal: () => cy.getByTestId('editCredential-modal', { timeout: 5000 }),
|
2022-11-22 01:37:26 -08:00
|
|
|
newCredentialTypeSelect: () => cy.getByTestId('new-credential-type-select'),
|
2022-12-15 07:39:59 -08:00
|
|
|
newCredentialTypeOption: (credentialType: string) =>
|
|
|
|
cy.getByTestId('new-credential-type-select-option').contains(credentialType),
|
2022-11-22 01:37:26 -08:00
|
|
|
newCredentialTypeButton: () => cy.getByTestId('new-credential-type-button'),
|
|
|
|
connectionParameters: () => cy.getByTestId('credential-connection-parameter'),
|
2022-12-15 07:39:59 -08:00
|
|
|
connectionParameter: (fieldName: string) =>
|
2023-04-28 03:02:28 -07:00
|
|
|
this.getters.connectionParameters().find(`:contains('${fieldName}') .n8n-input input`),
|
2022-11-22 01:37:26 -08:00
|
|
|
name: () => cy.getByTestId('credential-name'),
|
|
|
|
nameInput: () => cy.getByTestId('credential-name').find('input'),
|
2022-12-07 09:16:38 -08:00
|
|
|
// Saving of the credentials takes a while on the CI so we need to increase the timeout
|
|
|
|
saveButton: () => cy.getByTestId('credential-save-button', { timeout: 5000 }),
|
2023-01-27 00:05:43 -08:00
|
|
|
deleteButton: () => cy.getByTestId('credential-delete-button'),
|
2022-11-28 02:11:39 -08:00
|
|
|
closeButton: () => this.getters.editCredentialModal().find('.el-dialog__close').first(),
|
2023-01-27 00:05:43 -08:00
|
|
|
credentialsEditModal: () => cy.getByTestId('credential-edit-dialog'),
|
|
|
|
credentialsAuthTypeSelector: () => cy.getByTestId('node-auth-type-selector'),
|
2023-01-27 01:18:15 -08:00
|
|
|
credentialAuthTypeRadioButtons: () =>
|
2023-07-28 00:51:07 -07:00
|
|
|
this.getters.credentialsAuthTypeSelector().find('label.el-radio'),
|
2023-01-27 00:05:43 -08:00
|
|
|
credentialInputs: () => cy.getByTestId('credential-connection-parameter'),
|
2023-02-14 06:13:00 -08:00
|
|
|
menu: () => this.getters.editCredentialModal().get('.menu-container'),
|
|
|
|
menuItem: (name: string) => this.getters.menu().get('.n8n-menu-item').contains(name),
|
|
|
|
usersSelect: () => cy.getByTestId('credential-sharing-modal-users-select'),
|
2023-04-28 03:02:28 -07:00
|
|
|
testSuccessTag: () => cy.getByTestId('credentials-config-container-test-success'),
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
actions = {
|
2023-02-14 06:13:00 -08:00
|
|
|
addUser: (email: string) => {
|
|
|
|
this.getters.usersSelect().click();
|
2023-12-08 03:52:25 -08:00
|
|
|
getVisibleSelect().contains(email.toLowerCase()).click();
|
2023-02-14 06:13:00 -08:00
|
|
|
},
|
2022-11-22 01:37:26 -08:00
|
|
|
setName: (name: string) => {
|
|
|
|
this.getters.name().click();
|
|
|
|
this.getters.nameInput().clear().type(name);
|
|
|
|
},
|
2022-12-07 09:16:38 -08:00
|
|
|
save: (test = false) => {
|
2022-12-01 01:01:03 -08:00
|
|
|
cy.intercept('POST', '/rest/credentials').as('saveCredential');
|
2023-07-28 00:51:07 -07:00
|
|
|
this.getters.saveButton().click({ force: true });
|
2022-12-07 09:16:38 -08:00
|
|
|
|
|
|
|
cy.wait('@saveCredential');
|
2022-12-15 07:39:59 -08:00
|
|
|
if (test) cy.wait('@testCredential');
|
2022-11-28 02:11:39 -08:00
|
|
|
this.getters.saveButton().should('contain.text', 'Saved');
|
2022-11-24 14:22:09 -08:00
|
|
|
},
|
2023-12-08 03:52:25 -08:00
|
|
|
saveSharing: (test = false) => {
|
|
|
|
cy.intercept('PUT', '/rest/credentials/*/share').as('shareCredential');
|
|
|
|
this.getters.saveButton().click({ force: true });
|
|
|
|
cy.wait('@shareCredential');
|
|
|
|
this.getters.saveButton().should('contain.text', 'Saved');
|
|
|
|
},
|
2022-11-24 14:22:09 -08:00
|
|
|
close: () => {
|
|
|
|
this.getters.closeButton().click();
|
|
|
|
},
|
2023-01-27 00:05:43 -08:00
|
|
|
fillCredentialsForm: () => {
|
|
|
|
this.getters.credentialsEditModal().should('be.visible');
|
|
|
|
this.getters.credentialInputs().should('have.length.greaterThan', 0);
|
2023-01-27 01:18:15 -08:00
|
|
|
this.getters
|
|
|
|
.credentialInputs()
|
|
|
|
.find('input[type=text], input[type=password]')
|
|
|
|
.each(($el) => {
|
|
|
|
cy.wrap($el).type('test');
|
|
|
|
});
|
2023-01-27 00:05:43 -08:00
|
|
|
this.getters.saveButton().click();
|
|
|
|
this.getters.closeButton().click();
|
|
|
|
},
|
|
|
|
renameCredential: (newName: string) => {
|
|
|
|
this.getters.nameInput().type('{selectall}');
|
|
|
|
this.getters.nameInput().type(newName);
|
|
|
|
this.getters.nameInput().type('{enter}');
|
2023-01-27 01:18:15 -08:00
|
|
|
},
|
2023-02-14 06:13:00 -08:00
|
|
|
changeTab: (tabName: string) => {
|
|
|
|
this.getters.menuItem(tabName).click();
|
|
|
|
},
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
}
|