@nocobase/plugin-workflow-action-trigger 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -1,778 +0,0 @@
1
- import Database from '@nocobase/database';
2
- import { EXECUTION_STATUS } from '@nocobase/plugin-workflow';
3
- import { getApp, sleep } from '@nocobase/plugin-workflow-test';
4
- import { MockServer } from '@nocobase/test';
5
-
6
- import Plugin from '..';
7
-
8
- describe('workflow > action-trigger', () => {
9
- let app: MockServer;
10
- let db: Database;
11
- let agent;
12
- let PostRepo;
13
- let CategoryRepo;
14
- let WorkflowModel;
15
- let UserRepo;
16
- let users;
17
- let userAgents;
18
-
19
- beforeEach(async () => {
20
- app = await getApp({
21
- plugins: ['users', 'auth', Plugin],
22
- });
23
- await app.pm.get('auth').install();
24
- agent = app.agent();
25
- db = app.db;
26
- WorkflowModel = db.getCollection('workflows').model;
27
- PostRepo = db.getCollection('posts').repository;
28
- CategoryRepo = db.getCollection('categories').repository;
29
- UserRepo = db.getCollection('users').repository;
30
-
31
- users = await UserRepo.create({
32
- values: [
33
- { id: 2, nickname: 'a', roles: [{ name: 'root' }] },
34
- { id: 3, nickname: 'b' },
35
- ],
36
- });
37
-
38
- userAgents = users.map((user) => app.agent().login(user));
39
- });
40
-
41
- afterEach(() => app.destroy());
42
-
43
- describe('create', () => {
44
- it('enabled / disabled', async () => {
45
- const workflow = await WorkflowModel.create({
46
- enabled: true,
47
- type: 'action',
48
- config: {
49
- collection: 'posts',
50
- },
51
- });
52
-
53
- const res1 = await userAgents[0].resource('posts').create({
54
- values: { title: 't1' },
55
- triggerWorkflows: `${workflow.key}`,
56
- });
57
- expect(res1.status).toBe(200);
58
-
59
- await sleep(500);
60
-
61
- const e1 = await workflow.getExecutions();
62
- expect(e1.length).toBe(1);
63
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
64
- expect(e1[0].context.data).toMatchObject({ title: 't1' });
65
-
66
- await workflow.update({
67
- enabled: false,
68
- });
69
-
70
- const res2 = await userAgents[0].resource('posts').create({
71
- values: { title: 't2' },
72
- triggerWorkflows: `${workflow.key}`,
73
- });
74
- expect(res2.status).toBe(200);
75
-
76
- await sleep(500);
77
-
78
- const e2 = await workflow.getExecutions({ order: [['id', 'ASC']] });
79
- expect(e2.length).toBe(1);
80
-
81
- await workflow.update({
82
- enabled: true,
83
- });
84
-
85
- const res3 = await userAgents[0].resource('posts').create({
86
- values: { title: 't3' },
87
- triggerWorkflows: `${workflow.key}`,
88
- });
89
- expect(res2.status).toBe(200);
90
-
91
- await sleep(500);
92
-
93
- const e3 = await workflow.getExecutions({ order: [['id', 'ASC']] });
94
- expect(e3.length).toBe(2);
95
- expect(e3[1].status).toBe(EXECUTION_STATUS.RESOLVED);
96
- expect(e3[1].context.data).toMatchObject({ title: 't3' });
97
- });
98
-
99
- it('only trigger if params provided matching collection config', async () => {
100
- const workflow = await WorkflowModel.create({
101
- enabled: true,
102
- type: 'action',
103
- config: {
104
- collection: 'posts',
105
- },
106
- });
107
-
108
- const res1 = await userAgents[0].resource('posts').create({
109
- values: { title: 't1' },
110
- triggerWorkflows: `${workflow.key}`,
111
- });
112
- expect(res1.status).toBe(200);
113
-
114
- await sleep(500);
115
-
116
- const e1 = await workflow.getExecutions();
117
- expect(e1.length).toBe(1);
118
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
119
- expect(e1[0].context.data).toMatchObject({ title: 't1' });
120
-
121
- await workflow.update({
122
- config: {
123
- collection: 'comments',
124
- },
125
- });
126
-
127
- const res2 = await userAgents[0].resource('posts').create({
128
- values: { title: 't2' },
129
- triggerWorkflows: `${workflow.key}`,
130
- });
131
- expect(res2.status).toBe(200);
132
-
133
- await sleep(500);
134
-
135
- const e2 = await workflow.getExecutions({ order: [['id', 'ASC']] });
136
- expect(e2.length).toBe(1);
137
- // expect(e2[1].status).toBe(EXECUTION_STATUS.RESOLVED);
138
- // expect(e2[1].context.data).toMatchObject({ title: 't2' });
139
- });
140
-
141
- it('system fields could be accessed', async () => {
142
- const workflow = await WorkflowModel.create({
143
- enabled: true,
144
- type: 'action',
145
- config: {
146
- collection: 'posts',
147
- },
148
- });
149
-
150
- const res1 = await userAgents[0].resource('posts').create({
151
- values: { title: 't1' },
152
- triggerWorkflows: `${workflow.key}`,
153
- });
154
- expect(res1.status).toBe(200);
155
-
156
- await sleep(500);
157
-
158
- const e1 = await workflow.getExecutions();
159
- expect(e1.length).toBe(1);
160
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
161
- expect(e1[0].context.data).toHaveProperty('createdAt');
162
- });
163
-
164
- it('appends', async () => {
165
- const workflow = await WorkflowModel.create({
166
- enabled: true,
167
- type: 'action',
168
- config: {
169
- collection: 'posts',
170
- appends: ['createdBy'],
171
- },
172
- });
173
-
174
- const res1 = await userAgents[0].resource('posts').create({
175
- values: { title: 't1' },
176
- triggerWorkflows: `${workflow.key}`,
177
- });
178
- expect(res1.status).toBe(200);
179
-
180
- await sleep(500);
181
-
182
- const e1 = await workflow.getExecutions();
183
- expect(e1.length).toBe(1);
184
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
185
- expect(e1[0].context.data).toHaveProperty('createdBy');
186
- });
187
-
188
- it('user submitted form', async () => {
189
- const workflow = await WorkflowModel.create({
190
- enabled: true,
191
- type: 'action',
192
- config: {
193
- collection: 'posts',
194
- },
195
- });
196
-
197
- const res1 = await userAgents[0].resource('posts').create({
198
- values: { title: 't1' },
199
- triggerWorkflows: `${workflow.key}`,
200
- });
201
- expect(res1.status).toBe(200);
202
-
203
- await sleep(500);
204
-
205
- const [e1] = await workflow.getExecutions();
206
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
207
- expect(e1.context.user).toBeDefined();
208
- expect(e1.context.user.id).toBe(users[0].id);
209
- });
210
- });
211
-
212
- describe('update', () => {
213
- it('trigger after updated', async () => {
214
- const workflow = await WorkflowModel.create({
215
- enabled: true,
216
- type: 'action',
217
- config: {
218
- collection: 'posts',
219
- appends: ['createdBy'],
220
- },
221
- });
222
-
223
- const res1 = await userAgents[0].resource('posts').create({
224
- values: { title: 't1' },
225
- });
226
- expect(res1.status).toBe(200);
227
-
228
- await sleep(500);
229
-
230
- const e1 = await workflow.getExecutions();
231
- expect(e1.length).toBe(0);
232
-
233
- const res2 = await userAgents[0].resource('posts').update({
234
- filterByTk: res1.body.data.id,
235
- values: { title: 't2' },
236
- triggerWorkflows: `${workflow.key}`,
237
- });
238
-
239
- await sleep(500);
240
-
241
- const [e2] = await workflow.getExecutions();
242
- expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
243
- expect(e2.context.data).toHaveProperty('title', 't2');
244
- expect(e2.context.data).toHaveProperty('createdBy');
245
- });
246
- });
247
-
248
- describe.skip('destroy', () => {
249
- it('trigger after destroyed', async () => {
250
- const workflow = await WorkflowModel.create({
251
- enabled: true,
252
- type: 'action',
253
- config: {
254
- collection: 'posts',
255
- },
256
- });
257
-
258
- const p1 = await PostRepo.create({
259
- values: { title: 't1' },
260
- });
261
- const p2 = await PostRepo.create({
262
- values: { title: 't2' },
263
- });
264
- const res1 = await userAgents[0].resource('posts').destroy({
265
- filterByTk: p1.id,
266
- });
267
- expect(res1.status).toBe(200);
268
-
269
- await sleep(500);
270
-
271
- const e1 = await workflow.getExecutions();
272
- expect(e1.length).toBe(0);
273
-
274
- const res2 = await userAgents[0].resource('posts').destroy({
275
- filterByTk: p2.id,
276
- triggerWorkflows: `${workflow.key}`,
277
- });
278
-
279
- await sleep(500);
280
-
281
- const [e2] = await workflow.getExecutions();
282
- expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
283
- expect(e2.context.data).toBe(1);
284
- });
285
- });
286
-
287
- describe('directly trigger', () => {
288
- it('no collection configured should not be triggered', async () => {
289
- const workflow = await WorkflowModel.create({
290
- enabled: true,
291
- type: 'action',
292
- });
293
-
294
- const res1 = await userAgents[0].resource('workflows').trigger({
295
- values: { title: 't1' },
296
- triggerWorkflows: `${workflow.key}`,
297
- });
298
- expect(res1.status).toBe(202);
299
-
300
- await sleep(500);
301
-
302
- const e1s = await workflow.getExecutions();
303
- expect(e1s.length).toBe(0);
304
- });
305
-
306
- it('trigger on form data', async () => {
307
- const workflow = await WorkflowModel.create({
308
- enabled: true,
309
- type: 'action',
310
- config: {
311
- collection: 'posts',
312
- appends: ['createdBy'],
313
- },
314
- });
315
-
316
- const res1 = await userAgents[0].resource('workflows').trigger({
317
- values: { title: 't1' },
318
- triggerWorkflows: `${workflow.key}`,
319
- });
320
- expect(res1.status).toBe(202);
321
-
322
- await sleep(500);
323
-
324
- const [e1] = await workflow.getExecutions();
325
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
326
- expect(e1.context.data).toMatchObject({ title: 't1' });
327
- expect(e1.context.data.createdBy).toBeUndefined();
328
- });
329
-
330
- it('trigger on record data', async () => {
331
- const workflow = await WorkflowModel.create({
332
- enabled: true,
333
- type: 'action',
334
- config: {
335
- collection: 'posts',
336
- appends: ['createdBy'],
337
- },
338
- });
339
-
340
- const post = await PostRepo.create({
341
- values: { title: 't1', createdBy: users[0].id },
342
- });
343
-
344
- const res1 = await userAgents[0].resource('workflows').trigger({
345
- values: post.toJSON(),
346
- triggerWorkflows: `${workflow.key}`,
347
- });
348
- expect(res1.status).toBe(202);
349
-
350
- await sleep(500);
351
-
352
- const [e1] = await workflow.getExecutions();
353
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
354
- expect(e1.context.data).toMatchObject({ title: 't1' });
355
- expect(e1.context.data).toHaveProperty('createdBy');
356
- expect(e1.context.data.createdBy.id).toBe(users[0].id);
357
- });
358
-
359
- it('multi trigger', async () => {
360
- const w1 = await WorkflowModel.create({
361
- enabled: true,
362
- type: 'action',
363
- config: {
364
- collection: 'posts',
365
- },
366
- });
367
-
368
- const w2 = await WorkflowModel.create({
369
- enabled: true,
370
- type: 'action',
371
- config: {
372
- collection: 'posts',
373
- },
374
- });
375
-
376
- const res1 = await userAgents[0].resource('workflows').trigger({
377
- values: { title: 't1' },
378
- triggerWorkflows: `${w1.key},${w2.key}`,
379
- });
380
- expect(res1.status).toBe(202);
381
-
382
- await sleep(500);
383
-
384
- const [e1] = await w1.getExecutions();
385
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
386
- expect(e1.context.data).toMatchObject({ title: 't1' });
387
-
388
- const [e2] = await w2.getExecutions();
389
- expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
390
- expect(e2.context.data).toMatchObject({ title: 't1' });
391
- });
392
-
393
- it('user submitted form', async () => {
394
- const workflow = await WorkflowModel.create({
395
- enabled: true,
396
- type: 'action',
397
- config: {
398
- collection: 'posts',
399
- appends: ['createdBy'],
400
- },
401
- });
402
-
403
- const res1 = await userAgents[0].resource('posts').create({
404
- values: { title: 't1' },
405
- triggerWorkflows: `${workflow.key}`,
406
- });
407
- expect(res1.status).toBe(200);
408
-
409
- await sleep(500);
410
-
411
- const [e1] = await workflow.getExecutions();
412
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
413
- expect(e1.context.user).toBeDefined();
414
- expect(e1.context.user.id).toBe(users[0].id);
415
- });
416
- });
417
-
418
- describe('context data path', () => {
419
- it('level: 1', async () => {
420
- const workflow = await WorkflowModel.create({
421
- enabled: true,
422
- type: 'action',
423
- config: {
424
- collection: 'posts',
425
- },
426
- });
427
-
428
- const res1 = await userAgents[0].resource('workflows').trigger({
429
- values: { title: 't1', category: { title: 'c1' } },
430
- triggerWorkflows: `${workflow.key}!category`,
431
- });
432
- expect(res1.status).toBe(202);
433
-
434
- await sleep(500);
435
-
436
- const [e1] = await workflow.getExecutions();
437
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
438
- expect(e1.context.data).toMatchObject({ title: 'c1' });
439
- });
440
-
441
- it('level: 2', async () => {
442
- const workflow = await WorkflowModel.create({
443
- enabled: true,
444
- type: 'action',
445
- config: {
446
- collection: 'posts',
447
- },
448
- });
449
-
450
- const res1 = await userAgents[0].resource('workflows').trigger({
451
- values: { content: 'comment1', post: { category: { title: 'c1' } } },
452
- triggerWorkflows: `${workflow.key}!post.category`,
453
- });
454
- expect(res1.status).toBe(202);
455
-
456
- await sleep(500);
457
-
458
- const [e1] = await workflow.getExecutions();
459
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
460
- expect(e1.context.data).toMatchObject({ title: 'c1' });
461
- });
462
- });
463
-
464
- describe('associations actions', () => {
465
- it('trigger on associated data', async () => {
466
- const workflow = await WorkflowModel.create({
467
- enabled: true,
468
- type: 'action',
469
- config: {
470
- collection: 'posts',
471
- },
472
- });
473
-
474
- const c1 = await CategoryRepo.create({ values: { title: 'c1' } });
475
-
476
- const res1 = await userAgents[0].resource('categories.posts', c1.id).create({
477
- values: { title: 'p1' },
478
- triggerWorkflows: `${workflow.key}`,
479
- });
480
- expect(res1.status).toBe(200);
481
-
482
- await sleep(500);
483
-
484
- const e1s = await workflow.getExecutions();
485
- expect(e1s.length).toBe(1);
486
- expect(e1s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
487
- expect(e1s[0].context.data).toMatchObject({ title: 'p1', categoryId: c1.id });
488
-
489
- const res2 = await userAgents[0]
490
- .post(`/categories/${c1.id}/posts:create`)
491
- .query({ triggerWorkflows: `${workflow.key}` })
492
- .send({
493
- data: { title: 'p2' },
494
- });
495
-
496
- await sleep(500);
497
-
498
- const e2s = await workflow.getExecutions();
499
- expect(e2s.length).toBe(2);
500
- });
501
- });
502
-
503
- describe('workflow key', () => {
504
- it('revision', async () => {
505
- const w1 = await WorkflowModel.create({
506
- enabled: true,
507
- type: 'action',
508
- config: {
509
- collection: 'posts',
510
- },
511
- });
512
-
513
- const res1 = await userAgents[0].resource('workflows').trigger({
514
- values: { title: 't1' },
515
- triggerWorkflows: `${w1.key}`,
516
- });
517
- expect(res1.status).toBe(202);
518
-
519
- await sleep(500);
520
-
521
- const [e1] = await w1.getExecutions();
522
- expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
523
- expect(e1.context.data).toMatchObject({ title: 't1' });
524
-
525
- const res2 = await userAgents[0].resource('workflows').revision({
526
- filterByTk: w1.id,
527
- filter: {
528
- key: w1.key,
529
- },
530
- });
531
- const w2 = await WorkflowModel.findByPk(res2.body.data.id);
532
- await w2.update({
533
- enabled: true,
534
- });
535
-
536
- const res3 = await userAgents[0].resource('workflows').trigger({
537
- values: { title: 't2' },
538
- triggerWorkflows: `${w1.key}`,
539
- });
540
- expect(res3.status).toBe(202);
541
-
542
- await sleep(500);
543
-
544
- const e2 = await w1.getExecutions();
545
- expect(e2.length).toBe(1);
546
- const e3 = await w2.getExecutions();
547
- expect(e3.length).toBe(1);
548
- expect(e3[0].status).toBe(EXECUTION_STATUS.RESOLVED);
549
- expect(e3[0].context.data).toMatchObject({ title: 't2' });
550
- });
551
- });
552
-
553
- describe('sync', () => {
554
- it('sync form trigger', async () => {
555
- const workflow = await WorkflowModel.create({
556
- enabled: true,
557
- type: 'action',
558
- sync: true,
559
- config: {
560
- collection: 'posts',
561
- },
562
- });
563
-
564
- const res1 = await userAgents[0].resource('posts').create({
565
- values: { title: 't1' },
566
- triggerWorkflows: `${workflow.key}`,
567
- });
568
- expect(res1.status).toBe(200);
569
-
570
- const executions = await workflow.getExecutions();
571
- expect(executions.length).toBe(1);
572
- expect(executions[0].status).toBe(EXECUTION_STATUS.RESOLVED);
573
- });
574
-
575
- it('sync and async will all be triggered in one action', async () => {
576
- const w1 = await WorkflowModel.create({
577
- enabled: true,
578
- type: 'action',
579
- config: {
580
- collection: 'posts',
581
- },
582
- });
583
-
584
- const w2 = await WorkflowModel.create({
585
- enabled: true,
586
- type: 'action',
587
- sync: true,
588
- config: {
589
- collection: 'posts',
590
- },
591
- });
592
-
593
- const res1 = await userAgents[0].resource('posts').create({
594
- values: { title: 't1' },
595
- triggerWorkflows: [w1.key, w2.key].join(),
596
- });
597
- expect(res1.status).toBe(200);
598
-
599
- const e1s = await w1.getExecutions();
600
- expect(e1s.length).toBe(0);
601
-
602
- const e2s = await w2.getExecutions();
603
- expect(e2s.length).toBe(1);
604
- expect(e2s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
605
-
606
- await sleep(500);
607
-
608
- const e3s = await w1.getExecutions();
609
- expect(e3s.length).toBe(1);
610
- expect(e3s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
611
- });
612
- });
613
-
614
- describe('global workflow', () => {
615
- it('no action configured should not be triggered', async () => {
616
- const workflow = await WorkflowModel.create({
617
- enabled: true,
618
- type: 'action',
619
- config: {
620
- collection: 'posts',
621
- global: true,
622
- },
623
- });
624
-
625
- const res1 = await userAgents[0].resource('posts').create({
626
- values: { title: 't1' },
627
- });
628
- expect(res1.status).toBe(200);
629
-
630
- await sleep(500);
631
-
632
- const e1 = await workflow.getExecutions();
633
- expect(e1.length).toBe(0);
634
-
635
- const res2 = await userAgents[0].resource('posts').create({
636
- values: { title: 't1' },
637
- triggerWorkflows: `${workflow.key}`,
638
- });
639
- expect(res2.status).toBe(200);
640
-
641
- await sleep(500);
642
-
643
- const e2 = await workflow.getExecutions();
644
- expect(e2.length).toBe(0);
645
- });
646
-
647
- it('trigger on both create and update actions', async () => {
648
- const workflow = await WorkflowModel.create({
649
- enabled: true,
650
- type: 'action',
651
- config: {
652
- collection: 'posts',
653
- global: true,
654
- actions: ['create', 'update'],
655
- },
656
- });
657
-
658
- const res1 = await userAgents[0].resource('posts').create({
659
- values: { title: 't1' },
660
- });
661
- expect(res1.status).toBe(200);
662
-
663
- await sleep(500);
664
-
665
- const e1 = await workflow.getExecutions();
666
- expect(e1.length).toBe(1);
667
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
668
- expect(e1[0].context.data).toMatchObject({ title: 't1' });
669
-
670
- const res2 = await userAgents[0].resource('posts').update({
671
- filterByTk: res1.body.data.id,
672
- values: { title: 't2' },
673
- });
674
-
675
- await sleep(500);
676
-
677
- const e2 = await workflow.getExecutions({ order: [['id', 'ASC']] });
678
- expect(e2.length).toBe(2);
679
- expect(e2[1].status).toBe(EXECUTION_STATUS.RESOLVED);
680
- expect(e2[1].context.data).toMatchObject({ title: 't2' });
681
- });
682
-
683
- it('trigger on action when bound to button', async () => {
684
- const workflow = await WorkflowModel.create({
685
- enabled: true,
686
- type: 'action',
687
- config: {
688
- collection: 'posts',
689
- global: true,
690
- actions: ['create', 'update'],
691
- },
692
- });
693
-
694
- const res1 = await userAgents[0].resource('posts').create({
695
- values: { title: 't1' },
696
- triggerWorkflows: `${workflow.key}`,
697
- });
698
- expect(res1.status).toBe(200);
699
-
700
- await sleep(500);
701
-
702
- const e1 = await workflow.getExecutions();
703
- expect(e1.length).toBe(1);
704
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
705
- expect(e1[0].context.data).toMatchObject({ title: 't1' });
706
- });
707
-
708
- it('trigger on action directly submit to workflow', async () => {
709
- const workflow = await WorkflowModel.create({
710
- enabled: true,
711
- type: 'action',
712
- config: {
713
- collection: 'posts',
714
- global: true,
715
- actions: ['create', 'update'],
716
- },
717
- });
718
-
719
- const res1 = await userAgents[0].resource('workflows').trigger({
720
- values: { title: 't1' },
721
- triggerWorkflows: `${workflow.key}`,
722
- });
723
- expect(res1.status).toBe(202);
724
-
725
- await sleep(500);
726
-
727
- const e1 = await workflow.getExecutions();
728
- expect(e1.length).toBe(1);
729
- expect(e1[0].status).toBe(EXECUTION_STATUS.RESOLVED);
730
- expect(e1[0].context.data).toMatchObject({ title: 't1' });
731
- });
732
- });
733
-
734
- describe('multiple data source', () => {
735
- it('trigger on different data source', async () => {
736
- const workflow = await WorkflowModel.create({
737
- enabled: true,
738
- type: 'action',
739
- config: {
740
- collection: 'another:posts',
741
- },
742
- });
743
-
744
- const res1 = await userAgents[0].resource('posts').create({
745
- values: { title: 't1' },
746
- triggerWorkflows: `${workflow.key}`,
747
- });
748
- expect(res1.status).toBe(200);
749
-
750
- await sleep(500);
751
-
752
- const e1s = await workflow.getExecutions();
753
- expect(e1s.length).toBe(0);
754
-
755
- // const res2 = await userAgents[0]
756
- // .set('x-data-source', 'another')
757
- // .resource('posts')
758
- // .create({
759
- // values: { title: 't2' },
760
- // triggerWorkflows: `${workflow.key}`,
761
- // });
762
- const res2 = await agent
763
- .login(users[0])
764
- .set('x-data-source', 'another')
765
- .post('/api/posts:create')
766
- .query({ triggerWorkflows: `${workflow.key}` })
767
- .send({ title: 't2' });
768
-
769
- expect(res2.status).toBe(200);
770
-
771
- await sleep(500);
772
-
773
- const e2s = await workflow.getExecutions();
774
- expect(e2s.length).toBe(1);
775
- expect(e2s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
776
- });
777
- });
778
- });