mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:35:20 +00:00
fix(plugin-workflow): fix request node error in loop (#2254)
This commit is contained in:
parent
3510531182
commit
5540a582f0
@ -213,5 +213,35 @@ describe('workflow > instructions > request', () => {
|
||||
expect(job.status).toEqual(JOB_STATUS.RESOLVED);
|
||||
expect(job.result.data).toEqual({ title });
|
||||
});
|
||||
|
||||
it('request inside loop',async () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'loop',
|
||||
config: {
|
||||
target: 2,
|
||||
},
|
||||
});
|
||||
|
||||
const n2 = await workflow.createNode({
|
||||
type: 'request',
|
||||
upstreamId: n1.id,
|
||||
branchIndex: 0,
|
||||
config: {
|
||||
url: URL_DATA,
|
||||
method: 'GET',
|
||||
}
|
||||
});
|
||||
|
||||
await PostRepo.create({ values: { title: 't1' } });
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const [execution] = await workflow.getExecutions();
|
||||
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
||||
const jobs = await execution.getJobs({ order: [['id', 'ASC']] });
|
||||
expect(jobs.length).toBe(3);
|
||||
expect(jobs.map(item => item.status)).toEqual(Array(3).fill(JOB_STATUS.RESOLVED));
|
||||
expect(jobs[0].result).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -45,10 +45,11 @@ async function request(config) {
|
||||
export default class implements Instruction {
|
||||
constructor(public plugin) {}
|
||||
|
||||
async run(node: FlowNodeModel, input, processor: Processor) {
|
||||
async run(node: FlowNodeModel, prevJob, processor: Processor) {
|
||||
const job = await processor.saveJob({
|
||||
status: JOB_STATUS.PENDING,
|
||||
nodeId: node.id,
|
||||
upstreamId: prevJob?.id ?? null,
|
||||
});
|
||||
|
||||
const config = processor.getParsedValue(node.config, node) as RequestConfig;
|
||||
|
Loading…
Reference in New Issue
Block a user