@nocobase/plugin-workflow-manual 1.0.0-alpha.2 → 1.0.0-alpha.4
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/WorkflowTodo.d.ts +8 -0
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/client/instruction/AssigneesSelect.d.ts +8 -0
- package/dist/client/instruction/FormBlockInitializer.d.ts +8 -0
- package/dist/client/instruction/FormBlockProvider.d.ts +8 -0
- package/dist/client/instruction/ModeConfig.d.ts +8 -0
- package/dist/client/instruction/SchemaConfig.d.ts +8 -0
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +8 -0
- package/dist/client/instruction/forms/create.d.ts +8 -0
- package/dist/client/instruction/forms/custom.d.ts +8 -0
- package/dist/client/instruction/forms/update.d.ts +8 -0
- package/dist/client/instruction/index.d.ts +8 -0
- package/dist/client/instruction/utils.d.ts +8 -0
- package/dist/externalVersion.js +18 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/locale/index.d.ts +8 -0
- package/dist/locale/index.js +9 -0
- package/dist/server/ManualInstruction.d.ts +8 -0
- package/dist/server/ManualInstruction.js +9 -0
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +9 -0
- package/dist/server/actions.d.ts +8 -0
- package/dist/server/actions.js +9 -0
- package/dist/server/collections/1-users_jobs.d.ts +8 -0
- package/dist/server/collections/1-users_jobs.js +9 -0
- package/dist/server/collections/2-jobs.d.ts +8 -0
- package/dist/server/collections/2-jobs.js +9 -0
- package/dist/server/collections/3-users.d.ts +8 -0
- package/dist/server/collections/3-users.js +9 -0
- package/dist/server/forms/create.d.ts +8 -0
- package/dist/server/forms/create.js +9 -0
- package/dist/server/forms/index.d.ts +8 -0
- package/dist/server/forms/index.js +9 -0
- package/dist/server/forms/update.d.ts +8 -0
- package/dist/server/forms/update.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +8 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +9 -0
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +0 -647
- package/src/client/WorkflowTodoBlockInitializer.tsx +0 -32
- package/src/client/__e2e__/assignees.test.ts +0 -0
- package/src/client/__e2e__/createRecordForm.test.ts +0 -2287
- package/src/client/__e2e__/customFormBlocks.test.ts +0 -1933
- package/src/client/__e2e__/datablocks.test.ts +0 -1208
- package/src/client/__e2e__/updateRecordForm.test.ts +0 -2338
- package/src/client/__e2e__/workflowTodo.test.ts +0 -242
- package/src/client/index.ts +0 -51
- package/src/client/instruction/AssigneesSelect.tsx +0 -39
- package/src/client/instruction/FormBlockInitializer.tsx +0 -79
- package/src/client/instruction/FormBlockProvider.tsx +0 -92
- package/src/client/instruction/ModeConfig.tsx +0 -85
- package/src/client/instruction/SchemaConfig.tsx +0 -659
- package/src/client/instruction/createManualFormBlockUISchema.ts +0 -5
- package/src/client/instruction/forms/create.tsx +0 -123
- package/src/client/instruction/forms/custom.tsx +0 -439
- package/src/client/instruction/forms/update.tsx +0 -167
- package/src/client/instruction/index.tsx +0 -160
- package/src/client/instruction/utils.ts +0 -19
- package/src/index.ts +0 -2
- package/src/locale/en-US.json +0 -30
- package/src/locale/index.ts +0 -14
- package/src/locale/ko_KR.json +0 -32
- package/src/locale/zh-CN.json +0 -32
- package/src/server/ManualInstruction.ts +0 -157
- package/src/server/Plugin.ts +0 -43
- package/src/server/__tests__/assignees.test.ts +0 -153
- package/src/server/__tests__/collections/categories.ts +0 -15
- package/src/server/__tests__/collections/comments.ts +0 -24
- package/src/server/__tests__/collections/posts.ts +0 -40
- package/src/server/__tests__/collections/replies.ts +0 -9
- package/src/server/__tests__/collections/tags.ts +0 -15
- package/src/server/__tests__/data-source.test.ts +0 -223
- package/src/server/__tests__/form.test.ts +0 -637
- package/src/server/__tests__/mode.test.ts +0 -561
- package/src/server/actions.ts +0 -103
- package/src/server/collections/1-users_jobs.ts +0 -52
- package/src/server/collections/2-jobs.ts +0 -19
- package/src/server/collections/3-users.ts +0 -17
- package/src/server/forms/create.ts +0 -30
- package/src/server/forms/index.ts +0 -13
- package/src/server/forms/update.ts +0 -30
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20240325213145-fix-schema.ts +0 -82
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import Database from '@nocobase/database';
|
|
2
|
-
import { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
|
3
|
-
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
|
4
|
-
import { MockServer } from '@nocobase/test';
|
|
5
|
-
|
|
6
|
-
// NOTE: skipped because time is not stable on github ci, but should work in local
|
|
7
|
-
describe('workflow > instructions > manual > assignees', () => {
|
|
8
|
-
let app: MockServer;
|
|
9
|
-
let agent;
|
|
10
|
-
let userAgents;
|
|
11
|
-
let db: Database;
|
|
12
|
-
let PostRepo;
|
|
13
|
-
let CommentRepo;
|
|
14
|
-
let WorkflowModel;
|
|
15
|
-
let workflow;
|
|
16
|
-
let UserModel;
|
|
17
|
-
let users;
|
|
18
|
-
let UserJobModel;
|
|
19
|
-
|
|
20
|
-
beforeEach(async () => {
|
|
21
|
-
app = await getApp({
|
|
22
|
-
plugins: ['users', 'auth', 'workflow-manual'],
|
|
23
|
-
});
|
|
24
|
-
// await app.getPlugin('auth').install();
|
|
25
|
-
agent = app.agent();
|
|
26
|
-
db = app.db;
|
|
27
|
-
WorkflowModel = db.getCollection('workflows').model;
|
|
28
|
-
PostRepo = db.getCollection('posts').repository;
|
|
29
|
-
CommentRepo = db.getCollection('comments').repository;
|
|
30
|
-
UserModel = db.getCollection('users').model;
|
|
31
|
-
UserJobModel = db.getModel('users_jobs');
|
|
32
|
-
|
|
33
|
-
users = await UserModel.bulkCreate([
|
|
34
|
-
{ id: 2, nickname: 'a' },
|
|
35
|
-
{ id: 3, nickname: 'b' },
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
userAgents = users.map((user) => app.agent().login(user));
|
|
39
|
-
|
|
40
|
-
workflow = await WorkflowModel.create({
|
|
41
|
-
enabled: true,
|
|
42
|
-
type: 'collection',
|
|
43
|
-
config: {
|
|
44
|
-
mode: 1,
|
|
45
|
-
collection: 'posts',
|
|
46
|
-
appends: ['category', 'category.posts'],
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
afterEach(() => app.destroy());
|
|
52
|
-
|
|
53
|
-
describe('no', () => {
|
|
54
|
-
it('empty assignees', async () => {
|
|
55
|
-
const n1 = await workflow.createNode({
|
|
56
|
-
type: 'manual',
|
|
57
|
-
config: {
|
|
58
|
-
assignees: [],
|
|
59
|
-
forms: {
|
|
60
|
-
f1: {
|
|
61
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const post = await PostRepo.create({
|
|
68
|
-
values: { title: 't1', category: { title: 'c1' } },
|
|
69
|
-
context: { state: { currentUser: users[0] } },
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await sleep(500);
|
|
73
|
-
|
|
74
|
-
const [pending] = await workflow.getExecutions();
|
|
75
|
-
expect(pending.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('multiple', () => {
|
|
80
|
-
it('assignees from nested array', async () => {
|
|
81
|
-
const n1 = await workflow.createNode({
|
|
82
|
-
type: 'manual',
|
|
83
|
-
config: {
|
|
84
|
-
assignees: [`{{$context.data.category.posts.createdById}}`],
|
|
85
|
-
forms: {
|
|
86
|
-
f1: {
|
|
87
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const post = await PostRepo.create({
|
|
94
|
-
values: { title: 't1', category: { title: 'c1' } },
|
|
95
|
-
context: { state: { currentUser: users[0] } },
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
await sleep(500);
|
|
99
|
-
|
|
100
|
-
const [pending] = await workflow.getExecutions();
|
|
101
|
-
expect(pending.status).toBe(EXECUTION_STATUS.STARTED);
|
|
102
|
-
const [j1] = await pending.getJobs();
|
|
103
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
104
|
-
|
|
105
|
-
const usersJobs = await UserJobModel.findAll();
|
|
106
|
-
expect(usersJobs.length).toBe(1);
|
|
107
|
-
expect(usersJobs[0].status).toBe(JOB_STATUS.PENDING);
|
|
108
|
-
expect(usersJobs[0].userId).toBe(users[0].id);
|
|
109
|
-
expect(usersJobs[0].jobId).toBe(j1.id);
|
|
110
|
-
|
|
111
|
-
const res1 = await agent.resource('users_jobs').submit({
|
|
112
|
-
filterByTk: usersJobs[0].id,
|
|
113
|
-
values: { result: { f1: {}, _: 'resolve' } },
|
|
114
|
-
});
|
|
115
|
-
expect(res1.status).toBe(401);
|
|
116
|
-
|
|
117
|
-
const res2 = await userAgents[1].resource('users_jobs').submit({
|
|
118
|
-
filterByTk: usersJobs[0].id,
|
|
119
|
-
values: {
|
|
120
|
-
result: { f1: {}, _: 'resolve' },
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
expect(res2.status).toBe(403);
|
|
124
|
-
|
|
125
|
-
const res3 = await userAgents[0].resource('users_jobs').submit({
|
|
126
|
-
filterByTk: usersJobs[0].id,
|
|
127
|
-
values: {
|
|
128
|
-
result: { f1: { a: 1 }, _: 'resolve' },
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
expect(res3.status).toBe(202);
|
|
132
|
-
|
|
133
|
-
await sleep(1000);
|
|
134
|
-
|
|
135
|
-
const [j2] = await pending.getJobs();
|
|
136
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
137
|
-
expect(j2.result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
138
|
-
|
|
139
|
-
const usersJobsAfter = await UserJobModel.findAll();
|
|
140
|
-
expect(usersJobsAfter.length).toBe(1);
|
|
141
|
-
expect(usersJobsAfter[0].status).toBe(JOB_STATUS.RESOLVED);
|
|
142
|
-
expect(usersJobsAfter[0].result).toEqual({ f1: { a: 1 }, _: 'resolve' });
|
|
143
|
-
|
|
144
|
-
const res4 = await userAgents[0].resource('users_jobs').submit({
|
|
145
|
-
filterByTk: usersJobs[0].id,
|
|
146
|
-
values: {
|
|
147
|
-
result: { f1: { a: 2 }, _: 'resolve' },
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
expect(res4.status).toBe(400);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: 'comments',
|
|
5
|
-
fields: [
|
|
6
|
-
{
|
|
7
|
-
type: 'belongsTo',
|
|
8
|
-
name: 'post',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
type: 'text',
|
|
12
|
-
name: 'content',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: 'integer',
|
|
16
|
-
name: 'status',
|
|
17
|
-
defaultValue: 0,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'hasMany',
|
|
21
|
-
name: 'replies',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
} as CollectionOptions;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: 'posts',
|
|
5
|
-
createdBy: true,
|
|
6
|
-
updatedBy: true,
|
|
7
|
-
fields: [
|
|
8
|
-
{
|
|
9
|
-
type: 'string',
|
|
10
|
-
name: 'title',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
type: 'boolean',
|
|
14
|
-
name: 'published',
|
|
15
|
-
defaultValue: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'integer',
|
|
19
|
-
name: 'read',
|
|
20
|
-
defaultValue: 0,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'belongsTo',
|
|
24
|
-
name: 'category',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: 'hasMany',
|
|
28
|
-
name: 'comments',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: 'belongsToMany',
|
|
32
|
-
name: 'tags',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: 'integer',
|
|
36
|
-
name: 'read',
|
|
37
|
-
defaultValue: 0,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
} as CollectionOptions;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import Database from '@nocobase/database';
|
|
2
|
-
import { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
|
3
|
-
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
|
4
|
-
import { MockServer } from '@nocobase/test';
|
|
5
|
-
|
|
6
|
-
// NOTE: skipped because time is not stable on github ci, but should work in local
|
|
7
|
-
describe('workflow > instructions > manual', () => {
|
|
8
|
-
let app: MockServer;
|
|
9
|
-
let agent;
|
|
10
|
-
let userAgents;
|
|
11
|
-
let db: Database;
|
|
12
|
-
let PostRepo;
|
|
13
|
-
let AnotherPostRepo;
|
|
14
|
-
let WorkflowModel;
|
|
15
|
-
let workflow;
|
|
16
|
-
let UserModel;
|
|
17
|
-
let users;
|
|
18
|
-
let UserJobModel;
|
|
19
|
-
|
|
20
|
-
beforeEach(async () => {
|
|
21
|
-
app = await getApp({
|
|
22
|
-
plugins: ['users', 'auth', 'workflow-manual'],
|
|
23
|
-
});
|
|
24
|
-
// await app.getPlugin('auth').install();
|
|
25
|
-
agent = app.agent();
|
|
26
|
-
db = app.db;
|
|
27
|
-
WorkflowModel = db.getCollection('workflows').model;
|
|
28
|
-
PostRepo = db.getCollection('posts').repository;
|
|
29
|
-
AnotherPostRepo = app.dataSourceManager.dataSources.get('another').collectionManager.getRepository('posts');
|
|
30
|
-
UserModel = db.getCollection('users').model;
|
|
31
|
-
UserJobModel = db.getModel('users_jobs');
|
|
32
|
-
|
|
33
|
-
users = await UserModel.bulkCreate([
|
|
34
|
-
{ id: 2, nickname: 'a' },
|
|
35
|
-
{ id: 3, nickname: 'b' },
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
userAgents = users.map((user) => app.agent().login(user));
|
|
39
|
-
|
|
40
|
-
workflow = await WorkflowModel.create({
|
|
41
|
-
enabled: true,
|
|
42
|
-
type: 'collection',
|
|
43
|
-
config: {
|
|
44
|
-
mode: 1,
|
|
45
|
-
collection: 'posts',
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
afterEach(() => app.destroy());
|
|
51
|
-
|
|
52
|
-
describe('multiple data source', () => {
|
|
53
|
-
describe('create', () => {
|
|
54
|
-
it('create as configured', async () => {
|
|
55
|
-
const n1 = await workflow.createNode({
|
|
56
|
-
type: 'manual',
|
|
57
|
-
config: {
|
|
58
|
-
assignees: [users[0].id],
|
|
59
|
-
forms: {
|
|
60
|
-
f1: {
|
|
61
|
-
type: 'create',
|
|
62
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
63
|
-
collection: 'posts',
|
|
64
|
-
dataSource: 'another',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
71
|
-
|
|
72
|
-
await sleep(500);
|
|
73
|
-
|
|
74
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
75
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
76
|
-
order: [['userId', 'ASC']],
|
|
77
|
-
});
|
|
78
|
-
expect(pendingJobs.length).toBe(1);
|
|
79
|
-
|
|
80
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
81
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
82
|
-
values: {
|
|
83
|
-
result: { f1: { title: 't1' }, _: 'resolve' },
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
expect(res1.status).toBe(202);
|
|
87
|
-
|
|
88
|
-
await sleep(500);
|
|
89
|
-
|
|
90
|
-
const [e1] = await workflow.getExecutions();
|
|
91
|
-
expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
92
|
-
const [j1] = await e1.getJobs();
|
|
93
|
-
expect(j1.status).toBe(JOB_STATUS.RESOLVED);
|
|
94
|
-
expect(j1.result).toMatchObject({ f1: { title: 't1' } });
|
|
95
|
-
|
|
96
|
-
const posts = await AnotherPostRepo.find();
|
|
97
|
-
expect(posts.length).toBe(1);
|
|
98
|
-
expect(posts[0]).toMatchObject({ title: 't1' });
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('save first and then commit', async () => {
|
|
102
|
-
const n1 = await workflow.createNode({
|
|
103
|
-
type: 'manual',
|
|
104
|
-
config: {
|
|
105
|
-
assignees: [users[0].id],
|
|
106
|
-
forms: {
|
|
107
|
-
f1: {
|
|
108
|
-
type: 'create',
|
|
109
|
-
actions: [
|
|
110
|
-
{ status: JOB_STATUS.RESOLVED, key: 'resolve' },
|
|
111
|
-
{ status: JOB_STATUS.PENDING, key: 'pending' },
|
|
112
|
-
],
|
|
113
|
-
collection: 'posts',
|
|
114
|
-
dataSource: 'another',
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const post = await PostRepo.create({ values: { title: 't1' } });
|
|
121
|
-
|
|
122
|
-
await sleep(500);
|
|
123
|
-
|
|
124
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
125
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
126
|
-
order: [['userId', 'ASC']],
|
|
127
|
-
});
|
|
128
|
-
expect(pendingJobs.length).toBe(1);
|
|
129
|
-
|
|
130
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
131
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
132
|
-
values: {
|
|
133
|
-
result: { f1: { title: 't1' }, _: 'pending' },
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
expect(res1.status).toBe(202);
|
|
137
|
-
|
|
138
|
-
await sleep(500);
|
|
139
|
-
|
|
140
|
-
const [e1] = await workflow.getExecutions();
|
|
141
|
-
expect(e1.status).toBe(EXECUTION_STATUS.STARTED);
|
|
142
|
-
const [j1] = await e1.getJobs();
|
|
143
|
-
expect(j1.status).toBe(JOB_STATUS.PENDING);
|
|
144
|
-
expect(j1.result).toMatchObject({ f1: { title: 't1' } });
|
|
145
|
-
|
|
146
|
-
const c1 = await AnotherPostRepo.find();
|
|
147
|
-
expect(c1.length).toBe(0);
|
|
148
|
-
|
|
149
|
-
const res2 = await userAgents[0].resource('users_jobs').submit({
|
|
150
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
151
|
-
values: {
|
|
152
|
-
result: { f1: { title: 't2' }, _: 'resolve' },
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
await sleep(500);
|
|
157
|
-
|
|
158
|
-
const [e2] = await workflow.getExecutions();
|
|
159
|
-
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
160
|
-
const [j2] = await e2.getJobs();
|
|
161
|
-
expect(j2.status).toBe(JOB_STATUS.RESOLVED);
|
|
162
|
-
expect(j2.result).toMatchObject({ f1: { title: 't2' } });
|
|
163
|
-
|
|
164
|
-
const c2 = await AnotherPostRepo.find();
|
|
165
|
-
expect(c2.length).toBe(1);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe('update', () => {
|
|
170
|
-
it('update as configured', async () => {
|
|
171
|
-
const post = await AnotherPostRepo.create({ values: { title: 't1' } });
|
|
172
|
-
|
|
173
|
-
const n1 = await workflow.createNode({
|
|
174
|
-
type: 'manual',
|
|
175
|
-
config: {
|
|
176
|
-
assignees: [users[0].id],
|
|
177
|
-
forms: {
|
|
178
|
-
f1: {
|
|
179
|
-
type: 'update',
|
|
180
|
-
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
|
181
|
-
collection: 'posts',
|
|
182
|
-
dataSource: 'another',
|
|
183
|
-
filter: {
|
|
184
|
-
id: post.id,
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
await PostRepo.create({ values: { title: 't1' } });
|
|
192
|
-
|
|
193
|
-
await sleep(500);
|
|
194
|
-
|
|
195
|
-
const UserJobModel = db.getModel('users_jobs');
|
|
196
|
-
const pendingJobs = await UserJobModel.findAll({
|
|
197
|
-
order: [['userId', 'ASC']],
|
|
198
|
-
});
|
|
199
|
-
expect(pendingJobs.length).toBe(1);
|
|
200
|
-
|
|
201
|
-
const res1 = await userAgents[0].resource('users_jobs').submit({
|
|
202
|
-
filterByTk: pendingJobs[0].get('id'),
|
|
203
|
-
values: {
|
|
204
|
-
result: { f1: { title: 't2' }, _: 'resolve' },
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
expect(res1.status).toBe(202);
|
|
208
|
-
|
|
209
|
-
await sleep(500);
|
|
210
|
-
|
|
211
|
-
const [e2] = await workflow.getExecutions();
|
|
212
|
-
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
213
|
-
const [j1] = await e2.getJobs();
|
|
214
|
-
expect(j1.status).toBe(JOB_STATUS.RESOLVED);
|
|
215
|
-
expect(j1.result).toMatchObject({ f1: { title: 't2' } });
|
|
216
|
-
|
|
217
|
-
const postsAfter = await AnotherPostRepo.find();
|
|
218
|
-
expect(postsAfter.length).toBe(1);
|
|
219
|
-
expect(postsAfter[0]).toMatchObject({ title: 't2' });
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
});
|