refactor(editor): Stop cloning and serializing full execution data for executionFinished push message (#11703)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-11-14 17:39:46 +01:00
committed by GitHub
parent 7bb9002cbc
commit 15ca2c4e45
16 changed files with 273 additions and 478 deletions

View File

@@ -26,6 +26,7 @@
"cypress": "^13.14.2",
"cypress-otp": "^1.0.3",
"cypress-real-events": "^1.13.0",
"flatted": "catalog:",
"lodash": "catalog:",
"nanoid": "catalog:",
"start-server-and-test": "^2.0.8"

View File

@@ -1,7 +1,7 @@
// Load type definitions that come with Cypress module
/// <reference types="cypress" />
import type { FrontendSettings } from '@n8n/api-types';
import type { FrontendSettings, PushPayload, PushType } from '@n8n/api-types';
Cypress.Keyboard.defaults({
keystrokeDelay: 0,
@@ -66,7 +66,7 @@ declare global {
droppableSelector: string,
options?: Partial<DragAndDropOptions>,
): void;
push(type: string, data: unknown): void;
push<Type extends PushType>(type: Type, data: PushPayload<Type>): void;
shouldNotHaveConsoleErrors(): void;
window(): Chainable<
AUTWindow & {

View File

@@ -1,5 +1,5 @@
import { stringify } from 'flatted';
import type { IDataObject, IPinData, ITaskData, ITaskDataConnections } from 'n8n-workflow';
import { nanoid } from 'nanoid';
import { clickExecuteWorkflowButton } from '../composables/workflow';
@@ -39,41 +39,35 @@ export function createMockNodeExecutionData(
};
}
export function createMockWorkflowExecutionData({
executionId,
function createMockWorkflowExecutionData({
runData,
pinData = {},
lastNodeExecuted,
}: {
executionId: string;
runData: Record<string, ITaskData | ITaskData[]>;
pinData?: IPinData;
lastNodeExecuted: string;
}) {
return {
executionId,
data: {
data: {
startData: {},
resultData: {
runData,
pinData,
lastNodeExecuted,
},
executionData: {
contextData: {},
nodeExecutionStack: [],
metadata: {},
waitingExecution: {},
waitingExecutionSource: {},
},
data: stringify({
startData: {},
resultData: {
runData,
pinData: {},
lastNodeExecuted,
},
mode: 'manual',
startedAt: new Date().toISOString(),
stoppedAt: new Date().toISOString(),
status: 'success',
finished: true,
},
executionData: {
contextData: {},
nodeExecutionStack: [],
metadata: {},
waitingExecution: {},
waitingExecutionSource: {},
},
}),
mode: 'manual',
startedAt: new Date().toISOString(),
stoppedAt: new Date().toISOString(),
status: 'success',
finished: true,
};
}
@@ -81,14 +75,12 @@ export function runMockWorkflowExecution({
trigger,
lastNodeExecuted,
runData,
workflowExecutionData,
}: {
trigger?: () => void;
lastNodeExecuted: string;
runData: Array<ReturnType<typeof createMockNodeExecutionData>>;
workflowExecutionData?: ReturnType<typeof createMockWorkflowExecutionData>;
}) {
const executionId = nanoid(8);
const executionId = Math.floor(Math.random() * 1_000_000).toString();
cy.intercept('POST', '/rest/workflows/**/run?**', {
statusCode: 201,
@@ -125,13 +117,17 @@ export function runMockWorkflowExecution({
resolvedRunData[nodeName] = nodeExecution[nodeName];
});
cy.push(
'executionFinished',
createMockWorkflowExecutionData({
executionId,
lastNodeExecuted,
runData: resolvedRunData,
...workflowExecutionData,
}),
);
cy.intercept('GET', `/rest/executions/${executionId}`, {
statusCode: 200,
body: {
data: createMockWorkflowExecutionData({
lastNodeExecuted,
runData: resolvedRunData,
}),
},
}).as('getExecution');
cy.push('executionFinished', { executionId });
cy.wait('@getExecution');
}