Skip to content

Commit 15c1741

Browse files
committed
fix integration tests
1 parent 1a03d08 commit 15c1741

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/tools/helpers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Ajv } from 'ajv';
2+
import { ApifyApiError } from 'apify-client';
23
import { z } from 'zod';
34
import zodToJsonSchema from 'zod-to-json-schema';
45

6+
import log from '@apify/log';
7+
58
import { HelperTools } from '../const.js';
69
import type { InternalTool, ToolEntry } from '../types';
710
import { getActorsAsTools } from './actor.js';
811
import { actorNameToToolName } from './utils.js';
9-
import { ApifyApiError } from 'apify-client';
10-
import log from '@apify/log';
1112

1213
const ajv = new Ajv({ coerceTypes: 'array', strict: false });
1314

tests/integration/actor.server-sse.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ createIntegrationTestsSuite({
2121
getActorsMcpServer: () => mcpServer,
2222
createClientFn: async (options) => await createMcpSseClient(mcpUrl, options),
2323
beforeAllFn: async () => {
24-
mcpServer = new ActorsMcpServer({ enableAddingActors: false });
24+
mcpServer = new ActorsMcpServer({ enableAddingActors: false, enableDefaultActors: false });
2525
log.setLevel(log.LEVELS.OFF);
2626

2727
// Create an express app using the proper server setup

tests/integration/actor.server-streamable.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ createIntegrationTestsSuite({
2323
beforeAllFn: async () => {
2424
log.setLevel(log.LEVELS.OFF);
2525
// Create an express app using the proper server setup
26-
mcpServer = new ActorsMcpServer({ enableAddingActors: false });
26+
mcpServer = new ActorsMcpServer({ enableAddingActors: false, enableDefaultActors: false });
2727
app = createExpressApp(httpServerHost, mcpServer);
2828

2929
// Start a test server

tests/integration/suite.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ export function createIntegrationTestsSuite(
103103
await client.close();
104104
});
105105

106-
// TODO: This test is not working as there is a problem with server reset, which loads default Actors
107-
it.runIf(false)('should list all default tools and two loaded Actors', async () => {
106+
it('should list all default tools and two loaded Actors', async () => {
108107
const actors = ['apify/website-content-crawler', 'apify/instagram-scraper'];
109108
const client = await createClientFn({ actors, enableAddingActors: false });
110109
const names = getToolNames(await client.listTools());
@@ -210,25 +209,27 @@ export function createIntegrationTestsSuite(
210209
});
211210

212211
it.runIf(getActorsMcpServer)('should reset and restore tool state with default tools', async () => {
213-
const client = await createClientFn({ enableAddingActors: true });
212+
const firstClient = await createClientFn({ enableAddingActors: true });
214213
const actorsMCPServer = getActorsMcpServer!();
215214
const numberOfTools = defaultTools.length + addRemoveTools.length + defaults.actors.length;
216215
const toolList = actorsMCPServer.listAllToolNames();
217216
expect(toolList.length).toEqual(numberOfTools);
218217
// Add a new Actor
219-
await addActor(client, ACTOR_PYTHON_EXAMPLE);
218+
await addActor(firstClient, ACTOR_PYTHON_EXAMPLE);
220219

221220
// Store the tool name list
222221
const toolListWithActor = actorsMCPServer.listAllToolNames();
223222
expect(toolListWithActor.length).toEqual(numberOfTools + 1); // + 1 for the added Actor
223+
await firstClient.close();
224224

225225
// Remove all tools
226-
// TODO: The reset functions sets the enableAddingActors to false, which is not expected
227-
// await actorsMCPServer.reset();
228-
// const toolListAfterReset = actorsMCPServer.listAllToolNames();
229-
// expect(toolListAfterReset.length).toEqual(numberOfTools);
230-
231-
await client.close();
226+
await actorsMCPServer.reset();
227+
// We connect second client so that the default tools are loaded
228+
// if no specific list of Actors is provided
229+
const secondClient = await createClientFn({ enableAddingActors: true });
230+
const toolListAfterReset = actorsMCPServer.listAllToolNames();
231+
expect(toolListAfterReset.length).toEqual(numberOfTools);
232+
await secondClient.close();
232233
});
233234

234235
it.runIf(getActorsMcpServer)('should notify tools changed handler on tool modifications', async () => {

0 commit comments

Comments
 (0)