fix(plugin-workflow-manual): allow pass node when no assignee (#4139)

This commit is contained in:
Junyi 2024-04-23 13:42:58 +08:00 committed by GitHub
parent b6940596f5
commit 8a2bcd9a74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -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(

View File

@ -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({