mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Fix custom API call notice (#10227)
This commit is contained in:
@@ -3,6 +3,7 @@ import { createTestingPinia } from '@pinia/testing';
|
|||||||
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
||||||
import { createTestNode } from '@/__tests__/mocks';
|
import { createTestNode } from '@/__tests__/mocks';
|
||||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
|
import { CUSTOM_API_CALL_KEY } from '@/constants';
|
||||||
|
|
||||||
vi.mock('@/stores/workflows.store', () => ({
|
vi.mock('@/stores/workflows.store', () => ({
|
||||||
useWorkflowsStore: vi.fn(),
|
useWorkflowsStore: vi.fn(),
|
||||||
@@ -17,6 +18,34 @@ describe('useNodeHelpers()', () => {
|
|||||||
vi.clearAllMocks();
|
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()', () => {
|
describe('getNodeInputData()', () => {
|
||||||
it('should return an empty array when node is null', () => {
|
it('should return an empty array when node is null', () => {
|
||||||
const { getNodeInputData } = useNodeHelpers();
|
const { getNodeInputData } = useNodeHelpers();
|
||||||
|
|||||||
@@ -97,11 +97,13 @@ export function useNodeHelpers() {
|
|||||||
|
|
||||||
if (!isObject(parameters)) return false;
|
if (!isObject(parameters)) return false;
|
||||||
|
|
||||||
if ('resource' in parameters && 'operation' in parameters) {
|
if ('resource' in parameters || 'operation' in parameters) {
|
||||||
const { resource, operation } = 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;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user