mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 01:07:04 +02:00
fix(editor): Use existing workflowState when setting node execution issues (#20777)
This commit is contained in:
parent
b32c8cef6e
commit
ef89640dea
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user