mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 15:16:31 +00:00
fix(plugin-workflow): fix end logic when success (#3453)
This commit is contained in:
parent
2fc1604d78
commit
ad065431fb
@ -200,8 +200,7 @@ const useStyles = createStyles(({ css, token }) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 4em;
|
height: 6em;
|
||||||
padding: 1em 0;
|
|
||||||
border-left: 1px dashed ${token.colorBgLayout};
|
border-left: 1px dashed ${token.colorBgLayout};
|
||||||
|
|
||||||
.anticon {
|
.anticon {
|
||||||
|
@ -35,12 +35,20 @@ describe('workflow > instructions > end', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const n2 = await workflow.createNode({
|
||||||
|
type: 'echo',
|
||||||
|
upstreamId: n1.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await n1.setDownstream(n2);
|
||||||
|
|
||||||
await plugin.trigger(workflow, {});
|
await plugin.trigger(workflow, {});
|
||||||
|
|
||||||
const [execution] = await workflow.getExecutions();
|
const [execution] = await workflow.getExecutions();
|
||||||
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||||
const [job] = await execution.getJobs();
|
const jobs = await execution.getJobs();
|
||||||
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
expect(jobs.length).toBe(1);
|
||||||
|
expect(jobs[0].status).toBe(JOB_STATUS.RESOLVED);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('failed', async () => {
|
it('failed', async () => {
|
||||||
@ -51,12 +59,20 @@ describe('workflow > instructions > end', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const n2 = await workflow.createNode({
|
||||||
|
type: 'echo',
|
||||||
|
upstreamId: n1.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await n1.setDownstream(n2);
|
||||||
|
|
||||||
await plugin.trigger(workflow, {});
|
await plugin.trigger(workflow, {});
|
||||||
|
|
||||||
const [execution] = await workflow.getExecutions();
|
const [execution] = await workflow.getExecutions();
|
||||||
expect(execution.status).toBe(EXECUTION_STATUS.FAILED);
|
expect(execution.status).toBe(EXECUTION_STATUS.FAILED);
|
||||||
const [job] = await execution.getJobs();
|
const jobs = await execution.getJobs();
|
||||||
expect(job.status).toBe(JOB_STATUS.FAILED);
|
expect(jobs.length).toBe(1);
|
||||||
|
expect(jobs[0].status).toBe(JOB_STATUS.FAILED);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -9,9 +9,14 @@ interface Config {
|
|||||||
|
|
||||||
export default class extends Instruction {
|
export default class extends Instruction {
|
||||||
async run(node: FlowNodeModel, prevJob, processor: Processor) {
|
async run(node: FlowNodeModel, prevJob, processor: Processor) {
|
||||||
const { endStatus } = <Config>node.config;
|
const { endStatus = JOB_STATUS.RESOLVED } = <Config>node.config;
|
||||||
return {
|
await processor.saveJob({
|
||||||
status: endStatus ?? JOB_STATUS.RESOLVED,
|
status: endStatus,
|
||||||
};
|
nodeId: node.id,
|
||||||
|
nodeKey: node.key,
|
||||||
|
upstreamId: prevJob?.id ?? null,
|
||||||
|
});
|
||||||
|
|
||||||
|
return processor.exit(endStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user