@@ -1827,6 +1827,51 @@ describe('Versions', () => {
18271827 expect ( draftFindResults . docs [ 0 ] . title ) . toStrictEqual ( updatedTitle2 )
18281828 } )
18291829
1830+ it ( 'should be able to query blockType fields with contains and draft=true' , async ( ) => {
1831+ const matchingDraft = await createDraftDocument ( {
1832+ blocksField : [
1833+ {
1834+ blockType : 'block' ,
1835+ localized : null ,
1836+ text : 'Block' ,
1837+ } ,
1838+ ] ,
1839+ collection : draftCollectionSlug ,
1840+ payload,
1841+ title : 'draft block type query' ,
1842+ } )
1843+
1844+ await createDraftDocument ( {
1845+ blocksField : [ ] ,
1846+ collection : draftCollectionSlug ,
1847+ payload,
1848+ title : 'draft block type query 2' ,
1849+ } )
1850+
1851+ const query = {
1852+ 'blocksField.blockType' : {
1853+ contains : 'block' ,
1854+ } ,
1855+ }
1856+
1857+ const publishedFindResults = await payload . find ( {
1858+ collection : draftCollectionSlug ,
1859+ where : query ,
1860+ } )
1861+
1862+ expect ( publishedFindResults . docs ) . toHaveLength ( 1 )
1863+ expect ( publishedFindResults . docs . find ( ( { id } ) => id === matchingDraft . id ) ) . toBeDefined ( )
1864+
1865+ const draftFindResults = await payload . find ( {
1866+ collection : draftCollectionSlug ,
1867+ draft : true ,
1868+ where : query ,
1869+ } )
1870+
1871+ expect ( draftFindResults . docs ) . toHaveLength ( 1 )
1872+ expect ( draftFindResults . docs . find ( ( { id } ) => id === matchingDraft . id ) ) . toBeDefined ( )
1873+ } )
1874+
18301875 it ( "should not be able to query old drafts that don't match with draft=true" , async ( ) => {
18311876 const draftFindResults = await payload . find ( {
18321877 collection : draftCollectionSlug ,
0 commit comments