mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Parse out nodeType (#13474)
This commit is contained in:
parent
59389194c2
commit
1cd13b639e
|
@ -18,7 +18,9 @@ export const getSchemaPreview = async (
|
|||
): Promise<JSONSchema7> => {
|
||||
const { nodeType, version, resource, operation } = options;
|
||||
const versionString = padVersion(version);
|
||||
const path = ['schemas', nodeType, versionString, resource, operation].filter(Boolean).join('/');
|
||||
const path = ['schemas', nodeType.replace('@n8n/', ''), versionString, resource, operation]
|
||||
.filter(Boolean)
|
||||
.join('/');
|
||||
return await request({
|
||||
method: 'GET',
|
||||
baseURL: baseUrl,
|
||||
|
|
41
packages/editor-ui/src/api/test/schemaPreview.test.ts
Normal file
41
packages/editor-ui/src/api/test/schemaPreview.test.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { getSchemaPreview } from '../schemaPreview';
|
||||
import * as apiUtils from '@/utils/apiUtils';
|
||||
|
||||
describe('schemaPreview', () => {
|
||||
afterEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
vi.mock('@/utils/apiUtils', () => ({
|
||||
request: vi.fn().mockResolvedValue({ test: 'test' }),
|
||||
}));
|
||||
|
||||
it('should return schema preview', async () => {
|
||||
const response = await getSchemaPreview('http://test.com', {
|
||||
nodeType: 'n8n-nodes-base.asana',
|
||||
version: 1,
|
||||
resource: 'resource',
|
||||
operation: 'operation',
|
||||
});
|
||||
|
||||
expect(response).toEqual({ test: 'test' });
|
||||
});
|
||||
|
||||
it('should parse out nodeType', async () => {
|
||||
const spy = vi.spyOn(apiUtils, 'request');
|
||||
|
||||
await getSchemaPreview('http://test.com', {
|
||||
nodeType: '@n8n/n8n-nodes-base.asana',
|
||||
version: 1,
|
||||
resource: 'resource',
|
||||
operation: 'operation',
|
||||
});
|
||||
|
||||
expect(spy).toHaveBeenCalledWith({
|
||||
method: 'GET',
|
||||
baseURL: 'http://test.com',
|
||||
endpoint: 'schemas/n8n-nodes-base.asana/1.0.0/resource/operation.json',
|
||||
withCredentials: false,
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue