diff --git a/packages/editor-ui/src/composables/__tests__/useNodeHelpers.test.ts b/packages/editor-ui/src/composables/__tests__/useNodeHelpers.test.ts index 1969b3d5b8..732bf51f5e 100644 --- a/packages/editor-ui/src/composables/__tests__/useNodeHelpers.test.ts +++ b/packages/editor-ui/src/composables/__tests__/useNodeHelpers.test.ts @@ -3,6 +3,7 @@ import { createTestingPinia } from '@pinia/testing'; import { useNodeHelpers } from '@/composables/useNodeHelpers'; import { createTestNode } from '@/__tests__/mocks'; import { useWorkflowsStore } from '@/stores/workflows.store'; +import { CUSTOM_API_CALL_KEY } from '@/constants'; vi.mock('@/stores/workflows.store', () => ({ useWorkflowsStore: vi.fn(), @@ -17,6 +18,34 @@ describe('useNodeHelpers()', () => { vi.clearAllMocks(); }); + describe('isCustomApiCallSelected', () => { + test('should return `true` when resource includes `CUSTOM_API_CALL_KEY`', () => { + const nodeValues = { + parameters: { resource: CUSTOM_API_CALL_KEY }, + }; + expect(useNodeHelpers().isCustomApiCallSelected(nodeValues)).toBe(true); + }); + + test('should return `true` when operation includes `CUSTOM_API_CALL_KEY`', () => { + const nodeValues = { + parameters: { + operation: CUSTOM_API_CALL_KEY, + }, + }; + expect(useNodeHelpers().isCustomApiCallSelected(nodeValues)).toBe(true); + }); + + test('should return `false` when neither resource nor operation includes `CUSTOM_API_CALL_KEY`', () => { + const nodeValues = { + parameters: { + resource: 'users', + operation: 'get', + }, + }; + expect(useNodeHelpers().isCustomApiCallSelected(nodeValues)).toBe(false); + }); + }); + describe('getNodeInputData()', () => { it('should return an empty array when node is null', () => { const { getNodeInputData } = useNodeHelpers(); diff --git a/packages/editor-ui/src/composables/useNodeHelpers.ts b/packages/editor-ui/src/composables/useNodeHelpers.ts index 00f18041b0..19e46339bc 100644 --- a/packages/editor-ui/src/composables/useNodeHelpers.ts +++ b/packages/editor-ui/src/composables/useNodeHelpers.ts @@ -97,11 +97,13 @@ export function useNodeHelpers() { if (!isObject(parameters)) return false; - if ('resource' in parameters && 'operation' in parameters) { + if ('resource' in parameters || 'operation' in parameters) { const { resource, operation } = parameters; - if (!isString(resource) || !isString(operation)) return false; - return resource.includes(CUSTOM_API_CALL_KEY) || operation.includes(CUSTOM_API_CALL_KEY); + return ( + (isString(resource) && resource.includes(CUSTOM_API_CALL_KEY)) || + (isString(operation) && operation.includes(CUSTOM_API_CALL_KEY)) + ); } return false;