Skip to content
Merged
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
@@ -0,0 +1,56 @@
import { createMockApiClient } from './test-utils/mock-api-client';
import { CreateBoardTool } from './create-board-tool';
import { BoardKind } from '../../../monday-graphql/generated/graphql/graphql';

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

beforeEach(() => {
mocks = createMockApiClient();
jest.clearAllMocks();
});

const successfulResponse = {
create_board: {
id: '123456',
name: 'Test Board',
url: 'https://monday.com/boards/123456',
},
};

it('includes boardOwnerIds in variables when provided', async () => {
mocks.setResponse(successfulResponse);
const tool = new CreateBoardTool(mocks.mockApiClient);

await tool.execute({
boardName: 'Test Board',
boardKind: BoardKind.Public,
boardOwnerIds: ['111', '222'],
});

expect(mocks.getMockRequest()).toHaveBeenCalledWith(expect.stringContaining('mutation createBoard'), {
boardName: 'Test Board',
boardKind: BoardKind.Public,
boardDescription: undefined,
workspaceId: undefined,
boardOwnerIds: ['111', '222'],
});
});

it('does not include boardOwnerIds in variables when not provided', async () => {
mocks.setResponse(successfulResponse);
const tool = new CreateBoardTool(mocks.mockApiClient);

await tool.execute({
boardName: 'Test Board',
boardKind: BoardKind.Public,
});

expect(mocks.getMockRequest()).toHaveBeenCalledWith(expect.stringContaining('mutation createBoard'), {
boardName: 'Test Board',
boardKind: BoardKind.Public,
boardDescription: undefined,
workspaceId: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const createBoardToolSchema = {
boardKind: z.nativeEnum(BoardKind).default(BoardKind.Public).describe('The kind of board to create'),
boardDescription: z.string().optional().describe('The description of the board to create'),
workspaceId: z.string().optional().describe('The ID of the workspace to create the board in'),
boardOwnerIds: z.array(z.string()).optional().describe('Optional list of user IDs to set as board owners'),
};

export class CreateBoardTool extends BaseMondayApiTool<typeof createBoardToolSchema, never> {
Expand All @@ -39,6 +40,7 @@ export class CreateBoardTool extends BaseMondayApiTool<typeof createBoardToolSch
boardKind: input.boardKind,
boardDescription: input.boardDescription,
workspaceId: input.workspaceId,
...(input.boardOwnerIds !== undefined ? { boardOwnerIds: input.boardOwnerIds } : {}),
};

const res = await this.mondayApi.request<CreateBoardMutation>(createBoard, variables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12249,6 +12249,7 @@ export type CreateBoardMutationVariables = Exact<{
boardName: Scalars['String']['input'];
boardDescription?: InputMaybe<Scalars['String']['input']>;
workspaceId?: InputMaybe<Scalars['ID']['input']>;
boardOwnerIds?: InputMaybe<Array<Scalars['ID']['input']> | Scalars['ID']['input']>;
}>;


Expand Down
9 changes: 8 additions & 1 deletion packages/agent-toolkit/src/monday-graphql/queries.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@ export const moveItemToGroup = gql`
`;

export const createBoard = gql`
mutation createBoard($boardKind: BoardKind!, $boardName: String!, $boardDescription: String, $workspaceId: ID) {
mutation createBoard(
$boardKind: BoardKind!
$boardName: String!
$boardDescription: String
$workspaceId: ID
$boardOwnerIds: [ID!]
) {
create_board(
board_kind: $boardKind
board_name: $boardName
description: $boardDescription
workspace_id: $workspaceId
board_owner_ids: $boardOwnerIds
empty: true
) {
id
Expand Down
Loading