2022-11-22 01:37:26 -08:00
|
|
|
import { BasePage } from "../base";
|
|
|
|
|
|
|
|
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'),
|
|
|
|
newCredentialTypeOption: (credentialType: string) => cy.getByTestId('new-credential-type-select-option').contains(credentialType),
|
|
|
|
newCredentialTypeButton: () => cy.getByTestId('new-credential-type-button'),
|
|
|
|
connectionParameters: () => cy.getByTestId('credential-connection-parameter'),
|
|
|
|
connectionParameter: (fieldName: string) => this.getters.connectionParameters().contains(fieldName)
|
|
|
|
.parents('[data-test-id="credential-connection-parameter"]')
|
|
|
|
.find('.n8n-input input'),
|
|
|
|
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 }),
|
2022-11-28 02:11:39 -08:00
|
|
|
closeButton: () => this.getters.editCredentialModal().find('.el-dialog__close').first(),
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
actions = {
|
|
|
|
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');
|
2022-12-07 09:16:38 -08:00
|
|
|
if(test) {
|
|
|
|
cy.intercept('POST', '/rest/credentials/test').as('testCredential');
|
|
|
|
}
|
2022-12-01 01:01:03 -08:00
|
|
|
|
2022-11-22 01:37:26 -08:00
|
|
|
this.getters.saveButton().click();
|
2022-12-07 09:16:38 -08:00
|
|
|
|
|
|
|
cy.wait('@saveCredential');
|
|
|
|
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
|
|
|
},
|
|
|
|
close: () => {
|
|
|
|
this.getters.closeButton().click();
|
|
|
|
},
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
}
|