Skip to content

Commit 47e93f2

Browse files
committed
more spec new spec complience tests
1 parent 3869388 commit 47e93f2

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

tests/integration/suite.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ export function createIntegrationTestsSuite(
9797
await client.close();
9898
});
9999

100+
it('should match spec default: actors,docs,apify/rag-web-browser when no params provided', async () => {
101+
const client = await createClientFn();
102+
const tools = await client.listTools();
103+
const names = getToolNames(tools);
104+
105+
// Should be equivalent to tools=actors,docs,apify/rag-web-browser
106+
const expectedActorsTools = ['fetch-actor-details', 'search-actors', 'call-actor'];
107+
const expectedDocsTools = ['search-apify-docs', 'fetch-apify-docs'];
108+
const expectedActors = ['apify-slash-rag-web-browser'];
109+
110+
const expectedTotal = expectedActorsTools.concat(expectedDocsTools, expectedActors);
111+
expect(names).toHaveLength(expectedTotal.length);
112+
113+
expectedActorsTools.forEach(tool => expect(names).toContain(tool));
114+
expectedDocsTools.forEach(tool => expect(names).toContain(tool));
115+
expectedActors.forEach(actor => expect(names).toContain(actor));
116+
117+
await client.close();
118+
});
119+
100120
it('should list only add-actor when enableAddingActors is true and no tools/actors are specified', async () => {
101121
const client = await createClientFn({ enableAddingActors: true });
102122
const names = getToolNames(await client.listTools());
@@ -164,6 +184,22 @@ export function createIntegrationTestsSuite(
164184
await client.close();
165185
});
166186

187+
it('should treat selectors with slashes as Actor names', async () => {
188+
const client = await createClientFn({
189+
tools: ['docs', 'apify/python-example']
190+
});
191+
const names = getToolNames(await client.listTools());
192+
193+
// Should include docs category
194+
expect(names).toContain('search-apify-docs');
195+
expect(names).toContain('fetch-apify-docs');
196+
197+
// Should include actor (if it exists/is valid)
198+
expect(names).toContain('apify-slash-python-example');
199+
200+
await client.close();
201+
});
202+
167203
it('should merge actors param into tools selectors (backward compatibility)', async () => {
168204
const actors = ['apify/python-example'];
169205
const categories = ['docs'] as ToolCategory[];
@@ -177,6 +213,25 @@ export function createIntegrationTestsSuite(
177213
await client.close();
178214
});
179215

216+
it('should handle mixed categories and specific tools in tools param', async () => {
217+
const client = await createClientFn({
218+
tools: ['docs', 'fetch-actor-details', 'add-actor']
219+
});
220+
const names = getToolNames(await client.listTools());
221+
222+
// Should include: docs category + specific tools
223+
expect(names).toContain('search-apify-docs'); // from docs category
224+
expect(names).toContain('fetch-apify-docs'); // from docs category
225+
expect(names).toContain('fetch-actor-details'); // specific tool
226+
expect(names).toContain('add-actor'); // specific tool
227+
228+
// Should NOT include other actors category tools
229+
expect(names).not.toContain('search-actors');
230+
expect(names).not.toContain('call-actor');
231+
232+
await client.close();
233+
});
234+
180235
it('should load only docs tools', async () => {
181236
const categories = ['docs'] as ToolCategory[];
182237
const client = await createClientFn({ tools: categories, actors: [] });
@@ -269,6 +324,38 @@ export function createIntegrationTestsSuite(
269324
await client.close();
270325
});
271326

327+
it('should enforce two-step process for call-actor tool', async () => {
328+
const client = await createClientFn({ tools: ['actors'] });
329+
330+
// Step 1: Get info (should work)
331+
const infoResult = await client.callTool({
332+
name: HelperTools.ACTOR_CALL,
333+
arguments: {
334+
actor: ACTOR_PYTHON_EXAMPLE,
335+
step: 'info'
336+
}
337+
});
338+
339+
expect(infoResult.content).toBeDefined();
340+
const content = infoResult.content as { text: string }[];
341+
expect(content.some(item => item.text.includes('Actor card'))).toBe(true);
342+
expect(content.some(item => item.text.includes('Input Schema'))).toBe(true);
343+
344+
// Step 2: Call with proper input (should work)
345+
const callResult = await client.callTool({
346+
name: HelperTools.ACTOR_CALL,
347+
arguments: {
348+
actor: ACTOR_PYTHON_EXAMPLE,
349+
step: 'call',
350+
input: { first_number: 1, second_number: 2 }
351+
}
352+
});
353+
354+
expect(callResult.content).toBeDefined();
355+
356+
await client.close();
357+
});
358+
272359
it('should find Actors in store search', async () => {
273360
const query = 'python-example';
274361
const client = await createClientFn({

0 commit comments

Comments
 (0)