fix(plugin-workflow): fix end logic when success (#3453)

This commit is contained in:
Junyi 2024-01-29 14:04:37 +08:00 committed by GitHub
parent 2fc1604d78
commit ad065431fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 10 deletions

View File

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

View File

@ -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);
}); });
}); });
}); });

View File

@ -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);
} }
} }