feat: add payload.jobs.runByID (#9875)
This commit is contained in:
@@ -925,4 +925,44 @@ describe('Queues', () => {
|
||||
expect(allSimples.totalDocs).toBe(1)
|
||||
expect(allSimples.docs[0].title).toBe('externalWorkflow')
|
||||
})
|
||||
|
||||
it('ensure payload.jobs.runByID works and only runs the specified job', async () => {
|
||||
payload.config.jobs.deleteJobOnComplete = false
|
||||
|
||||
let lastJobID: string = null
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const job = await payload.jobs.queue({
|
||||
task: 'CreateSimple',
|
||||
input: {
|
||||
message: 'from single task',
|
||||
},
|
||||
})
|
||||
lastJobID = job.id
|
||||
}
|
||||
|
||||
await payload.jobs.runByID({
|
||||
id: lastJobID,
|
||||
})
|
||||
|
||||
const allSimples = await payload.find({
|
||||
collection: 'simple',
|
||||
limit: 100,
|
||||
})
|
||||
|
||||
expect(allSimples.totalDocs).toBe(1)
|
||||
expect(allSimples.docs[0].title).toBe('from single task')
|
||||
|
||||
const allCompletedJobs = await payload.find({
|
||||
collection: 'payload-jobs',
|
||||
limit: 100,
|
||||
where: {
|
||||
completedAt: {
|
||||
exists: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(allCompletedJobs.totalDocs).toBe(1)
|
||||
expect(allCompletedJobs.docs[0].id).toBe(lastJobID)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user