fix(Notion Node): Block with text results in a body validation error (#8622)

This commit is contained in:
Michael Kret 2024-02-14 13:05:06 +02:00 committed by GitHub
parent f5274302f8
commit 6bc1c3d7a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 1 deletions

View file

@ -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) : {}),
},
});
}

View file

@ -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',
},
},
],
},
},
]);
});
});