@@ -1792,6 +1792,51 @@ describe('Versions', () => {
17921792 expect ( retrieved . _status ) . toStrictEqual ( 'published' )
17931793 } )
17941794
1795+ it ( 'should restrict scheduled publish based on user' , async ( ) => {
1796+ const draft = await payload . create ( {
1797+ collection : draftCollectionSlug ,
1798+ data : {
1799+ title : 'my doc to publish in the future' ,
1800+ description : 'hello' ,
1801+ restrictedToUpdate : true ,
1802+ } ,
1803+ draft : true ,
1804+ } )
1805+
1806+ expect ( draft . _status ) . toStrictEqual ( 'draft' )
1807+
1808+ const currentDate = new Date ( )
1809+
1810+ const user = (
1811+ await payload . find ( { collection : 'users' , where : { email : { equals : devUser . email } } } )
1812+ ) . docs [ 0 ]
1813+
1814+ await payload . jobs . queue ( {
1815+ task : 'schedulePublish' ,
1816+ waitUntil : new Date ( currentDate . getTime ( ) + 3000 ) ,
1817+ input : {
1818+ doc : {
1819+ relationTo : draftCollectionSlug ,
1820+ value : draft . id ,
1821+ } ,
1822+ user : user . id ,
1823+ } ,
1824+ } )
1825+
1826+ await wait ( 4000 )
1827+
1828+ const res = await payload . jobs . run ( )
1829+
1830+ expect ( res . jobStatus [ Object . keys ( res . jobStatus ) [ 0 ] ] . status ) . toBe ( 'error-reached-max-retries' )
1831+
1832+ const retrieved = await payload . findByID ( {
1833+ collection : draftCollectionSlug ,
1834+ id : draft . id ,
1835+ } )
1836+
1837+ expect ( retrieved . _status ) . toStrictEqual ( 'draft' )
1838+ } )
1839+
17951840 it ( 'should allow collection scheduled unpublish' , async ( ) => {
17961841 const published = await payload . create ( {
17971842 collection : draftCollectionSlug ,
0 commit comments