@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
tsx 54 lines 2.04 KB
Raw
1 import { describe, expect, test } from 'bun:test';
2 import { renderToStaticMarkup } from 'react-dom/server';
3
4 import { CustomSchemaUI } from '../../components/custom-schema-ui';
5 import { generateSchemaData, getSchemaDisplayDescription } from '../../components/schema-generator';
6
7 describe('experimental API schema fields', () => {
8 test('removes only a leading marker from flagged descriptions', () => {
9 expect(
10 getSchemaDisplayDescription('[EXPERIMENTAL] Whether to validate credentials', true)
11 ).toBe('Whether to validate credentials');
12 expect(
13 getSchemaDisplayDescription('[Experimental] Whether to validate credentials', true)
14 ).toBe('Whether to validate credentials');
15 expect(getSchemaDisplayDescription('[EXPERIMENTAL] Unflagged source description', false)).toBe(
16 '[EXPERIMENTAL] Unflagged source description'
17 );
18 expect(getSchemaDisplayDescription('Experimental behavior without a source marker', true)).toBe(
19 'Experimental behavior without a source marker'
20 );
21 });
22
23 test('renders one Experimental badge with clean field copy', () => {
24 const generated = generateSchemaData(
25 {
26 root: {
27 type: 'object',
28 properties: {
29 validate_credentials: {
30 type: 'boolean',
31 default: false,
32 description: '[EXPERIMENTAL] Whether to validate the provided credentials',
33 'x-experimental': true,
34 },
35 },
36 },
37 },
38 {
39 renderMarkdown: text => text,
40 schema: { getRawRef: () => undefined, resolve: node => node },
41 }
42 );
43
44 const html = renderToStaticMarkup(
45 <CustomSchemaUI name="body" as="body" generated={generated} />
46 );
47
48 expect(html).toContain('validate_credentials');
49 expect(html.match(/>Experimental<\/span>/g)).toHaveLength(1);
50 expect(html).toContain('Whether to validate the provided credentials');
51 expect(html).not.toContain('[EXPERIMENTAL]');
52 expect(html).toContain('title="Experimental: these APIs may change in future releases"');
53 });
54 });