mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix: Fix template credential setup for nodes that dont have credentials (#8208)
Fix template credential setup for templates whose workflow includes nodes that require credentials but the workflow definition does not have them defined. Like for example https://n8n.io/workflows/1344-save-email-attachments-to-nextcloud/
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { CredentialsModal, MessageBox } from '../pages/modals';
|
||||
import {
|
||||
clickUseWorkflowButtonByTitle,
|
||||
visitTemplateCollectionPage,
|
||||
@@ -9,8 +8,6 @@ import { TemplateWorkflowPage } from '../pages/template-workflow';
|
||||
import { WorkflowPage } from '../pages/workflow';
|
||||
|
||||
const templateWorkflowPage = new TemplateWorkflowPage();
|
||||
const credentialsModal = new CredentialsModal();
|
||||
const messageBox = new MessageBox();
|
||||
const workflowPage = new WorkflowPage();
|
||||
|
||||
const testTemplate = templateCredentialsSetupPage.testData.simpleTemplate;
|
||||
@@ -95,24 +92,48 @@ describe('Template credentials setup', () => {
|
||||
// Continue button should be disabled if no credentials are created
|
||||
templateCredentialsSetupPage.getters.continueButton().should('be.disabled');
|
||||
|
||||
templateCredentialsSetupPage.getters.createAppCredentialsButton('Shopify').click();
|
||||
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
|
||||
credentialsModal.actions.save(false);
|
||||
credentialsModal.actions.close();
|
||||
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Shopify');
|
||||
|
||||
// Continue button should be enabled if at least one has been created
|
||||
templateCredentialsSetupPage.getters.continueButton().should('be.enabled');
|
||||
|
||||
templateCredentialsSetupPage.getters.createAppCredentialsButton('X (Formerly Twitter)').click();
|
||||
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
|
||||
credentialsModal.actions.save(false);
|
||||
credentialsModal.actions.close();
|
||||
messageBox.actions.cancel();
|
||||
templateCredentialsSetupPage.fillInDummyCredentialsForAppWithConfirm('X (Formerly Twitter)');
|
||||
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Telegram');
|
||||
|
||||
templateCredentialsSetupPage.getters.createAppCredentialsButton('Telegram').click();
|
||||
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
|
||||
credentialsModal.actions.save(false);
|
||||
credentialsModal.actions.close();
|
||||
cy.intercept('POST', '/rest/workflows').as('createWorkflow');
|
||||
templateCredentialsSetupPage.getters.continueButton().should('be.enabled');
|
||||
templateCredentialsSetupPage.getters.continueButton().click();
|
||||
cy.wait('@createWorkflow');
|
||||
|
||||
workflowPage.getters.canvasNodes().should('have.length', 3);
|
||||
});
|
||||
|
||||
it('should work with a template that has no credentials (ADO-1603)', () => {
|
||||
const templateWithoutCreds = templateCredentialsSetupPage.testData.templateWithoutCredentials;
|
||||
cy.intercept('GET', `https://api.n8n.io/api/templates/workflows/${templateWithoutCreds.id}`, {
|
||||
fixture: templateWithoutCreds.fixture,
|
||||
});
|
||||
templateCredentialsSetupPage.visitTemplateCredentialSetupPage(templateWithoutCreds.id);
|
||||
|
||||
const expectedAppNames = ['1. Email (IMAP)', '2. Nextcloud'];
|
||||
const expectedAppDescriptions = [
|
||||
'The credential you select will be used in the IMAP Email node of the workflow template.',
|
||||
'The credential you select will be used in the Nextcloud node of the workflow template.',
|
||||
];
|
||||
|
||||
templateCredentialsSetupPage.getters.appCredentialSteps().each(($el, index) => {
|
||||
templateCredentialsSetupPage.getters
|
||||
.stepHeading($el)
|
||||
.should('have.text', expectedAppNames[index]);
|
||||
templateCredentialsSetupPage.getters
|
||||
.stepDescription($el)
|
||||
.should('have.text', expectedAppDescriptions[index]);
|
||||
});
|
||||
|
||||
templateCredentialsSetupPage.getters.continueButton().should('be.disabled');
|
||||
|
||||
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Email (IMAP)');
|
||||
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Nextcloud');
|
||||
|
||||
cy.intercept('POST', '/rest/workflows').as('createWorkflow');
|
||||
templateCredentialsSetupPage.getters.continueButton().should('be.enabled');
|
||||
|
||||
182
cypress/fixtures/Test_Template_2.json
Normal file
182
cypress/fixtures/Test_Template_2.json
Normal file
File diff suppressed because one or more lines are too long
@@ -1,3 +1,5 @@
|
||||
import { CredentialsModal, MessageBox } from './modals';
|
||||
|
||||
export type TemplateTestData = {
|
||||
id: number;
|
||||
fixture: string;
|
||||
@@ -8,8 +10,15 @@ export const testData = {
|
||||
id: 1205,
|
||||
fixture: 'Test_Template_1.json',
|
||||
},
|
||||
templateWithoutCredentials: {
|
||||
id: 1344,
|
||||
fixture: 'Test_Template_2.json',
|
||||
},
|
||||
};
|
||||
|
||||
const credentialsModal = new CredentialsModal();
|
||||
const messageBox = new MessageBox();
|
||||
|
||||
export const getters = {
|
||||
continueButton: () => cy.getByTestId('continue-button'),
|
||||
skipLink: () => cy.get('a:contains("Skip")'),
|
||||
@@ -33,3 +42,23 @@ export const enableTemplateCredentialSetupFeatureFlag = () => {
|
||||
win.featureFlags.override('016_template_credential_setup', true);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Fills in dummy credentials for the given app name.
|
||||
*/
|
||||
export const fillInDummyCredentialsForApp = (appName: string) => {
|
||||
getters.createAppCredentialsButton(appName).click();
|
||||
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
|
||||
credentialsModal.actions.save(false);
|
||||
credentialsModal.actions.close();
|
||||
};
|
||||
|
||||
/**
|
||||
* Fills in dummy credentials for the given app name. Assumes
|
||||
* that a confirmation message box will be shown, which will be
|
||||
* handled.
|
||||
*/
|
||||
export const fillInDummyCredentialsForAppWithConfirm = (appName: string) => {
|
||||
fillInDummyCredentialsForApp(appName);
|
||||
messageBox.actions.cancel();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user