fix(editor): Fix partial chat executions (#15379)

This commit is contained in:
oleg
2025-05-15 17:12:08 +02:00
committed by GitHub
parent 726438d95e
commit b6370fb2ec
8 changed files with 452 additions and 32 deletions

View File

@@ -359,6 +359,64 @@ describe('useRunWorkflow({ router })', () => {
expect(result).toEqual(mockExecutionResponse);
});
it('should exclude destinationNode from startNodes when provided', async () => {
// ARRANGE
const mockExecutionResponse = { executionId: '123' };
const { runWorkflow } = useRunWorkflow({ router });
const dataCaptor = captor<IStartRunData>();
const parentNodeName = 'parentNode';
const destinationNodeName = 'destinationNode';
// Mock workflow with parent-child relationship
const workflow = {
name: 'Test Workflow',
id: 'workflowId',
getParentNodes: vi.fn().mockImplementation((nodeName: string) => {
if (nodeName === destinationNodeName) {
return [parentNodeName];
}
return [];
}),
nodes: {
[parentNodeName]: createTestNode({ name: parentNodeName }),
[destinationNodeName]: createTestNode({ name: destinationNodeName }),
},
} as unknown as Workflow;
vi.mocked(pushConnectionStore).isConnected = true;
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockExecutionResponse);
vi.mocked(workflowsStore).nodesIssuesExist = false;
vi.mocked(workflowHelpers).getCurrentWorkflow.mockReturnValue(workflow);
vi.mocked(workflowHelpers).getWorkflowDataToSave.mockResolvedValue({
id: 'workflowId',
nodes: [],
} as unknown as IWorkflowData);
vi.mocked(workflowsStore).getWorkflowRunData = {
[parentNodeName]: [
{
startTime: 1,
executionTime: 0,
source: [],
data: { main: [[{ json: { test: 'data' } }]] },
},
],
} as unknown as IRunData;
// ACT
await runWorkflow({ destinationNode: destinationNodeName });
// ASSERT
expect(workflowsStore.runWorkflow).toHaveBeenCalledTimes(1);
expect(workflowsStore.runWorkflow).toHaveBeenCalledWith(dataCaptor);
const startNodes = dataCaptor.value.startNodes ?? [];
const destinationInStartNodes = startNodes.some((node) => node.name === destinationNodeName);
expect(destinationInStartNodes).toBe(false);
});
it('should send dirty nodes for partial executions v2', async () => {
vi.mocked(settingsStore).partialExecutionVersion = 2;
const composable = useRunWorkflow({ router });