fix(editor): Set workflow name when importing (no-changelog) (#19410)

This commit is contained in:
Daria
2025-09-11 15:29:41 +03:00
committed by GitHub
parent 3af4541391
commit b91219ea15
11 changed files with 53 additions and 30 deletions

View File

@@ -62,8 +62,8 @@ describe('Sharing', { disableAutoLogin: true }, () => {
cy.visit(workflowsPage.url);
workflowsPage.getters.createWorkflowButton().click();
cy.createFixtureWorkflow('Test_workflow_1.json', 'Workflow W2');
workflowPage.actions.saveWorkflowOnButtonClick();
cy.createFixtureWorkflow('Test_workflow_1.json');
workflowPage.actions.setWorkflowName('Workflow W2');
cy.url().then((url) => {
workflowW2Url = url;
});

View File

@@ -466,7 +466,7 @@ describe('Execution', () => {
});
it('should send proper payload for node rerun', () => {
cy.createFixtureWorkflow('Multiple_trigger_node_rerun.json', 'Multiple trigger node rerun');
cy.createFixtureWorkflow('Multiple_trigger_node_rerun.json');
workflowPage.getters.zoomToFitButton().click();
workflowPage.getters.executeWorkflowButton().click();

View File

@@ -14,7 +14,7 @@ describe('Workflow Executions', () => {
describe('when workflow is saved', () => {
beforeEach(() => {
workflowPage.actions.visit();
cy.createFixtureWorkflow('Test_workflow_4_executions_view.json', 'My test workflow');
cy.createFixtureWorkflow('Test_workflow_4_executions_view.json');
});
it('should render executions tab correctly', () => {

View File

@@ -43,7 +43,7 @@ describe('Editor zoom should work after route changes', () => {
cy.enableFeature('workflowHistory');
cy.signinAsOwner();
workflowPage.actions.visit();
cy.createFixtureWorkflow('Lots_of_nodes.json', 'Lots of nodes');
cy.createFixtureWorkflow('Lots_of_nodes.json');
workflowPage.actions.saveWorkflowOnButtonClick();
});

View File

@@ -6,7 +6,7 @@ const ndv = new NDV();
describe('Node IO Filter', () => {
beforeEach(() => {
workflowPage.actions.visit();
cy.createFixtureWorkflow('Node_IO_filter.json', 'Node IO filter');
cy.createFixtureWorkflow('Node_IO_filter.json');
workflowPage.actions.saveWorkflowOnButtonClick();
workflowPage.actions.executeWorkflow();
});

View File

@@ -24,7 +24,7 @@ describe('Workflows', () => {
getNewWorkflowCardButton().should('be.visible');
getNewWorkflowCardButton().click();
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
cy.createFixtureWorkflow('Test_workflow_1.json');
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
@@ -43,7 +43,7 @@ describe('Workflows', () => {
it('should correct route after cancelling saveChangesModal', () => {
getCreateWorkflowButton().click();
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
cy.createFixtureWorkflow('Test_workflow_1.json');
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
// Here we go back via browser rather than the home button
@@ -63,7 +63,7 @@ describe('Workflows', () => {
getCreateWorkflowButton().click();
saveWorkflowOnButtonClick();
cy.url().then((startUrl) => {
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
cy.createFixtureWorkflow('Test_workflow_1.json');
cy.url().should('equal', startUrl);
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
@@ -80,7 +80,7 @@ describe('Workflows', () => {
it('should open ndv via URL', () => {
getCreateWorkflowButton().click();
saveWorkflowOnButtonClick();
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
cy.createFixtureWorkflow('Test_workflow_1.json');
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
cy.url().then((ndvUrl) => {
@@ -98,7 +98,7 @@ describe('Workflows', () => {
it('should open show warning and drop nodeId from URL if it contained an unknown nodeId', () => {
getCreateWorkflowButton().click();
saveWorkflowOnButtonClick();
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
cy.createFixtureWorkflow('Test_workflow_1.json');
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
cy.url().then((ndvUrl) => {

View File

@@ -11,8 +11,8 @@ describe('Workflow Selector Parameter', () => {
cy.signinAsOwner();
['Get_Weather', 'Search_DB'].forEach((workflowName) => {
workflowPage.actions.visit();
cy.createFixtureWorkflow(`Test_Subworkflow_${workflowName}.json`, workflowName);
workflowPage.actions.saveWorkflowOnButtonClick();
cy.createFixtureWorkflow(`Test_Subworkflow_${workflowName}.json`);
workflowPage.actions.setWorkflowName(workflowName);
});
workflowPage.actions.visit();
workflowPage.actions.addInitialNodeToCanvas(EXECUTE_WORKFLOW_NODE_NAME, {

View File

@@ -10,7 +10,6 @@ import {
N8N_AUTH_COOKIE,
} from '../constants';
import { WorkflowPage } from '../pages';
import { getUniqueWorkflowName } from '../utils/workflowUtils';
Cypress.Commands.add('setAppDate', (targetDate: number | Date) => {
cy.window().then((win) => {
@@ -26,22 +25,17 @@ Cypress.Commands.add('getByTestId', (selector, ...args) => {
return cy.get(`[data-test-id="${selector}"]`, ...args);
});
Cypress.Commands.add(
'createFixtureWorkflow',
(fixtureKey: string, workflowName = getUniqueWorkflowName()) => {
const workflowPage = new WorkflowPage();
Cypress.Commands.add('createFixtureWorkflow', (fixtureKey: string) => {
const workflowPage = new WorkflowPage();
// We need to force the click because the input is hidden
workflowPage.getters
.workflowImportInput()
.selectFile(`fixtures/${fixtureKey}`, { force: true });
// We need to force the click because the input is hidden
workflowPage.getters.workflowImportInput().selectFile(`fixtures/${fixtureKey}`, { force: true });
cy.waitForLoad(false);
workflowPage.actions.setWorkflowName(workflowName);
workflowPage.getters.saveButton().should('contain', 'Saved');
workflowPage.actions.zoomToFit();
},
);
cy.waitForLoad(false);
workflowPage.actions.saveWorkflowOnButtonClick();
workflowPage.getters.saveButton().should('contain', 'Saved');
workflowPage.actions.zoomToFit();
});
Cypress.Commands.addQuery('findChildByTestId', function (testId: string) {
return (subject: Cypress.Chainable) => subject.find(`[data-test-id="${testId}"]`);

View File

@@ -33,9 +33,8 @@ declare global {
* Creates a workflow from the given fixture and optionally renames it.
*
* @param fixtureKey
* @param [workflowName] Optional name for the workflow. A random nanoid is used if not given
*/
createFixtureWorkflow(fixtureKey: string, workflowName?: string): void;
createFixtureWorkflow(fixtureKey: string): void;
/** @deprecated use signinAsOwner, signinAsAdmin or signinAsMember instead */
signin(payload: SigninPayload): void;
signinAsOwner(): void;