diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/ManualInstruction.ts b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/ManualInstruction.ts index 2e654a280e..998ac5a8cb 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/ManualInstruction.ts +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/ManualInstruction.ts @@ -96,13 +96,17 @@ export default class extends Instruction { const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))]; const job = await processor.saveJob({ - status: JOB_STATUS.PENDING, + status: assignees.length ? JOB_STATUS.PENDING : JOB_STATUS.RESOLVED, result: mode ? [] : null, nodeId: node.id, nodeKey: node.key, upstreamId: prevJob?.id ?? null, }); + if (!assignees.length) { + return job; + } + // NOTE: batch create users jobs const UserJobModel = this.workflow.app.db.getModel('users_jobs'); await UserJobModel.bulkCreate( diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/__tests__/assignees.test.ts b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/__tests__/assignees.test.ts index b13de66ceb..d8b7015e18 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/__tests__/assignees.test.ts +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/__tests__/assignees.test.ts @@ -50,6 +50,32 @@ describe('workflow > instructions > manual > assignees', () => { afterEach(() => app.destroy()); + describe('no', () => { + it('empty assignees', async () => { + const n1 = await workflow.createNode({ + type: 'manual', + config: { + assignees: [], + forms: { + f1: { + actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }], + }, + }, + }, + }); + + const post = await PostRepo.create({ + values: { title: 't1', category: { title: 'c1' } }, + context: { state: { currentUser: users[0] } }, + }); + + await sleep(500); + + const [pending] = await workflow.getExecutions(); + expect(pending.status).toBe(EXECUTION_STATUS.RESOLVED); + }); + }); + describe('multiple', () => { it('assignees from nested array', async () => { const n1 = await workflow.createNode({