fix(editor): Redirect to workflow editor after saving in debug mode (#7645)

This commit is contained in:
Csaba Tuncsik 2023-11-08 14:04:02 +01:00 committed by GitHub
parent 5df583f783
commit 020042ef1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 deletions

View file

@ -12,14 +12,11 @@ const ndv = new NDV();
const executionsTab = new WorkflowExecutionsTab(); const executionsTab = new WorkflowExecutionsTab();
describe('Debug', () => { describe('Debug', () => {
beforeEach(() => {
cy.enableFeature('debugInEditor');
});
it('should be able to debug executions', () => { it('should be able to debug executions', () => {
cy.intercept('GET', '/rest/settings', (req) => {
req.on('response', (res) => {
res.send({
data: { ...res.body.data, enterprise: { debugInEditor: true } },
});
});
}).as('loadSettings');
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions'); cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/*').as('getExecution'); cy.intercept('GET', '/rest/executions/*').as('getExecution');
cy.intercept('GET', '/rest/executions-current?filter=*').as('getCurrentExecutions'); cy.intercept('GET', '/rest/executions-current?filter=*').as('getCurrentExecutions');
@ -47,6 +44,7 @@ describe('Debug', () => {
cy.wait(['@getExecutions', '@getCurrentExecutions']); cy.wait(['@getExecutions', '@getCurrentExecutions']);
executionsTab.getters.executionDebugButton().should('have.text', 'Debug in editor').click(); executionsTab.getters.executionDebugButton().should('have.text', 'Debug in editor').click();
cy.url().should('include', '/debug');
cy.get('.el-notification').contains('Execution data imported').should('be.visible'); cy.get('.el-notification').contains('Execution data imported').should('be.visible');
cy.get('.matching-pinned-nodes-confirmation').should('not.exist'); cy.get('.matching-pinned-nodes-confirmation').should('not.exist');
@ -56,6 +54,8 @@ describe('Debug', () => {
ndv.actions.close(); ndv.actions.close();
workflowPage.actions.saveWorkflowUsingKeyboardShortcut(); workflowPage.actions.saveWorkflowUsingKeyboardShortcut();
cy.url().should('not.include', '/debug');
workflowPage.actions.executeWorkflow(); workflowPage.actions.executeWorkflow();
cy.wait(['@postWorkflowRun']); cy.wait(['@postWorkflowRun']);
@ -87,6 +87,7 @@ describe('Debug', () => {
confirmDialog = cy.get('.matching-pinned-nodes-confirmation').filter(':visible'); confirmDialog = cy.get('.matching-pinned-nodes-confirmation').filter(':visible');
confirmDialog.find('li').should('have.length', 2); confirmDialog.find('li').should('have.length', 2);
confirmDialog.get('.btn--confirm').click(); confirmDialog.get('.btn--confirm').click();
cy.url().should('include', '/debug');
workflowPage.getters.canvasNodes().first().should('have.descendants', '.node-pin-data-icon'); workflowPage.getters.canvasNodes().first().should('have.descendants', '.node-pin-data-icon');
workflowPage.getters workflowPage.getters
@ -104,6 +105,7 @@ describe('Debug', () => {
workflowPage.getters.canvasNodePlusEndpointByName(EDIT_FIELDS_SET_NODE_NAME).click(); workflowPage.getters.canvasNodePlusEndpointByName(EDIT_FIELDS_SET_NODE_NAME).click();
workflowPage.actions.addNodeToCanvas(IF_NODE_NAME, false); workflowPage.actions.addNodeToCanvas(IF_NODE_NAME, false);
workflowPage.actions.saveWorkflowUsingKeyboardShortcut(); workflowPage.actions.saveWorkflowUsingKeyboardShortcut();
cy.url().should('not.include', '/debug');
executionsTab.actions.switchToExecutionsTab(); executionsTab.actions.switchToExecutionsTab();
cy.wait(['@getExecutions', '@getCurrentExecutions']); cy.wait(['@getExecutions', '@getCurrentExecutions']);
@ -112,6 +114,8 @@ describe('Debug', () => {
confirmDialog = cy.get('.matching-pinned-nodes-confirmation').filter(':visible'); confirmDialog = cy.get('.matching-pinned-nodes-confirmation').filter(':visible');
confirmDialog.find('li').should('have.length', 1); confirmDialog.find('li').should('have.length', 1);
confirmDialog.get('.btn--confirm').click(); confirmDialog.get('.btn--confirm').click();
cy.url().should('include', '/debug');
workflowPage.getters.canvasNodes().last().find('.node-info-icon').should('be.empty'); workflowPage.getters.canvasNodes().last().find('.node-info-icon').should('be.empty');
workflowPage.getters.canvasNodes().first().dblclick(); workflowPage.getters.canvasNodes().first().dblclick();
@ -119,6 +123,8 @@ describe('Debug', () => {
ndv.actions.close(); ndv.actions.close();
workflowPage.actions.saveWorkflowUsingKeyboardShortcut(); workflowPage.actions.saveWorkflowUsingKeyboardShortcut();
cy.url().should('not.include', '/debug');
workflowPage.actions.executeWorkflow(); workflowPage.actions.executeWorkflow();
workflowPage.actions.deleteNode(IF_NODE_NAME); workflowPage.actions.deleteNode(IF_NODE_NAME);
@ -128,5 +134,6 @@ describe('Debug', () => {
cy.wait(['@getExecution']); cy.wait(['@getExecution']);
executionsTab.getters.executionDebugButton().should('have.text', 'Copy to editor').click(); executionsTab.getters.executionDebugButton().should('have.text', 'Copy to editor').click();
cy.get('.el-notification').contains("Some execution data wasn't imported").should('be.visible'); cy.get('.el-notification').contains("Some execution data wasn't imported").should('be.visible');
cy.url().should('include', '/debug');
}); });
}); });

View file

@ -379,7 +379,17 @@ export default defineComponent({
name: this.workflowName, name: this.workflowName,
tags: this.currentWorkflowTagIds, tags: this.currentWorkflowTagIds,
}); });
if (saved) await this.settingsStore.fetchPromptsData();
if (saved) {
await this.settingsStore.fetchPromptsData();
if (this.$route.name === VIEWS.EXECUTION_DEBUG) {
await this.$router.replace({
name: VIEWS.WORKFLOW,
params: { name: this.currentWorkflowId },
});
}
}
}, },
onShareButtonClick() { onShareButtonClick() {
this.uiStore.openModalWithData({ this.uiStore.openModalWithData({

View file

@ -459,7 +459,11 @@ export default defineComponent({
}, },
}, },
async beforeRouteLeave(to, from, next) { async beforeRouteLeave(to, from, next) {
if (getNodeViewTab(to) === MAIN_HEADER_TABS.EXECUTIONS || from.name === VIEWS.TEMPLATE_IMPORT) { if (
getNodeViewTab(to) === MAIN_HEADER_TABS.EXECUTIONS ||
from.name === VIEWS.TEMPLATE_IMPORT ||
(getNodeViewTab(to) === MAIN_HEADER_TABS.WORKFLOW && from.name === VIEWS.EXECUTION_DEBUG)
) {
next(); next();
return; return;
} }
@ -793,7 +797,16 @@ export default defineComponent({
}, },
async onSaveKeyboardShortcut(e: KeyboardEvent) { async onSaveKeyboardShortcut(e: KeyboardEvent) {
let saved = await this.saveCurrentWorkflow(); let saved = await this.saveCurrentWorkflow();
if (saved) await this.settingsStore.fetchPromptsData(); if (saved) {
await this.settingsStore.fetchPromptsData();
if (this.$route.name === VIEWS.EXECUTION_DEBUG) {
await this.$router.replace({
name: VIEWS.WORKFLOW,
params: { name: this.currentWorkflow },
});
}
}
if (this.activeNode) { if (this.activeNode) {
// If NDV is open, save will not work from editable input fields // If NDV is open, save will not work from editable input fields
// so don't show success message if this is true // so don't show success message if this is true
@ -3995,7 +4008,7 @@ export default defineComponent({
const node = tempWorkflow.nodes[nodeNameTable[nodeName]]; const node = tempWorkflow.nodes[nodeNameTable[nodeName]];
try { try {
this.setPinData(node, data.pinData![nodeName], 'add-nodes'); this.setPinData(node, data.pinData[nodeName], 'add-nodes');
pinDataSuccess = true; pinDataSuccess = true;
} catch (error) { } catch (error) {
pinDataSuccess = false; pinDataSuccess = false;