Skip to content

Commit

Permalink
fix(editor): Fix issue with existing credential not opening in HTTP a…
Browse files Browse the repository at this point in the history
…gent tool (#10167)
  • Loading branch information
OlegIvaniv authored and elsmr committed Jul 26, 2024
1 parent 950d824 commit 0e448dc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions cypress/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const AI_MEMORY_WINDOW_BUFFER_MEMORY_NODE_NAME = 'Window Buffer Memory';
export const AI_TOOL_CALCULATOR_NODE_NAME = 'Calculator';
export const AI_TOOL_CODE_NODE_NAME = 'Code Tool';
export const AI_TOOL_WIKIPEDIA_NODE_NAME = 'Wikipedia';
export const AI_TOOL_HTTP_NODE_NAME = 'HTTP Request Tool';
export const AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME = 'OpenAI Chat Model';
export const AI_OUTPUT_PARSER_AUTO_FIXING_NODE_NAME = 'Auto-fixing Output Parser';
export const WEBHOOK_NODE_NAME = 'Webhook';
Expand Down
29 changes: 28 additions & 1 deletion cypress/e2e/2-credentials.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { ICredentialType } from 'n8n-workflow';
import { type ICredentialType } from 'n8n-workflow';
import {
AGENT_NODE_NAME,
AI_TOOL_HTTP_NODE_NAME,
GMAIL_NODE_NAME,
HTTP_REQUEST_NODE_NAME,
NEW_GOOGLE_ACCOUNT_NAME,
Expand Down Expand Up @@ -201,6 +203,31 @@ describe('Credentials', () => {
.should('have.value', NEW_CREDENTIAL_NAME2);
});

it('should edit credential for non-standard credential type', () => {
workflowPage.actions.visit();
workflowPage.actions.addNodeToCanvas(AGENT_NODE_NAME);
workflowPage.actions.addNodeToCanvas(AI_TOOL_HTTP_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
cy.get('body').type('{enter}');
cy.getByTestId('parameter-input-authentication').click();
cy.contains('Predefined Credential Type').click();
cy.getByTestId('credential-select').click();
cy.contains('Adalo API').click();
workflowPage.getters.nodeCredentialsSelect().click();
getVisibleSelect().find('li').last().click();
credentialsModal.actions.fillCredentialsForm();
workflowPage.getters.nodeCredentialsEditButton().click();
credentialsModal.getters.credentialsEditModal().should('be.visible');
credentialsModal.getters.name().click();
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME);
credentialsModal.getters.saveButton().click();
credentialsModal.getters.closeButton().click();
workflowPage.getters
.nodeCredentialsSelect()
.find('input')
.should('have.value', NEW_CREDENTIAL_NAME);
});

it('should setup generic authentication for HTTP node', () => {
workflowPage.actions.visit();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ const sidebarItems = computed(() => {
const defaultCredentialTypeName = computed(() => {
let defaultName = credentialTypeName.value;
if (!defaultName || defaultName === 'null') {
if (activeNodeType.value?.credentials) {
if (activeNodeType.value?.credentials && activeNodeType.value.credentials.length > 0) {
defaultName = activeNodeType.value.credentials[0].name;
}
}
Expand Down

0 comments on commit 0e448dc

Please sign in to comment.