-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): Split exhaustive tests
- Loading branch information
Showing
4 changed files
with
141 additions
and
107 deletions.
There are no files selected for viewing
107 changes: 0 additions & 107 deletions
107
packages/ui/src/components/Visualization/Canvas/CanvasFormTabs.exhaustive.test.tsx
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
packages/ui/src/components/Visualization/Canvas/Form.components.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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<string, ICamelComponentDefinition>; | ||
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( | ||
<AutoField.componentDetectorContext.Provider value={CustomAutoFieldDetector}> | ||
<AutoForm schema={schema!} model={{}} onChangeModel={() => {}}> | ||
<AutoFields omitFields={SchemaService.OMIT_FORM_FIELDS} /> | ||
</AutoForm> | ||
</AutoField.componentDetectorContext.Provider>, | ||
); | ||
} catch (e) { | ||
throw new Error(`Error rendering ${name} component: \n ${e}`); | ||
} | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/ui/src/components/Visualization/Canvas/Form.eips.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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<string, ICamelProcessorDefinition>; | ||
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( | ||
<AutoField.componentDetectorContext.Provider value={CustomAutoFieldDetector}> | ||
<AutoForm schema={schema!} model={{}} onChangeModel={() => {}}> | ||
<AutoFields omitFields={SchemaService.OMIT_FORM_FIELDS} /> | ||
</AutoForm> | ||
</AutoField.componentDetectorContext.Provider>, | ||
); | ||
} catch (e) { | ||
throw new Error(`Error rendering ${name} EIP: \n ${e}`); | ||
} | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/ui/src/components/Visualization/Canvas/Form.kamelets.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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<string, IKameletDefinition>; | ||
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( | ||
<AutoField.componentDetectorContext.Provider value={CustomAutoFieldDetector}> | ||
<AutoForm schema={schema!} model={{}} onChangeModel={() => {}}> | ||
<AutoFields omitFields={SchemaService.OMIT_FORM_FIELDS} /> | ||
</AutoForm> | ||
</AutoField.componentDetectorContext.Provider>, | ||
); | ||
} catch (e) { | ||
throw new Error(`Error rendering ${name} Kamelet: \n ${e}`); | ||
} | ||
}); | ||
}); | ||
}); |