@nocobase/plugin-workflow-manual 0.20.0-alpha.15 → 0.20.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +4 -4
- package/dist/externalVersion.js +9 -9
- package/dist/server/forms/create.d.ts +2 -1
- package/dist/server/forms/create.js +4 -4
- package/dist/server/forms/update.d.ts +2 -1
- package/dist/server/forms/update.js +4 -4
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +4 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +88 -0
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +1 -1
- package/src/client/__e2e__/createRecordForm.test.ts +65 -0
- package/src/client/__e2e__/updateRecordForm.test.ts +53 -0
- package/src/client/__e2e__/workflowTodo.test.ts +9 -0
- package/src/client/instruction/SchemaConfig.tsx +3 -20
- package/src/client/instruction/forms/custom.tsx +32 -13
- package/src/client/instruction/index.tsx +1 -1
- package/src/server/__tests__/data-source.test.ts +223 -0
- package/src/server/__tests__/{instruction.test.ts → form.test.ts} +0 -510
- package/src/server/__tests__/mode.test.ts +561 -0
- package/src/server/forms/create.ts +10 -3
- package/src/server/forms/update.ts +10 -3
- package/src/server/migrations/20240325213145-fix-schema.ts +81 -0
- package/dist/client/instruction/DetailsBlockProvider.d.ts +0 -2
- package/src/client/instruction/DetailsBlockProvider.tsx +0 -87
|
@@ -333,516 +333,6 @@ describe('workflow > instructions > manual', () => {
|
|
|
333
333
|
});
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
describe('mode: 0 (single record)', () => {
|
|
337
|
-
it('the only user assigned could submit', async () => {
|
|
338
|
-
const n1 = await workflow.createNode({
|
|
339
|
-
type: 'manual',
|
|
340
|
-
config: {
|
|
341
|
-
assignees: [users[0].id],
|
|
342
|
-
forms: {
|
|
343
|
-
f1: {
|
|
344
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
351
|
-
|
|
352
|
-
await sleep(500);
|
|
353
|
-
|
|
354
|
-
const [pending] = await workflow.getExecutions();
|
|
355
|
-
expect(pending.status).toBe(EXECUTION_STATUS.STARTED);
|
|
356
|
-
const [j1] = await pending.getJobs();
|
|
357
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
358
|
-
|
|
359
|
-
const usersJobs = await UserJobModel.findAll();
|
|
360
|
-
expect(usersJobs.length).toBe(1);
|
|
361
|
-
expect(usersJobs[0].status).toBe(JOB_STATUS.PENDING);
|
|
362
|
-
expect(usersJobs[0].userId).toBe(users[0].id);
|
|
363
|
-
expect(usersJobs[0].jobId).toBe(j1.id);
|
|
364
|
-
|
|
365
|
-
const res1 = await agent.resource('users_jobs').submit({
|
|
366
|
-
filterByTk: usersJobs[0].id,
|
|
367
|
-
values: { result: { f1: {}, _: 'resolve' } },
|
|
368
|
-
});
|
|
369
|
-
expect(res1.status).toBe(401);
|
|
370
|
-
|
|
371
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
372
|
-
filterByTk: usersJobs[0].id,
|
|
373
|
-
values: {
|
|
374
|
-
result: { f1: {}, _: 'resolve' },
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
expect(res2.status).toBe(403);
|
|
378
|
-
|
|
379
|
-
const res3 = await userAgents[0].resource('users_jobs').submit({
|
|
380
|
-
filterByTk: usersJobs[0].id,
|
|
381
|
-
values: {
|
|
382
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
expect(res3.status).toBe(202);
|
|
386
|
-
|
|
387
|
-
await sleep(1000);
|
|
388
|
-
|
|
389
|
-
const [j2] = await pending.getJobs();
|
|
390
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
391
|
-
expect(j2.result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
392
|
-
|
|
393
|
-
const usersJobsAfter = await UserJobModel.findAll();
|
|
394
|
-
expect(usersJobsAfter.length).toBe(1);
|
|
395
|
-
expect(usersJobsAfter[0].status).toBe(JOB_STATUS.RESOLVED);
|
|
396
|
-
expect(usersJobsAfter[0].result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
397
|
-
|
|
398
|
-
const res4 = await userAgents[0].resource('users_jobs').submit({
|
|
399
|
-
filterByTk: usersJobs[0].id,
|
|
400
|
-
values: {
|
|
401
|
-
result: { f1: { a: 2 }, _: 'resolve' },
|
|
402
|
-
},
|
|
403
|
-
});
|
|
404
|
-
expect(res4.status).toBe(400);
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
it('any user assigned could submit', async () => {
|
|
408
|
-
const n1 = await workflow.createNode({
|
|
409
|
-
type: 'manual',
|
|
410
|
-
config: {
|
|
411
|
-
assignees: [users[0].id, users[1].id],
|
|
412
|
-
forms: {
|
|
413
|
-
f1: {
|
|
414
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
421
|
-
|
|
422
|
-
await sleep(500);
|
|
423
|
-
|
|
424
|
-
const [pending] = await workflow.getExecutions();
|
|
425
|
-
expect(pending.status).toBe(EXECUTION_STATUS.STARTED);
|
|
426
|
-
const [j1] = await pending.getJobs();
|
|
427
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
428
|
-
|
|
429
|
-
const usersJobs = await j1.getUsersJobs();
|
|
430
|
-
|
|
431
|
-
const res1 = await userAgents[1].resource('users_jobs').submit({
|
|
432
|
-
filterByTk: usersJobs.find((item) => item.userId === users[1].id).id,
|
|
433
|
-
values: {
|
|
434
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
435
|
-
},
|
|
436
|
-
});
|
|
437
|
-
expect(res1.status).toBe(202);
|
|
438
|
-
|
|
439
|
-
await sleep(1000);
|
|
440
|
-
|
|
441
|
-
const [j2] = await pending.getJobs();
|
|
442
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
443
|
-
expect(j2.result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
444
|
-
|
|
445
|
-
const res2 = await userAgents[0].resource('users_jobs').submit({
|
|
446
|
-
filterByTk: usersJobs.find((item) => item.userId === users[0].id).id,
|
|
447
|
-
values: {
|
|
448
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
449
|
-
},
|
|
450
|
-
});
|
|
451
|
-
expect(res2.status).toBe(400);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('also could submit to users_jobs api', async () => {
|
|
455
|
-
const n1 = await workflow.createNode({
|
|
456
|
-
type: 'manual',
|
|
457
|
-
config: {
|
|
458
|
-
assignees: [users[0].id],
|
|
459
|
-
forms: {
|
|
460
|
-
f1: {
|
|
461
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
},
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
468
|
-
|
|
469
|
-
await sleep(500);
|
|
470
|
-
|
|
471
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
472
|
-
const usersJobs = await UserJobModel.findAll();
|
|
473
|
-
expect(usersJobs.length).toBe(1);
|
|
474
|
-
expect(usersJobs[0].get('status')).toBe(JOB_STATUS.PENDING);
|
|
475
|
-
expect(usersJobs[0].get('userId')).toBe(users[0].id);
|
|
476
|
-
|
|
477
|
-
const res = await userAgents[0].resource('users_jobs').submit({
|
|
478
|
-
filterByTk: usersJobs[0].get('id'),
|
|
479
|
-
values: {
|
|
480
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
481
|
-
},
|
|
482
|
-
});
|
|
483
|
-
expect(res.status).toBe(202);
|
|
484
|
-
|
|
485
|
-
await sleep(1000);
|
|
486
|
-
|
|
487
|
-
const [execution] = await workflow.getExecutions();
|
|
488
|
-
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
489
|
-
const [job] = await execution.getJobs();
|
|
490
|
-
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
|
491
|
-
expect(job.result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
492
|
-
});
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
describe('mode: 1 (multiple record, all)', () => {
|
|
496
|
-
it('all resolved', async () => {
|
|
497
|
-
const n1 = await workflow.createNode({
|
|
498
|
-
type: 'manual',
|
|
499
|
-
config: {
|
|
500
|
-
assignees: [users[0].id, users[1].id],
|
|
501
|
-
mode: 1,
|
|
502
|
-
forms: {
|
|
503
|
-
f1: {
|
|
504
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
505
|
-
},
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
511
|
-
|
|
512
|
-
await sleep(500);
|
|
513
|
-
|
|
514
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
515
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
516
|
-
order: [['userId', 'ASC']],
|
|
517
|
-
});
|
|
518
|
-
expect(pendingJobs.length).toBe(2);
|
|
519
|
-
|
|
520
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
521
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
522
|
-
values: {
|
|
523
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
524
|
-
},
|
|
525
|
-
});
|
|
526
|
-
expect(res1.status).toBe(202);
|
|
527
|
-
|
|
528
|
-
await sleep(1000);
|
|
529
|
-
|
|
530
|
-
const [e1] = await workflow.getExecutions();
|
|
531
|
-
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
|
|
532
|
-
const [j1] = await e1.getJobs();
|
|
533
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
534
|
-
expect(j1.result).toBe(0.5);
|
|
535
|
-
const usersJobs1 = await UserJobModel.findAll({
|
|
536
|
-
order: [['userId', 'ASC']],
|
|
537
|
-
});
|
|
538
|
-
expect(usersJobs1.length).toBe(2);
|
|
539
|
-
|
|
540
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
541
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
542
|
-
values: {
|
|
543
|
-
result: { f1: { a: 2 }, _: 'resolve' },
|
|
544
|
-
},
|
|
545
|
-
});
|
|
546
|
-
expect(res2.status).toBe(202);
|
|
547
|
-
|
|
548
|
-
await sleep(1000);
|
|
549
|
-
|
|
550
|
-
const [e2] = await workflow.getExecutions();
|
|
551
|
-
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
552
|
-
const [j2] = await e2.getJobs();
|
|
553
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
554
|
-
expect(j2.result).toBe(1);
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
it('first rejected', async () => {
|
|
558
|
-
const n1 = await workflow.createNode({
|
|
559
|
-
type: 'manual',
|
|
560
|
-
config: {
|
|
561
|
-
assignees: [users[0].id, users[1].id],
|
|
562
|
-
mode: 1,
|
|
563
|
-
forms: {
|
|
564
|
-
f1: {
|
|
565
|
-
actions: [{ status: JOB_STATUS.REJECTED, key: 'reject' }],
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
572
|
-
|
|
573
|
-
await sleep(500);
|
|
574
|
-
|
|
575
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
576
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
577
|
-
order: [['userId', 'ASC']],
|
|
578
|
-
});
|
|
579
|
-
expect(pendingJobs.length).toBe(2);
|
|
580
|
-
|
|
581
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
582
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
583
|
-
values: {
|
|
584
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
585
|
-
},
|
|
586
|
-
});
|
|
587
|
-
expect(res1.status).toBe(202);
|
|
588
|
-
|
|
589
|
-
await sleep(1000);
|
|
590
|
-
|
|
591
|
-
const [e1] = await workflow.getExecutions();
|
|
592
|
-
expect(e1.status).toBe(EXECUTION_STATUS.REJECTED);
|
|
593
|
-
const [j1] = await e1.getJobs();
|
|
594
|
-
expect(j1.status).toBe(JOB_STATUS.REJECTED);
|
|
595
|
-
expect(j1.result).toBe(0.5);
|
|
596
|
-
const usersJobs1 = await UserJobModel.findAll({
|
|
597
|
-
order: [['userId', 'ASC']],
|
|
598
|
-
});
|
|
599
|
-
expect(usersJobs1.length).toBe(2);
|
|
600
|
-
|
|
601
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
602
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
603
|
-
values: {
|
|
604
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
605
|
-
},
|
|
606
|
-
});
|
|
607
|
-
expect(res2.status).toBe(400);
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
it('last rejected', async () => {
|
|
611
|
-
const n1 = await workflow.createNode({
|
|
612
|
-
type: 'manual',
|
|
613
|
-
config: {
|
|
614
|
-
assignees: [users[0].id, users[1].id],
|
|
615
|
-
mode: 1,
|
|
616
|
-
forms: {
|
|
617
|
-
f1: {
|
|
618
|
-
actions: [
|
|
619
|
-
{ status: JOB_STATUS.RESOLVED, key: 'resolve' },
|
|
620
|
-
{ status: JOB_STATUS.REJECTED, key: 'reject' },
|
|
621
|
-
],
|
|
622
|
-
},
|
|
623
|
-
},
|
|
624
|
-
},
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
628
|
-
|
|
629
|
-
await sleep(500);
|
|
630
|
-
|
|
631
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
632
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
633
|
-
order: [['userId', 'ASC']],
|
|
634
|
-
});
|
|
635
|
-
expect(pendingJobs.length).toBe(2);
|
|
636
|
-
|
|
637
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
638
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
639
|
-
values: {
|
|
640
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
641
|
-
},
|
|
642
|
-
});
|
|
643
|
-
expect(res1.status).toBe(202);
|
|
644
|
-
|
|
645
|
-
await sleep(1000);
|
|
646
|
-
|
|
647
|
-
const [e1] = await workflow.getExecutions();
|
|
648
|
-
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
|
|
649
|
-
const [j1] = await e1.getJobs();
|
|
650
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
651
|
-
expect(j1.result).toBe(0.5);
|
|
652
|
-
const usersJobs1 = await UserJobModel.findAll({
|
|
653
|
-
order: [['userId', 'ASC']],
|
|
654
|
-
});
|
|
655
|
-
expect(usersJobs1.length).toBe(2);
|
|
656
|
-
|
|
657
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
658
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
659
|
-
values: {
|
|
660
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
661
|
-
},
|
|
662
|
-
});
|
|
663
|
-
expect(res2.status).toBe(202);
|
|
664
|
-
|
|
665
|
-
await sleep(1000);
|
|
666
|
-
|
|
667
|
-
const [e2] = await workflow.getExecutions();
|
|
668
|
-
expect(e2.status).toBe(EXECUTION_STATUS.REJECTED);
|
|
669
|
-
const [j2] = await e2.getJobs();
|
|
670
|
-
expect(j2.status).toBe(JOB_STATUS.REJECTED);
|
|
671
|
-
expect(j2.result).toBe(1);
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
describe('mode: -1 (multiple record, any)', () => {
|
|
676
|
-
it('first resolved', async () => {
|
|
677
|
-
const n1 = await workflow.createNode({
|
|
678
|
-
type: 'manual',
|
|
679
|
-
config: {
|
|
680
|
-
assignees: [users[0].id, users[1].id],
|
|
681
|
-
mode: -1,
|
|
682
|
-
forms: {
|
|
683
|
-
f1: {
|
|
684
|
-
actions: [
|
|
685
|
-
{ status: JOB_STATUS.RESOLVED, key: 'resolve' },
|
|
686
|
-
{ status: JOB_STATUS.REJECTED, key: 'reject' },
|
|
687
|
-
],
|
|
688
|
-
},
|
|
689
|
-
},
|
|
690
|
-
},
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
694
|
-
|
|
695
|
-
await sleep(500);
|
|
696
|
-
|
|
697
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
698
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
699
|
-
order: [['userId', 'ASC']],
|
|
700
|
-
});
|
|
701
|
-
expect(pendingJobs.length).toBe(2);
|
|
702
|
-
|
|
703
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
704
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
705
|
-
values: {
|
|
706
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
707
|
-
},
|
|
708
|
-
});
|
|
709
|
-
expect(res1.status).toBe(202);
|
|
710
|
-
|
|
711
|
-
await sleep(1000);
|
|
712
|
-
|
|
713
|
-
const [e1] = await workflow.getExecutions();
|
|
714
|
-
expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
715
|
-
const [j1] = await e1.getJobs();
|
|
716
|
-
expect(j1.status).toBe(JOB_STATUS.RESOLVED);
|
|
717
|
-
expect(j1.result).toBe(0.5);
|
|
718
|
-
|
|
719
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
720
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
721
|
-
values: {
|
|
722
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
723
|
-
},
|
|
724
|
-
});
|
|
725
|
-
expect(res2.status).toBe(400);
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
it('any resolved', async () => {
|
|
729
|
-
const n1 = await workflow.createNode({
|
|
730
|
-
type: 'manual',
|
|
731
|
-
config: {
|
|
732
|
-
assignees: [users[0].id, users[1].id],
|
|
733
|
-
mode: -1,
|
|
734
|
-
forms: {
|
|
735
|
-
f1: {
|
|
736
|
-
actions: [
|
|
737
|
-
{ status: JOB_STATUS.RESOLVED, key: 'resolve' },
|
|
738
|
-
{ status: JOB_STATUS.REJECTED, key: 'reject' },
|
|
739
|
-
],
|
|
740
|
-
},
|
|
741
|
-
},
|
|
742
|
-
},
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
746
|
-
|
|
747
|
-
await sleep(500);
|
|
748
|
-
|
|
749
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
750
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
751
|
-
order: [['userId', 'ASC']],
|
|
752
|
-
});
|
|
753
|
-
expect(pendingJobs.length).toBe(2);
|
|
754
|
-
|
|
755
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
756
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
757
|
-
values: {
|
|
758
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
759
|
-
},
|
|
760
|
-
});
|
|
761
|
-
expect(res1.status).toBe(202);
|
|
762
|
-
|
|
763
|
-
await sleep(1000);
|
|
764
|
-
|
|
765
|
-
const [e1] = await workflow.getExecutions();
|
|
766
|
-
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
|
|
767
|
-
const [j1] = await e1.getJobs();
|
|
768
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
769
|
-
expect(j1.result).toBe(0.5);
|
|
770
|
-
|
|
771
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
772
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
773
|
-
values: {
|
|
774
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
775
|
-
},
|
|
776
|
-
});
|
|
777
|
-
expect(res2.status).toBe(202);
|
|
778
|
-
|
|
779
|
-
await sleep(1000);
|
|
780
|
-
|
|
781
|
-
const [e2] = await workflow.getExecutions();
|
|
782
|
-
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
783
|
-
const [j2] = await e2.getJobs();
|
|
784
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
785
|
-
expect(j2.result).toBe(1);
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
it('all rejected', async () => {
|
|
789
|
-
const n1 = await workflow.createNode({
|
|
790
|
-
type: 'manual',
|
|
791
|
-
config: {
|
|
792
|
-
assignees: [users[0].id, users[1].id],
|
|
793
|
-
mode: -1,
|
|
794
|
-
forms: {
|
|
795
|
-
f1: {
|
|
796
|
-
actions: [{ status: JOB_STATUS.REJECTED, key: 'reject' }],
|
|
797
|
-
},
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
803
|
-
|
|
804
|
-
await sleep(500);
|
|
805
|
-
|
|
806
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
807
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
808
|
-
order: [['userId', 'ASC']],
|
|
809
|
-
});
|
|
810
|
-
expect(pendingJobs.length).toBe(2);
|
|
811
|
-
|
|
812
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
813
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
814
|
-
values: {
|
|
815
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
816
|
-
},
|
|
817
|
-
});
|
|
818
|
-
expect(res1.status).toBe(202);
|
|
819
|
-
|
|
820
|
-
await sleep(1000);
|
|
821
|
-
|
|
822
|
-
const [e1] = await workflow.getExecutions();
|
|
823
|
-
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
|
|
824
|
-
const [j1] = await e1.getJobs();
|
|
825
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
826
|
-
expect(j1.result).toBe(0.5);
|
|
827
|
-
|
|
828
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
829
|
-
filterByTk: pendingJobs[1].get('id'),
|
|
830
|
-
values: {
|
|
831
|
-
result: { f1: { a: 0 }, _: 'reject' },
|
|
832
|
-
},
|
|
833
|
-
});
|
|
834
|
-
expect(res2.status).toBe(202);
|
|
835
|
-
|
|
836
|
-
await sleep(1000);
|
|
837
|
-
|
|
838
|
-
const [e2] = await workflow.getExecutions();
|
|
839
|
-
expect(e2.status).toBe(EXECUTION_STATUS.REJECTED);
|
|
840
|
-
const [j2] = await e2.getJobs();
|
|
841
|
-
expect(j2.status).toBe(JOB_STATUS.REJECTED);
|
|
842
|
-
expect(j2.result).toBe(1);
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
|
|
846
336
|
describe('use result of submitted form in manual node', () => {
|
|
847
337
|
it('result should be available and correct', async () => {
|
|
848
338
|
const n1 = await workflow.createNode({
|