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
Expand Up @@ -395,6 +395,20 @@ describe('UpdateDocTool', () => {
expect(result.content[0].text).toContain('[FAILED] create_block');
});

it('throws when create_doc_blocks only contains null entries', async () => {
jest.spyOn(mocks, 'mockRequest').mockImplementation((query: string) => {
if (query.includes('mutation createDocBlocks')) return Promise.resolve({ create_doc_blocks: [null] });
return Promise.resolve({});
});

const result = await callToolByNameRawAsync('update_doc', {
doc_id: 'doc_123',
operations: [{ operation_type: 'create_block', block: { block_type: 'divider' } }],
});

expect(result.content[0].text).toContain('[FAILED] create_block');
});

// ─── delete_block ────────────────────────────────────────────────────────

it('executes delete_block operation', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ COMMENTS:
};
const res = await this.mondayApi.request<CreateDocBlocksMutation>(createDocBlocks, variables);

const created = res?.create_doc_blocks;
if (!created || created.length === 0) {
const created = res?.create_doc_blocks?.filter((block): block is NonNullable<typeof block> => block != null) || [];
if (created.length === 0) {
throw new Error('No blocks returned from create_doc_blocks');
}
const createdIds = created.map((b) => b.id).join(', ');
Expand Down