Skip to content

Commit b39df73

Browse files
Claudehotlong
andauthored
Add tests for agent and tool metadata visibility
Tests verify that: - 'agent' and 'tool' types appear in metadata types list - Built-in agents (data_chat, metadata_assistant) are queryable - Built-in tools (create_object, list_objects, query_records, etc.) are queryable Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/6dbd64f2-446d-4992-9adb-659a1283ec1b Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1f7550e commit b39df73

1 file changed

Lines changed: 60 additions & 5 deletions

File tree

apps/studio/test/verify-metadata.test.ts

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ describe('Metadata Service Integration', () => {
1818
const response: any = await client.meta.getItems('object');
1919
// Response after unwrap: { type: 'object', items: [...] }
2020
const objects = response.items || response.data || response;
21-
21+
2222
console.log('Fetched Objects:', objects.map((o: any) => o.name));
23-
23+
2424
expect(objects).toBeDefined();
2525
expect(Array.isArray(objects)).toBe(true);
2626
expect(objects.length).toBeGreaterThan(0);
27-
27+
2828
// Object name without namespace prefix (studio config has no namespace)
2929
const task = objects.find((o: any) => o.name === 'task');
3030
expect(task).toBeDefined();
@@ -35,15 +35,70 @@ describe('Metadata Service Integration', () => {
3535
// Use short name 'task' which resolves via registry fallback
3636
const response: any = await client.meta.getItem('object', 'task');
3737
const def = response.data || response;
38-
38+
3939
expect(def).toBeDefined();
4040
expect(def.name).toBe('task');
4141
expect(def.fields).toBeDefined();
42-
42+
4343
// Check if fields are parsed correctly (client might return Map or Object depending on version)
4444
// Adjust expectation based on ObjectStackClient behavior
4545
// Assuming it matches the raw JSON or a wrapper
4646
console.log('Fields:', def.fields);
4747
// expect(Object.keys(def.fields).length).toBeGreaterThan(0);
4848
});
49+
50+
it('should include "agent" in metadata types', async () => {
51+
const { client } = env;
52+
const response: any = await client.meta.getTypes();
53+
const types = response.types || response.data || response;
54+
55+
expect(types).toBeDefined();
56+
expect(Array.isArray(types)).toBe(true);
57+
expect(types).toContain('agent');
58+
});
59+
60+
it('should include "tool" in metadata types', async () => {
61+
const { client } = env;
62+
const response: any = await client.meta.getTypes();
63+
const types = response.types || response.data || response;
64+
65+
expect(types).toBeDefined();
66+
expect(Array.isArray(types)).toBe(true);
67+
expect(types).toContain('tool');
68+
});
69+
70+
it('should list registered agents via client.meta.getItems("agent")', async () => {
71+
const { client } = env;
72+
const response: any = await client.meta.getItems('agent');
73+
const agents = response.items || response.data || response;
74+
75+
console.log('Fetched Agents:', agents?.map?.((a: any) => a.name) || agents);
76+
77+
expect(agents).toBeDefined();
78+
expect(Array.isArray(agents)).toBe(true);
79+
expect(agents.length).toBeGreaterThan(0);
80+
81+
// Check for built-in agents
82+
const agentNames = agents.map((a: any) => a.name);
83+
expect(agentNames).toContain('data_chat');
84+
expect(agentNames).toContain('metadata_assistant');
85+
});
86+
87+
it('should list registered tools via client.meta.getItems("tool")', async () => {
88+
const { client } = env;
89+
const response: any = await client.meta.getItems('tool');
90+
const tools = response.items || response.data || response;
91+
92+
console.log('Fetched Tools:', tools?.map?.((t: any) => t.name) || tools);
93+
94+
expect(tools).toBeDefined();
95+
expect(Array.isArray(tools)).toBe(true);
96+
expect(tools.length).toBeGreaterThan(0);
97+
98+
// Check for some built-in tools
99+
const toolNames = tools.map((t: any) => t.name);
100+
expect(toolNames).toContain('create_object');
101+
expect(toolNames).toContain('list_objects');
102+
expect(toolNames).toContain('query_records');
103+
});
49104
});

0 commit comments

Comments
 (0)