Skip to content

Commit

Permalink
fix(Notion Node): Block with text results in a body validation error (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency authored and despairblue committed Feb 16, 2024
1 parent 122c914 commit 8e49f65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Notion/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export function formatBlocks(blocks: IDataObject[]) {
...(block.type === 'to_do' ? { checked: block.checked } : {}),
...(block.type === 'image' ? { type: 'external', external: { url: block.url } } : {}),
// prettier-ignore,
...(!['to_do', 'image'].includes(block.type as string) ? getTextBlocks(block) : {}),
...(!['image'].includes(block.type as string) ? getTextBlocks(block) : {}),
},
});
}
Expand Down
33 changes: 33 additions & 0 deletions packages/nodes-base/nodes/Notion/test/GenericFunctions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { formatBlocks } from '../GenericFunctions';

describe('Test NotionV2, formatBlocks', () => {
it('should format to_do block', () => {
const blocks = [
{
type: 'to_do',
checked: false,
richText: false,
textContent: 'Testing',
},
];

const result = formatBlocks(blocks);

expect(result).toEqual([
{
object: 'block',
type: 'to_do',
to_do: {
checked: false,
text: [
{
text: {
content: 'Testing',
},
},
],
},
},
]);
});
});

0 comments on commit 8e49f65

Please sign in to comment.