fix(editor): Use existing workflowState when setting node execution issues (#20777)

This commit is contained in:
Charlie Kolb 2025-10-16 09:30:09 +02:00 committed by GitHub
parent b32c8cef6e
commit ef89640dea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 4 deletions

View File

@ -19,6 +19,15 @@ import { faker } from '@faker-js/faker';
import type { INodeUi } from '@/Interface';
import type { IUsedCredential } from '@/features/credentials/credentials.types';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { injectWorkflowState, useWorkflowState } from './useWorkflowState';
vi.mock('@/composables/useWorkflowState', async () => {
const actual = await vi.importActual('@/composables/useWorkflowState');
return {
...actual,
injectWorkflowState: vi.fn(),
};
});
describe('useNodeHelpers()', () => {
beforeAll(() => {
@ -29,6 +38,23 @@ describe('useNodeHelpers()', () => {
vi.clearAllMocks();
});
describe('initialization', () => {
it('should use provided workflowState and not inject', () => {
const workflowState = useWorkflowState();
vi.clearAllMocks();
useNodeHelpers({ workflowState });
expect(injectWorkflowState).not.toBeCalled();
});
it('should create workflowState if not provided', () => {
useNodeHelpers();
expect(injectWorkflowState).toBeCalled();
});
});
describe('isNodeExecutable()', () => {
it('should return true if the node is null but explicitly executable', () => {
const { isNodeExecutable } = useNodeHelpers();

View File

@ -51,7 +51,7 @@ import { useTelemetry } from './useTelemetry';
import { hasPermission } from '@/utils/rbac/permissions';
import { useCanvasStore } from '@/stores/canvas.store';
import { useSettingsStore } from '@/stores/settings.store';
import { injectWorkflowState } from './useWorkflowState';
import { injectWorkflowState, type WorkflowState } from './useWorkflowState';
declare namespace HttpRequestNode {
namespace V2 {
@ -63,12 +63,12 @@ declare namespace HttpRequestNode {
}
}
export function useNodeHelpers() {
export function useNodeHelpers(opts: { workflowState?: WorkflowState } = {}) {
const credentialsStore = useCredentialsStore();
const historyStore = useHistoryStore();
const nodeTypesStore = useNodeTypesStore();
const workflowsStore = useWorkflowsStore();
const workflowState = injectWorkflowState();
const workflowState = opts.workflowState ?? injectWorkflowState();
const settingsStore = useSettingsStore();
const i18n = useI18n();
const canvasStore = useCanvasStore();

View File

@ -421,7 +421,7 @@ export function setRunExecutionData(
workflowState: WorkflowState,
) {
const workflowsStore = useWorkflowsStore();
const nodeHelpers = useNodeHelpers();
const nodeHelpers = useNodeHelpers({ workflowState });
const runDataExecutedErrorMessage = getRunDataExecutedErrorMessage(execution);
const workflowExecution = workflowsStore.getWorkflowExecution;