@@ -57,6 +57,17 @@ describe('@payloadcms/sdk', () => {
5757 await payload . delete ( { collection : 'posts' , where : { id : { in : ids } } } )
5858 } )
5959
60+ it ( 'should execute find with disableErrors: true' , async ( ) => {
61+ const result = await sdk . find ( {
62+ collection : 'posts' ,
63+ where : { id : { equals : 'non-existent-id' } } ,
64+ disableErrors : true ,
65+ } )
66+
67+ expect ( result . docs ) . toHaveLength ( 0 )
68+ expect ( result . totalDocs ) . toBe ( 0 )
69+ } )
70+
6071 it ( 'should execute findVersions' , async ( ) => {
6172 const result = await sdk . findVersions ( {
6273 collection : 'posts' ,
@@ -93,6 +104,16 @@ describe('@payloadcms/sdk', () => {
93104 expect ( result . id ) . toBe ( version . id )
94105 } )
95106
107+ it ( 'should execute findVersionByID with disableErrors: true' , async ( ) => {
108+ const result = await sdk . findVersionByID ( {
109+ collection : 'posts' ,
110+ id : 'non-existent-version-id' ,
111+ disableErrors : true ,
112+ } )
113+
114+ expect ( result ) . toBeNull ( )
115+ } )
116+
96117 it ( 'should execute create' , async ( ) => {
97118 const result = await sdk . create ( { collection : 'posts' , data : { text : 'text' } } )
98119
@@ -113,6 +134,15 @@ describe('@payloadcms/sdk', () => {
113134 expect ( result . totalDocs ) . toBe ( 1 )
114135 } )
115136
137+ it ( 'should execute count with disableErrors: true' , async ( ) => {
138+ const result = await sdk . count ( {
139+ collection : 'posts' ,
140+ where : { id : { equals : 'non-existent-id' } } ,
141+ disableErrors : true ,
142+ } )
143+ expect ( result . totalDocs ) . toBe ( 0 )
144+ } )
145+
116146 it ( 'should execute update (by ID)' , async ( ) => {
117147 const result = await sdk . update ( {
118148 collection : 'posts' ,
@@ -195,6 +225,14 @@ describe('@payloadcms/sdk', () => {
195225 expect ( result . text ) . toBe ( 'some-global' )
196226 } )
197227
228+ it ( 'should execute findGlobal with disableErrors: true' , async ( ) => {
229+ const result = await sdk . findGlobal ( {
230+ slug : 'non-existent-global' ,
231+ disableErrors : true ,
232+ } )
233+ expect ( result ) . toBeNull ( )
234+ } )
235+
198236 it ( 'should execute findGlobalVersions' , async ( ) => {
199237 const result = await sdk . findGlobalVersions ( {
200238 slug : 'global' ,
@@ -215,6 +253,16 @@ describe('@payloadcms/sdk', () => {
215253 expect ( result . id ) . toBe ( version . id )
216254 } )
217255
256+ it ( 'should execute findGlobalVersionByID with disableErrors: true' , async ( ) => {
257+ const result = await sdk . findGlobalVersionByID ( {
258+ id : 'non-existent-version-id' ,
259+ slug : 'global' ,
260+ disableErrors : true ,
261+ } )
262+
263+ expect ( result ) . toBeNull ( )
264+ } )
265+
218266 it ( 'should execute updateGlobal' , async ( ) => {
219267 const result = await sdk . updateGlobal ( { slug : 'global' , data : { text : 'some-updated-global' } } )
220268 expect ( result . text ) . toBe ( 'some-updated-global' )
0 commit comments