fix(editor): Fix routing between workflow editing and new workflow pages (#14031)

This commit is contained in:
Csaba Tuncsik
2025-03-19 06:02:58 +01:00
committed by GitHub
parent ebf912dd30
commit 6817abe47f
3 changed files with 50 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
export const universalAddButton = () => cy.getByTestId('universal-add');
export const createResource = (
resourceType: 'project' | 'workflow' | 'credential',
projectName: string,
) => {
universalAddButton().click();
cy.getByTestId('navigation-submenu')
.contains(new RegExp(resourceType, 'i'))
.should('be.visible')
.click();
if (resourceType !== 'project') {
cy.getByTestId('navigation-submenu-item')
.contains(new RegExp(projectName))
.should('be.visible')
.click();
}
};

View File

@@ -1,7 +1,9 @@
import { createResource } from '../composables/create';
import { setCredentialValues } from '../composables/modals/credential-modal';
import { clickCreateNewCredential, selectResourceLocatorItem } from '../composables/ndv';
import * as projects from '../composables/projects';
import {
EDIT_FIELDS_SET_NODE_NAME,
INSTANCE_ADMIN,
INSTANCE_MEMBERS,
INSTANCE_OWNER,
@@ -360,6 +362,31 @@ describe('Projects', { disableAutoLogin: true }, () => {
projects.getIconPickerButton().should('contain', '😀');
projects.getMenuItems().contains(NEW_PROJECT_NAME).should('contain', '😀');
});
it('should be able to create a workflow when in the workflow editor', () => {
cy.signinAsOwner();
workflowPage.actions.visit();
workflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
workflowPage.actions.saveWorkflowOnButtonClick();
cy.url().then((url) => {
createResource('workflow', 'Personal');
cy.get('body').click();
workflowPage.getters.canvasNodes().should('not.have.length');
cy.go('back');
cy.url().should('eq', url);
workflowPage.getters.canvasNodes().should('have.length', 2);
createResource('workflow', 'Personal');
cy.url().then((url) => {
const urlObj = new URL(url);
expect(urlObj.pathname).to.include('/workflow/new');
workflowPage.getters.canvasNodes().should('not.have.length');
});
});
});
});
describe('when moving resources between projects', () => {

View File

@@ -1612,8 +1612,10 @@ function showAddFirstStepIfEnabled() {
watch(
() => route.name,
async (newRouteName, oldRouteName) => {
// it's navigating from and existing workflow to a new workflow
const force = newRouteName === VIEWS.NEW_WORKFLOW && oldRouteName === VIEWS.WORKFLOW;
// When navigating from an existing workflow to a new workflow or the other way around we should load the new workflow
const force =
(newRouteName === VIEWS.NEW_WORKFLOW && oldRouteName === VIEWS.WORKFLOW) ||
(newRouteName === VIEWS.WORKFLOW && oldRouteName === VIEWS.NEW_WORKFLOW);
await initializeRoute(force);
},
);