diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Form.components.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Form.components.test.tsx deleted file mode 100644 index 4f616426c..000000000 --- a/packages/ui/src/components/Visualization/Canvas/Form/Form.components.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { AutoField, AutoFields, AutoForm } from '@kaoto-next/uniforms-patternfly'; -import catalogLibrary from '@kaoto/camel-catalog/index.json'; -import { CatalogLibrary } from '@kaoto/camel-catalog/types'; -import { render } from '@testing-library/react'; -import { CamelCatalogService, CatalogKind, ICamelComponentDefinition } from '../../../../models'; -import { getFirstCatalogMap } from '../../../../stubs/test-load-catalog'; -import { SchemaService } from '../../../Form'; -import { CustomAutoFieldDetector } from '../../../Form/CustomAutoField'; - -describe('Form - components', () => { - let componentCatalogMap: Record; - const schemaService = new SchemaService(); - - beforeAll(async () => { - const catalogsMap = await getFirstCatalogMap(catalogLibrary as CatalogLibrary); - componentCatalogMap = catalogsMap.componentCatalogMap; - - CamelCatalogService.setCatalogKey(CatalogKind.Component, componentCatalogMap); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(() => {}); - }); - - it('should render for all component without an error', async () => { - Object.entries(componentCatalogMap).forEach(([name, catalog]) => { - try { - if (name === 'default') return; - - const schema = schemaService.getSchemaBridge(catalog.propertiesSchema); - render( - - {}}> - - - , - ); - } catch (e) { - throw new Error(`Error rendering ${name} component: \n ${e}`); - } - }); - }); -}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Form.eips.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Form.eips.test.tsx deleted file mode 100644 index 28aa22d64..000000000 --- a/packages/ui/src/components/Visualization/Canvas/Form/Form.eips.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { AutoField, AutoFields, AutoForm } from '@kaoto-next/uniforms-patternfly'; -import catalogLibrary from '@kaoto/camel-catalog/index.json'; -import { CatalogLibrary } from '@kaoto/camel-catalog/types'; -import { render } from '@testing-library/react'; -import { CamelCatalogService, CatalogKind, ICamelProcessorDefinition } from '../../../../models'; -import { getFirstCatalogMap } from '../../../../stubs/test-load-catalog'; -import { SchemaService } from '../../../Form'; -import { CustomAutoFieldDetector } from '../../../Form/CustomAutoField'; - -describe('Form - EIPs', () => { - let patternCatalogMap: Record; - const schemaService = new SchemaService(); - - beforeAll(async () => { - const catalogsMap = await getFirstCatalogMap(catalogLibrary as CatalogLibrary); - patternCatalogMap = catalogsMap.patternCatalogMap; - - CamelCatalogService.setCatalogKey(CatalogKind.Pattern, patternCatalogMap); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(() => {}); - }); - - it('should render for all EIPs without an error', async () => { - Object.entries(patternCatalogMap).forEach(([name, catalog]) => { - try { - if (name === 'default') return; - - const schema = schemaService.getSchemaBridge(catalog.propertiesSchema); - render( - - {}}> - - - , - ); - } catch (e) { - throw new Error(`Error rendering ${name} EIP: \n ${e}`); - } - }); - }); -}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Form.kamelets.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Form.kamelets.test.tsx deleted file mode 100644 index 2ce032253..000000000 --- a/packages/ui/src/components/Visualization/Canvas/Form/Form.kamelets.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { AutoField, AutoFields, AutoForm } from '@kaoto-next/uniforms-patternfly'; -import catalogLibrary from '@kaoto/camel-catalog/index.json'; -import { CatalogLibrary } from '@kaoto/camel-catalog/types'; -import { render } from '@testing-library/react'; -import { CamelCatalogService, CatalogKind, IKameletDefinition } from '../../../../models'; -import { getFirstCatalogMap } from '../../../../stubs/test-load-catalog'; -import { SchemaService } from '../../../Form'; -import { CustomAutoFieldDetector } from '../../../Form/CustomAutoField'; - -describe('Form - Kamelets', () => { - let kameletCatalogMap: Record; - const schemaService = new SchemaService(); - - beforeAll(async () => { - const catalogsMap = await getFirstCatalogMap(catalogLibrary as CatalogLibrary); - kameletCatalogMap = catalogsMap.kameletsCatalogMap; - - CamelCatalogService.setCatalogKey(CatalogKind.Kamelet, kameletCatalogMap); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(() => {}); - }); - - it('should render for all Kamelets without an error', async () => { - Object.entries(kameletCatalogMap).forEach(([name, catalog]) => { - try { - if (name === 'default') return; - - const schema = schemaService.getSchemaBridge(catalog.propertiesSchema); - render( - - {}}> - - - , - ); - } catch (e) { - throw new Error(`Error rendering ${name} Kamelet: \n ${e}`); - } - }); - }); -}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.000-050.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.000-050.test.tsx new file mode 100644 index 000000000..909b8751d --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.000-050.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 0, end: 50 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.050-100.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.050-100.test.tsx new file mode 100644 index 000000000..d70230562 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.050-100.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 50, end: 100 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.100-150.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.100-150.test.tsx new file mode 100644 index 000000000..8d75884ab --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.100-150.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 100, end: 150 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.150-200.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.150-200.test.tsx new file mode 100644 index 000000000..895f505a0 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.150-200.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 150, end: 200 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.200-250.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.200-250.test.tsx new file mode 100644 index 000000000..e56b84187 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.200-250.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 200, end: 250 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.250-300.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.250-300.test.tsx new file mode 100644 index 000000000..7889ac4d8 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.250-300.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 250, end: 300 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.300-end.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.300-end.test.tsx new file mode 100644 index 000000000..690b66a8c --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.components.300-end.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Component, range: { start: 300, end: undefined } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.eips.000-end.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.eips.000-end.test.tsx new file mode 100644 index 000000000..1e58ea25c --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.eips.000-end.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Pattern, range: { start: 0, end: undefined } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.000-050.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.000-050.test.tsx new file mode 100644 index 000000000..058684e45 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.000-050.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Kamelet, range: { start: 0, end: 50 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.050-100.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.050-100.test.tsx new file mode 100644 index 000000000..481f0c5e6 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.050-100.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Kamelet, range: { start: 50, end: 100 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.100-150.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.100-150.test.tsx new file mode 100644 index 000000000..c9c4936fe --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.100-150.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Kamelet, range: { start: 100, end: 150 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.150-200.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.150-200.test.tsx new file mode 100644 index 000000000..189990b07 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.150-200.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Kamelet, range: { start: 150, end: 200 } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.200-end.test.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.200-end.test.tsx new file mode 100644 index 000000000..6d405734b --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/Form.kamelets.200-end.test.tsx @@ -0,0 +1,8 @@ +import { CatalogKind } from '../../../../../models'; +import { FormTest } from './FormTest'; + +const target = { kind: CatalogKind.Kamelet, range: { start: 200, end: undefined } }; + +describe(`Form: ${target.kind} - [${target.range.start} - ${target.range.end}]`, () => { + FormTest(target); +}); diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/FormTest.tsx b/packages/ui/src/components/Visualization/Canvas/Form/Tests/FormTest.tsx new file mode 100644 index 000000000..1670e46b0 --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/FormTest.tsx @@ -0,0 +1,51 @@ +import { AutoField, AutoFields, AutoForm } from '@kaoto-next/uniforms-patternfly'; +import catalogLibrary from '@kaoto/camel-catalog/index.json'; +import { CatalogLibrary } from '@kaoto/camel-catalog/types'; +import { render } from '@testing-library/react'; +import { CamelCatalogService, CatalogKind, KaotoSchemaDefinition } from '../../../../../models'; +import { getFirstCatalogMap } from '../../../../../stubs/test-load-catalog'; +import { SchemaService } from '../../../../Form'; +import { CustomAutoFieldDetector } from '../../../../Form/CustomAutoField'; +import { getSchemasSlice } from './get-schemas-slices'; + +export const FormTest = (target: { kind: CatalogKind; range: { start: number; end: number | undefined } }) => { + let schemas: [string, KaotoSchemaDefinition['schema']][] = []; + + beforeAll(async () => { + const catalogsMap = await getFirstCatalogMap(catalogLibrary as CatalogLibrary); + + CamelCatalogService.setCatalogKey(CatalogKind.Component, catalogsMap.componentCatalogMap); + CamelCatalogService.setCatalogKey(CatalogKind.Pattern, catalogsMap.patternCatalogMap); + CamelCatalogService.setCatalogKey(CatalogKind.Kamelet, catalogsMap.kameletsCatalogMap); + + schemas = getSchemasSlice(CamelCatalogService.getCatalogByKey(target.kind), target.range); + jest.spyOn(console, 'error').mockImplementation(() => {}); + }); + + afterAll(() => { + jest.clearAllMocks(); + }); + + it('should have schemas', () => { + expect(schemas).not.toHaveLength(0); + }); + + it('should render the form without an error', () => { + schemas.forEach(([name, schema]) => { + try { + const schemaService = new SchemaService(); + const schemaBridge = schemaService.getSchemaBridge(schema); + render( + + {}}> + + + , + ); + } catch (e) { + console.error(e); + throw new Error(`Error rendering ${name} ${target.kind}`); + } + }); + }); +}; diff --git a/packages/ui/src/components/Visualization/Canvas/Form/Tests/get-schemas-slices.ts b/packages/ui/src/components/Visualization/Canvas/Form/Tests/get-schemas-slices.ts new file mode 100644 index 000000000..96405104b --- /dev/null +++ b/packages/ui/src/components/Visualization/Canvas/Form/Tests/get-schemas-slices.ts @@ -0,0 +1,21 @@ +import { + ICamelComponentDefinition, + ICamelProcessorDefinition, + IKameletDefinition, + KaotoSchemaDefinition, +} from '../../../../../models'; + +export const getSchemasSlice = ( + catalogMap: + | Record + | Record + | Record + | undefined, + range: { start: number; end: number | undefined }, +): [string, KaotoSchemaDefinition['schema']][] => { + if (!catalogMap) return []; + + return Object.entries(catalogMap) + .slice(range.start, range.end) + .map(([name, { propertiesSchema }]) => [name, propertiesSchema]); +};