mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix(editor): Fix custom API call notice (#10227)
This commit is contained in:
parent
d719899223
commit
5b47c8b57b
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue