Merge pull request #888 from payloadcms/feat/allow-rich-text-querying

feat: allows querying on rich text content
This commit is contained in:
James Mikrut
2022-08-04 14:04:40 -04:00
committed by GitHub
2 changed files with 30 additions and 0 deletions

View File

@@ -232,4 +232,30 @@ describe('Fields', () => {
expect(blockFields.docs[0].blocks[2].subBlocks[1].text).toEqual(blocksFieldSeedData[2].subBlocks[1].text);
});
});
describe('richText', () => {
it('should allow querying on rich text content', async () => {
const emptyRichTextQuery = await payload.find({
collection: 'rich-text-fields',
where: {
'richText.children.text': {
like: 'doesnt exist',
},
},
});
expect(emptyRichTextQuery.docs).toHaveLength(0);
const workingRichTextQuery = await payload.find({
collection: 'rich-text-fields',
where: {
'richText.children.text': {
like: 'hello',
},
},
});
expect(workingRichTextQuery.docs).toHaveLength(1);
});
});
});