2023-12-08 03:52:25 -08:00
|
|
|
import { getVisibleSelect } from '../../utils';
|
2024-09-18 00:19:33 -07:00
|
|
|
import { BasePage } from '../base';
|
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'),
|
2022-12-15 07:39:59 -08:00
|
|
|
connectionParameter: (fieldName: string) =>
|
2024-06-17 04:41:49 -07:00
|
|
|
this.getters.credentialInputs().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(),
|
2024-06-17 04:41:49 -07:00
|
|
|
oauthConnectButton: () => cy.getByTestId('oauth-connect-button'),
|
|
|
|
oauthConnectSuccessBanner: () => cy.getByTestId('oauth-connect-success-banner'),
|
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),
|
2024-05-17 01:53:15 -07:00
|
|
|
usersSelect: () => cy.getByTestId('project-sharing-select').filter(':visible'),
|
2023-04-28 03:02:28 -07:00
|
|
|
testSuccessTag: () => cy.getByTestId('credentials-config-container-test-success'),
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
2024-06-10 06:49:50 -07:00
|
|
|
|
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
|
|
|
},
|
2024-06-10 06:49:50 -07:00
|
|
|
saveSharing: () => {
|
2023-12-08 03:52:25 -08:00
|
|
|
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();
|
|
|
|
},
|
2024-06-14 05:48:49 -07:00
|
|
|
fillCredentialsForm: (closeModal = true) => {
|
2023-01-27 00:05:43 -08:00
|
|
|
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();
|
2024-06-14 05:48:49 -07:00
|
|
|
if (closeModal) {
|
|
|
|
this.getters.closeButton().click();
|
|
|
|
}
|
|
|
|
},
|
2024-06-17 04:41:49 -07:00
|
|
|
fillField: (fieldName: string, value: string) => {
|
|
|
|
this.getters
|
|
|
|
.credentialInputs()
|
|
|
|
.getByTestId(`parameter-input-${fieldName}`)
|
|
|
|
.find('input')
|
|
|
|
.type(value);
|
|
|
|
},
|
2024-06-14 05:48:49 -07:00
|
|
|
createNewCredential: (type: string, closeModal = true) => {
|
|
|
|
this.getters.newCredentialModal().should('be.visible');
|
|
|
|
this.getters.newCredentialTypeSelect().should('be.visible');
|
|
|
|
this.getters.newCredentialTypeOption(type).click();
|
|
|
|
this.getters.newCredentialTypeButton().click();
|
|
|
|
this.actions.fillCredentialsForm(closeModal);
|
2023-01-27 00:05:43 -08:00
|
|
|
},
|
|
|
|
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
|
|
|
},
|
2024-06-14 05:48:49 -07:00
|
|
|
changeTab: (tabName: 'Sharing') => {
|
2023-02-14 06:13:00 -08:00
|
|
|
this.getters.menuItem(tabName).click();
|
|
|
|
},
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
}
|