Merge branch 'main' into next

This commit is contained in:
nocobase[bot]
2025-08-26 02:47:16 +00:00
5 changed files with 55 additions and 4 deletions
@@ -152,7 +152,7 @@ export default class extends Instruction {
},
{
value: 'allSettled',
label: `{{t('Run all branch (ignore failures)', { ns: "${NAMESPACE}" })}}`,
label: `{{t('Run all branches (ignore failures)', { ns: "${NAMESPACE}" })}}`,
tooltip: `{{t('Always continue after all branches end, regardless of success or failure.', { ns: "${NAMESPACE}" })}}`,
},
],
@@ -6,7 +6,7 @@
"All succeeded": "全部成功",
"Any succeeded": "任意成功",
"Any succeeded or failed": "任意成功或失败",
"Run all branch (ignore failures)": "全部执行(忽略失败)",
"Run all branches (ignore failures)": "全部执行(忽略失败)",
"Continue after all branches succeeded": "全部分支都成功后才能继续",
"Continue after any branch succeeded": "任意分支成功后就继续",
"Continue after any branch succeeded, or exit after any branch failed.": "任意分支成功就继续流程,或者任意分支失败就退出流程。",
@@ -66,7 +66,7 @@ const Modes = {
return true;
},
getStatus(result) {
if (result.some((status) => status === JOB_STATUS.PENDING)) {
if (result.some((status) => !status)) {
return JOB_STATUS.PENDING;
}
return JOB_STATUS.RESOLVED;
@@ -329,6 +329,57 @@ describe('workflow > instructions > parallel', () => {
expect(jobs.find((item) => item.nodeId === n2.id).status).toBe(JOB_STATUS.RESOLVED);
expect(jobs.find((item) => item.nodeId === n3.id).status).toBe(JOB_STATUS.ERROR);
});
it('wait till all done', async () => {
const n1 = await workflow.createNode({
type: 'parallel',
config: {
mode: 'allSettled',
},
});
const n2 = await workflow.createNode({
type: 'echo',
upstreamId: n1.id,
branchIndex: 0,
});
const n3 = await workflow.createNode({
type: 'asyncResume',
config: {
duration: 500,
},
upstreamId: n1.id,
branchIndex: 1,
});
const n4 = await workflow.createNode({
type: 'echo',
upstreamId: n3.id,
});
await n3.setDownstream(n4);
const post = await PostRepo.create({ values: { title: 't1' } });
await sleep(300);
const [e1] = await workflow.getExecutions();
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
const j1s = await e1.getJobs({ order: [['id', 'ASC']] });
expect(j1s.length).toBe(3);
expect(j1s.find((item) => item.nodeId === n1.id).status).toBe(JOB_STATUS.PENDING);
expect(j1s.find((item) => item.nodeId === n1.id).result).toEqual([JOB_STATUS.RESOLVED, null]);
expect(j1s.find((item) => item.nodeId === n2.id).status).toBe(JOB_STATUS.RESOLVED);
expect(j1s.find((item) => item.nodeId === n3.id).status).toBe(JOB_STATUS.PENDING);
await sleep(300);
const [e2] = await workflow.getExecutions();
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
const j2s = await e2.getJobs({ order: [['id', 'ASC']] });
expect(j2s.length).toBe(4);
expect(j2s.find((item) => item.nodeId === n1.id).status).toBe(JOB_STATUS.RESOLVED);
expect(j2s.find((item) => item.nodeId === n2.id).status).toBe(JOB_STATUS.RESOLVED);
expect(j2s.find((item) => item.nodeId === n3.id).status).toBe(JOB_STATUS.RESOLVED);
expect(j2s.find((item) => item.nodeId === n4.id).status).toBe(JOB_STATUS.RESOLVED);
});
});
describe('branch and join', () => {
@@ -100,7 +100,7 @@ export default {
});
processor.options.plugin.resume(job);
}, 100);
}, node.config.duration ?? 100);
return null;
},