Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
import { MondayAgentToolkit } from 'src/mcp/toolkit';
import { callToolByNameRawAsync, createMockApiClient } from '../test-utils/mock-api-client';
import { organizeWorkspaceInfoHierarchy } from './helpers';
import { WorkspaceKind, State } from '../../../../monday-graphql/generated/graphql/graphql';

describe('WorkspaceInfoTool', () => {
let mocks: ReturnType<typeof createMockApiClient>;

beforeEach(() => {
jest.clearAllMocks();
mocks = createMockApiClient();
jest.spyOn(MondayAgentToolkit.prototype as any, 'createApiClient').mockReturnValue(mocks.mockApiClient);
});

afterEach(() => {
jest.restoreAllMocks();
});

describe('executeInternal', () => {
it('should return a no-workspace message when the API returns only null workspaces', async () => {
mocks.setResponses([
{
workspaces: [null],
boards: [],
docs: [],
folders: [],
},
]);

const result = await callToolByNameRawAsync('workspace_info', {
workspace_id: 123,
});

expect(result.content[0].text).toBe('No workspace found with ID 123');
expect(mocks.getMockRequest()).toHaveBeenCalledTimes(1);
});
});

describe('organizeWorkspaceInfoHierarchy', () => {
it('should organize workspace data with proper hierarchy', () => {
const rawResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class WorkspaceInfoTool extends BaseMondayApiTool<typeof workspaceInfoToo

const res = await this.mondayApi.request<GetWorkspaceInfoQuery>(getWorkspaceInfo, variables);

if (!res.workspaces || res.workspaces.length === 0) {
if (!res.workspaces?.some((workspace) => workspace != null)) {
return {
content: `No workspace found with ID ${input.workspace_id}`,
};
Expand Down