@steedos-labs/content-compliance 0.7.18 → 0.7.20
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/index.js +1 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_review.button.yml +1 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_urgent_review.button.yml +1 -1
- package/package.json +1 -1
- package/lib/actions/collection.d.ts +0 -2
- package/lib/actions/collection.js +0 -26
- package/lib/actions/collection.js.map +0 -1
- package/lib/methods/__tests__/pre_review_flow.test.d.ts +0 -1
- package/lib/methods/__tests__/pre_review_flow.test.js +0 -583
- package/lib/methods/__tests__/pre_review_flow.test.js.map +0 -1
- package/lib/methods/__tests__/pre_review_helpers.test.d.ts +0 -1
- package/lib/methods/__tests__/pre_review_helpers.test.js +0 -306
- package/lib/methods/__tests__/pre_review_helpers.test.js.map +0 -1
- package/lib/methods/task.d.ts +0 -7
- package/lib/methods/task.js +0 -317
- package/lib/methods/task.js.map +0 -1
package/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_review.button.yml
CHANGED
|
@@ -8,7 +8,7 @@ amis_schema: |-
|
|
|
8
8
|
"label": "延后审核",
|
|
9
9
|
"id": "u:pepsico_postpone_review",
|
|
10
10
|
"editorState": "default",
|
|
11
|
-
"visibleOn": "${
|
|
11
|
+
"visibleOn": "${(current_step == 'departmental_review' || current_step == 'personnel_review' || current_step == 'submitter_revisions') && !is_urgent && !ARRAYINCLUDES(person_pending_approve, context.user.user) && ARRAYINCLUDES(person_approved, context.user.user) && !ARRAYINCLUDES(postpone_marker_users, context.user.user) && !ARRAYINCLUDES(review_postponed_users, context.user.user) && !is_skip_approver && ((ARRAYINCLUDES(ns_reviewer, context.user.user) && ns_approval_status == false) || (ARRAYINCLUDES(legal_reviewer, context.user.user) && legal_approval_status == false) || (ARRAYINCLUDES(sra_reviewer, context.user.user) && sra_approval_status == false) || (ARRAYINCLUDES(ca_reviewer, context.user.user) && ca_approval_status == false) || (ARRAYINCLUDES(reviewer, context.user.user) && approval_status == false) || (pre_ns_reviewer == context.user.user && pre_ns_approval_status == false) || (pre_legal_reviewer == context.user.user && pre_legal_approval_status == false) || (pre_sra_reviewer == context.user.user && pre_sra_approval_status == false) || (pre_ca_reviewer == context.user.user && pre_ca_approval_status == false) || (pre_reviewer == context.user.user && pre_approval_status == false)) && formFactor != 'SMALL'}",
|
|
12
12
|
"onEvent": {
|
|
13
13
|
"click": {
|
|
14
14
|
"weight": 0,
|
package/main/default/objects/pepsico_material_approval/buttons/pepsico_urgent_review.button.yml
CHANGED
|
@@ -14,7 +14,7 @@ amis_schema: |-
|
|
|
14
14
|
"label": "加急审核",
|
|
15
15
|
"id": "u:pepsico_urgent_review",
|
|
16
16
|
"editorState": "default",
|
|
17
|
-
"visibleOn": "${
|
|
17
|
+
"visibleOn": "${(current_step == 'departmental_review' || current_step == 'personnel_review') && !is_urgent && context.user.user == owner && (context.user.is_collaborator !== true || canUrgent === true || quota) && formFactor != 'SMALL'}",
|
|
18
18
|
"disabledOn": "${quota && quota.available === 0}",
|
|
19
19
|
"disabledTip": "${quota && quota.available === 0 ? (reason || '暂无加急次数') : ''}",
|
|
20
20
|
"onEvent": {
|
package/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCollection = exports._makeNewID = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var objectql = require("@steedos/objectql");
|
|
6
|
-
function _makeNewID() {
|
|
7
|
-
return objectql.getDataSource('default').adapter._makeNewID();
|
|
8
|
-
}
|
|
9
|
-
exports._makeNewID = _makeNewID;
|
|
10
|
-
function getCollection(name) {
|
|
11
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
12
|
-
var adapter;
|
|
13
|
-
return tslib_1.__generator(this, function (_a) {
|
|
14
|
-
switch (_a.label) {
|
|
15
|
-
case 0:
|
|
16
|
-
adapter = objectql.getDataSource('default').adapter;
|
|
17
|
-
return [4, adapter.connect()];
|
|
18
|
-
case 1:
|
|
19
|
-
_a.sent();
|
|
20
|
-
return [2, adapter.collection(name)];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.getCollection = getCollection;
|
|
26
|
-
//# sourceMappingURL=collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/actions/collection.ts"],"names":[],"mappings":";;;;AAAA,IAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAE9C,SAAgB,UAAU;IACtB,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;AAClE,CAAC;AAFD,gCAEC;AAED,SAAsB,aAAa,CAAC,IAAI;;;;;;oBAC9B,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,OAAO,CAAA;oBACzD,WAAM,OAAO,CAAC,OAAO,EAAE,EAAA;;oBAAvB,SAAuB,CAAA;oBACvB,WAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;;;CAClC;AAJD,sCAIC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
var consts_1 = require("../consts");
|
|
5
|
-
var approval_engine_1 = require("../approval_engine");
|
|
6
|
-
jest.mock('../AI', function () { return ({ callAIReview: jest.fn() }); });
|
|
7
|
-
jest.mock('../notification', function () { return ({ sendNotifications: jest.fn() }); });
|
|
8
|
-
jest.mock('../agent', function () { return ({
|
|
9
|
-
getReviewerAgentsInfo: jest.fn().mockResolvedValue({ userIds: ['agent-1'], clientUserIds: [] }),
|
|
10
|
-
}); });
|
|
11
|
-
jest.mock('../content_hub', function () { return ({ inventoryApprovalMaterial: jest.fn() }); });
|
|
12
|
-
jest.mock('../image_comparison', function () { return ({ isModifiedSubmission: jest.fn().mockResolvedValue(false) }); });
|
|
13
|
-
jest.mock('../material', function () { return (tslib_1.__assign(tslib_1.__assign({}, jest.requireActual('../material')), { getApproverFieldByType: jest.requireActual('../material').getApproverFieldByType, getUserReviewedAllMaterialsStatus: jest.fn().mockResolvedValue(consts_1.ApprovalStatus.approved), uploadBulkDocToOneDrive: jest.fn(), downloadBulkFromOneDriveDoc: jest.fn(), getOneDriveMaterials: jest.fn().mockResolvedValue([]), getPendingUploadsToOneDriveMaterials: jest.fn().mockResolvedValue([]), deleteBulkDocOneDriveShareLink: jest.fn() })); });
|
|
14
|
-
jest.mock('../../const', function () { return ({
|
|
15
|
-
DCO_TYPES: ['MD-PO1-PO18'],
|
|
16
|
-
}); });
|
|
17
|
-
function makeMaterialApproval(overrides) {
|
|
18
|
-
if (overrides === void 0) { overrides = {}; }
|
|
19
|
-
return tslib_1.__assign({ _id: 'test-approval-id', classification: 'Brand KV', social_media: '', followers: 0, kol_classification: '', brief_flow_number: '', brief_flow: '', autonumber: '', name: 'Test Approval', product: 'Test Product', material_type: '', campaign_type: '', launch_time: '', available_channels: '', communication_context: '', content_rule: '', custom_tags: '', expiry_date: '', effective_date: '', bgm: '', subtitles: '', music_copyright: '', font_copyright: '', copyright_music: '', copyright_front: '', material_owner: '', child_files: 'no', kids_reviewer: '', kids_approval_status: '', kids_file_name: '', materials_quantity: 0, reviewer: [], assistance: '', approval_status: '', approval_materials_quantity: 0, ns_reviewer: ['ns-user-1'], ns_assistance: '', ns_approval_status: '', ns_materials_quantity: 0, legal_reviewer: ['legal-user-1'], legal_assistance: '', legal_approval_status: '', legal_materials_quantity: 0, sra_reviewer: ['sra-user-1'], sra_assistance: '', sra_approval_status: '', sra_materials_quantity: 0, ca_reviewer: ['ca-user-1'], ca_assistance: '', ca_approval_status: '', ca_materials_quantity: 0, owner: 'owner-user-1', current_step: consts_1.Step.draft, owner_department: '', review_status: '', person_pending_approve: '', person_view: '', person_approved: '', launch: '', postpone_launch_date: '', aunch_time: '', instance_state: '', space: 'test-space', materials_uploaded_to_onedrive_status: '', materials_xml_to_word_status: '', material_owner_id: '', external_submitted: false, is_external: false, internal_collaborator: '', is_skip_approver: false, pepsico_flow_rule: 'rule-1', shop_tag: '', pre_reviewer: '', pre_ns_reviewer: '', pre_sra_reviewer: '', pre_ca_reviewer: '', pre_legal_reviewer: '', pre_approval_status: '', pre_ns_approval_status: '', pre_sra_approval_status: '', pre_ca_approval_status: '', pre_legal_approval_status: '' }, overrides);
|
|
20
|
-
}
|
|
21
|
-
function createMockDB(options) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
if (options === void 0) { options = {}; }
|
|
24
|
-
var ruleFormula = options.ruleFormula || '${false}';
|
|
25
|
-
var approvalRecords = {};
|
|
26
|
-
var processRecords = [];
|
|
27
|
-
var getObject = function (name) {
|
|
28
|
-
if (name === 'pepsico_material_approval') {
|
|
29
|
-
return {
|
|
30
|
-
findOne: jest.fn(function (id) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
31
|
-
return [2, approvalRecords[id]];
|
|
32
|
-
}); }); }),
|
|
33
|
-
update: jest.fn(function (id, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
34
|
-
return tslib_1.__generator(this, function (_a) {
|
|
35
|
-
approvalRecords[id] = tslib_1.__assign(tslib_1.__assign({}, approvalRecords[id]), data);
|
|
36
|
-
return [2, approvalRecords[id]];
|
|
37
|
-
});
|
|
38
|
-
}); }),
|
|
39
|
-
directUpdate: jest.fn(function (id, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
40
|
-
return tslib_1.__generator(this, function (_a) {
|
|
41
|
-
approvalRecords[id] = tslib_1.__assign(tslib_1.__assign({}, approvalRecords[id]), data);
|
|
42
|
-
return [2, approvalRecords[id]];
|
|
43
|
-
});
|
|
44
|
-
}); }),
|
|
45
|
-
find: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
46
|
-
return [2, Object.values(approvalRecords)];
|
|
47
|
-
}); }); }),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (name === 'pepsico_approval_process') {
|
|
51
|
-
return {
|
|
52
|
-
find: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
53
|
-
return [2, processRecords];
|
|
54
|
-
}); }); }),
|
|
55
|
-
insert: jest.fn(function (data) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
56
|
-
processRecords.push(data);
|
|
57
|
-
return [2, data];
|
|
58
|
-
}); }); }),
|
|
59
|
-
update: jest.fn(function (id, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
60
|
-
var idx;
|
|
61
|
-
return tslib_1.__generator(this, function (_a) {
|
|
62
|
-
idx = processRecords.findIndex(function (p) { return p._id === id; });
|
|
63
|
-
if (idx >= 0)
|
|
64
|
-
processRecords[idx] = tslib_1.__assign(tslib_1.__assign({}, processRecords[idx]), data);
|
|
65
|
-
return [2, processRecords[idx]];
|
|
66
|
-
});
|
|
67
|
-
}); }),
|
|
68
|
-
directUpdate: jest.fn(function (id, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
69
|
-
var idx;
|
|
70
|
-
return tslib_1.__generator(this, function (_a) {
|
|
71
|
-
idx = processRecords.findIndex(function (p) { return p._id === id; });
|
|
72
|
-
if (idx >= 0)
|
|
73
|
-
processRecords[idx] = tslib_1.__assign(tslib_1.__assign({}, processRecords[idx]), data);
|
|
74
|
-
return [2, processRecords[idx]];
|
|
75
|
-
});
|
|
76
|
-
}); }),
|
|
77
|
-
count: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
78
|
-
return [2, processRecords.length];
|
|
79
|
-
}); }); }),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (name === 'pepsico_flow_rule') {
|
|
83
|
-
return {
|
|
84
|
-
findOne: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
85
|
-
return tslib_1.__generator(this, function (_a) {
|
|
86
|
-
return [2, ({
|
|
87
|
-
_id: 'rule-1',
|
|
88
|
-
name: ruleFormula,
|
|
89
|
-
skip_approve: null,
|
|
90
|
-
})];
|
|
91
|
-
});
|
|
92
|
-
}); }),
|
|
93
|
-
find: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
94
|
-
return tslib_1.__generator(this, function (_a) {
|
|
95
|
-
return [2, [{
|
|
96
|
-
_id: 'rule-1',
|
|
97
|
-
name: ruleFormula,
|
|
98
|
-
skip_approve: null,
|
|
99
|
-
}]];
|
|
100
|
-
});
|
|
101
|
-
}); }),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (name === 'pepsico_material') {
|
|
105
|
-
return {
|
|
106
|
-
find: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
107
|
-
return [2, []];
|
|
108
|
-
}); }); }),
|
|
109
|
-
directFind: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
110
|
-
return [2, []];
|
|
111
|
-
}); }); }),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
find: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
116
|
-
return [2, []];
|
|
117
|
-
}); }); }),
|
|
118
|
-
findOne: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
119
|
-
return [2, null];
|
|
120
|
-
}); }); }),
|
|
121
|
-
update: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
122
|
-
return [2, null];
|
|
123
|
-
}); }); }),
|
|
124
|
-
directUpdate: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
125
|
-
return [2, null];
|
|
126
|
-
}); }); }),
|
|
127
|
-
insert: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
128
|
-
return [2, null];
|
|
129
|
-
}); }); }),
|
|
130
|
-
count: jest.fn(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
131
|
-
return [2, 0];
|
|
132
|
-
}); }); }),
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
return { approvalRecords: approvalRecords, processRecords: processRecords, getObject: getObject };
|
|
136
|
-
}
|
|
137
|
-
function createMockCtx(userId, db, options) {
|
|
138
|
-
if (userId === void 0) { userId = 'user-1'; }
|
|
139
|
-
var mockDB = db || createMockDB(options);
|
|
140
|
-
return {
|
|
141
|
-
ctx: {
|
|
142
|
-
meta: {
|
|
143
|
-
user: {
|
|
144
|
-
userId: userId,
|
|
145
|
-
name: 'Test User',
|
|
146
|
-
is_space_admin: false,
|
|
147
|
-
organization: { _id: 'org-1' },
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
getObject: mockDB.getObject,
|
|
151
|
-
},
|
|
152
|
-
db: mockDB,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
describe('submitPreReviewContent', function () {
|
|
156
|
-
describe('validation', function () {
|
|
157
|
-
test('throws on invalid approval status', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
var ctx;
|
|
159
|
-
return tslib_1.__generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
ctx = createMockCtx().ctx;
|
|
163
|
-
return [4, expect((0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', 'invalid')).rejects.toThrow('无效的审核状态')];
|
|
164
|
-
case 1:
|
|
165
|
-
_a.sent();
|
|
166
|
-
return [2];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}); });
|
|
170
|
-
test('throws when current_step is not pre_review', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
171
|
-
var _a, ctx, db, approval;
|
|
172
|
-
return tslib_1.__generator(this, function (_b) {
|
|
173
|
-
switch (_b.label) {
|
|
174
|
-
case 0:
|
|
175
|
-
_a = createMockCtx('pre-user-1'), ctx = _a.ctx, db = _a.db;
|
|
176
|
-
approval = makeMaterialApproval({
|
|
177
|
-
current_step: consts_1.Step.departmental_review,
|
|
178
|
-
person_pending_approve: 'pre-user-1',
|
|
179
|
-
pre_reviewer: 'pre-user-1',
|
|
180
|
-
});
|
|
181
|
-
db.approvalRecords['test-id'] = approval;
|
|
182
|
-
return [4, expect((0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)).rejects.toThrow('当前步骤不是预审步骤')];
|
|
183
|
-
case 1:
|
|
184
|
-
_b.sent();
|
|
185
|
-
return [2];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}); });
|
|
189
|
-
test('throws when user is not a pending pre-reviewer', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
190
|
-
var _a, ctx, db, approval;
|
|
191
|
-
return tslib_1.__generator(this, function (_b) {
|
|
192
|
-
switch (_b.label) {
|
|
193
|
-
case 0:
|
|
194
|
-
_a = createMockCtx('wrong-user'), ctx = _a.ctx, db = _a.db;
|
|
195
|
-
approval = makeMaterialApproval({
|
|
196
|
-
current_step: consts_1.Step.pre_review,
|
|
197
|
-
person_pending_approve: ['pre-user-1'],
|
|
198
|
-
pre_reviewer: 'pre-user-1',
|
|
199
|
-
});
|
|
200
|
-
db.approvalRecords['test-id'] = approval;
|
|
201
|
-
return [4, expect((0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)).rejects.toThrow('您不是当前预审人')];
|
|
202
|
-
case 1:
|
|
203
|
-
_b.sent();
|
|
204
|
-
return [2];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}); });
|
|
208
|
-
test('throws when user cannot be mapped to a pre-review field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
209
|
-
var _a, ctx, db, approval;
|
|
210
|
-
return tslib_1.__generator(this, function (_b) {
|
|
211
|
-
switch (_b.label) {
|
|
212
|
-
case 0:
|
|
213
|
-
_a = createMockCtx('unknown-pre-user'), ctx = _a.ctx, db = _a.db;
|
|
214
|
-
approval = makeMaterialApproval({
|
|
215
|
-
current_step: consts_1.Step.pre_review,
|
|
216
|
-
person_pending_approve: ['unknown-pre-user'],
|
|
217
|
-
});
|
|
218
|
-
db.approvalRecords['test-id'] = approval;
|
|
219
|
-
return [4, expect((0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)).rejects.toThrow('无法确定预审字段')];
|
|
220
|
-
case 1:
|
|
221
|
-
_b.sent();
|
|
222
|
-
return [2];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}); });
|
|
226
|
-
});
|
|
227
|
-
describe('field mapping', function () {
|
|
228
|
-
test('maps pre_reviewer user to pre_approval_status field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
229
|
-
var _a, ctx, db, approval, e_1;
|
|
230
|
-
return tslib_1.__generator(this, function (_b) {
|
|
231
|
-
switch (_b.label) {
|
|
232
|
-
case 0:
|
|
233
|
-
_a = createMockCtx('pre-user-1'), ctx = _a.ctx, db = _a.db;
|
|
234
|
-
approval = makeMaterialApproval({
|
|
235
|
-
_id: 'test-id',
|
|
236
|
-
current_step: consts_1.Step.pre_review,
|
|
237
|
-
person_pending_approve: ['pre-user-1'],
|
|
238
|
-
pre_reviewer: 'pre-user-1',
|
|
239
|
-
pre_approval_status: '',
|
|
240
|
-
});
|
|
241
|
-
db.approvalRecords['test-id'] = approval;
|
|
242
|
-
_b.label = 1;
|
|
243
|
-
case 1:
|
|
244
|
-
_b.trys.push([1, 3, , 4]);
|
|
245
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
246
|
-
case 2:
|
|
247
|
-
_b.sent();
|
|
248
|
-
return [3, 4];
|
|
249
|
-
case 3:
|
|
250
|
-
e_1 = _b.sent();
|
|
251
|
-
expect(e_1.message).not.toContain('无法确定预审字段');
|
|
252
|
-
return [3, 4];
|
|
253
|
-
case 4: return [2];
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}); });
|
|
257
|
-
test('maps pre_ns_reviewer user to pre_ns_approval_status field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
258
|
-
var _a, ctx, db, approval, e_2;
|
|
259
|
-
return tslib_1.__generator(this, function (_b) {
|
|
260
|
-
switch (_b.label) {
|
|
261
|
-
case 0:
|
|
262
|
-
_a = createMockCtx('pre-ns-user'), ctx = _a.ctx, db = _a.db;
|
|
263
|
-
approval = makeMaterialApproval({
|
|
264
|
-
_id: 'test-id',
|
|
265
|
-
current_step: consts_1.Step.pre_review,
|
|
266
|
-
person_pending_approve: ['pre-ns-user'],
|
|
267
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
268
|
-
});
|
|
269
|
-
db.approvalRecords['test-id'] = approval;
|
|
270
|
-
_b.label = 1;
|
|
271
|
-
case 1:
|
|
272
|
-
_b.trys.push([1, 3, , 4]);
|
|
273
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
274
|
-
case 2:
|
|
275
|
-
_b.sent();
|
|
276
|
-
return [3, 4];
|
|
277
|
-
case 3:
|
|
278
|
-
e_2 = _b.sent();
|
|
279
|
-
expect(e_2.message).not.toContain('无法确定预审字段');
|
|
280
|
-
return [3, 4];
|
|
281
|
-
case 4: return [2];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}); });
|
|
285
|
-
test('maps pre_legal_reviewer user to pre_legal_approval_status field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
286
|
-
var _a, ctx, db, approval, e_3;
|
|
287
|
-
return tslib_1.__generator(this, function (_b) {
|
|
288
|
-
switch (_b.label) {
|
|
289
|
-
case 0:
|
|
290
|
-
_a = createMockCtx('pre-legal-user'), ctx = _a.ctx, db = _a.db;
|
|
291
|
-
approval = makeMaterialApproval({
|
|
292
|
-
_id: 'test-id',
|
|
293
|
-
current_step: consts_1.Step.pre_review,
|
|
294
|
-
person_pending_approve: ['pre-legal-user'],
|
|
295
|
-
pre_legal_reviewer: 'pre-legal-user',
|
|
296
|
-
});
|
|
297
|
-
db.approvalRecords['test-id'] = approval;
|
|
298
|
-
_b.label = 1;
|
|
299
|
-
case 1:
|
|
300
|
-
_b.trys.push([1, 3, , 4]);
|
|
301
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
302
|
-
case 2:
|
|
303
|
-
_b.sent();
|
|
304
|
-
return [3, 4];
|
|
305
|
-
case 3:
|
|
306
|
-
e_3 = _b.sent();
|
|
307
|
-
expect(e_3.message).not.toContain('无法确定预审字段');
|
|
308
|
-
return [3, 4];
|
|
309
|
-
case 4: return [2];
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}); });
|
|
313
|
-
test('maps pre_sra_reviewer user to pre_sra_approval_status field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
314
|
-
var _a, ctx, db, approval, e_4;
|
|
315
|
-
return tslib_1.__generator(this, function (_b) {
|
|
316
|
-
switch (_b.label) {
|
|
317
|
-
case 0:
|
|
318
|
-
_a = createMockCtx('pre-sra-user'), ctx = _a.ctx, db = _a.db;
|
|
319
|
-
approval = makeMaterialApproval({
|
|
320
|
-
_id: 'test-id',
|
|
321
|
-
current_step: consts_1.Step.pre_review,
|
|
322
|
-
person_pending_approve: ['pre-sra-user'],
|
|
323
|
-
pre_sra_reviewer: 'pre-sra-user',
|
|
324
|
-
});
|
|
325
|
-
db.approvalRecords['test-id'] = approval;
|
|
326
|
-
_b.label = 1;
|
|
327
|
-
case 1:
|
|
328
|
-
_b.trys.push([1, 3, , 4]);
|
|
329
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
330
|
-
case 2:
|
|
331
|
-
_b.sent();
|
|
332
|
-
return [3, 4];
|
|
333
|
-
case 3:
|
|
334
|
-
e_4 = _b.sent();
|
|
335
|
-
expect(e_4.message).not.toContain('无法确定预审字段');
|
|
336
|
-
return [3, 4];
|
|
337
|
-
case 4: return [2];
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}); });
|
|
341
|
-
test('maps pre_ca_reviewer user to pre_ca_approval_status field', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
342
|
-
var _a, ctx, db, approval, e_5;
|
|
343
|
-
return tslib_1.__generator(this, function (_b) {
|
|
344
|
-
switch (_b.label) {
|
|
345
|
-
case 0:
|
|
346
|
-
_a = createMockCtx('pre-ca-user'), ctx = _a.ctx, db = _a.db;
|
|
347
|
-
approval = makeMaterialApproval({
|
|
348
|
-
_id: 'test-id',
|
|
349
|
-
current_step: consts_1.Step.pre_review,
|
|
350
|
-
person_pending_approve: ['pre-ca-user'],
|
|
351
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
352
|
-
});
|
|
353
|
-
db.approvalRecords['test-id'] = approval;
|
|
354
|
-
_b.label = 1;
|
|
355
|
-
case 1:
|
|
356
|
-
_b.trys.push([1, 3, , 4]);
|
|
357
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
358
|
-
case 2:
|
|
359
|
-
_b.sent();
|
|
360
|
-
return [3, 4];
|
|
361
|
-
case 3:
|
|
362
|
-
e_5 = _b.sent();
|
|
363
|
-
expect(e_5.message).not.toContain('无法确定预审字段');
|
|
364
|
-
return [3, 4];
|
|
365
|
-
case 4: return [2];
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
}); });
|
|
369
|
-
test('delegates can be resolved via approval_process record type', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
370
|
-
var _a, ctx, db, approval, e_6;
|
|
371
|
-
return tslib_1.__generator(this, function (_b) {
|
|
372
|
-
switch (_b.label) {
|
|
373
|
-
case 0:
|
|
374
|
-
_a = createMockCtx('delegate-user'), ctx = _a.ctx, db = _a.db;
|
|
375
|
-
approval = makeMaterialApproval({
|
|
376
|
-
_id: 'test-id',
|
|
377
|
-
current_step: consts_1.Step.pre_review,
|
|
378
|
-
person_pending_approve: ['delegate-user'],
|
|
379
|
-
});
|
|
380
|
-
db.approvalRecords['test-id'] = approval;
|
|
381
|
-
db.processRecords.push({
|
|
382
|
-
_id: 'process-1',
|
|
383
|
-
owner: 'delegate-user',
|
|
384
|
-
pepsico_material_approval: 'test-id',
|
|
385
|
-
current_step: consts_1.Step.pre_review,
|
|
386
|
-
space: 'test-space',
|
|
387
|
-
approved: 'progess',
|
|
388
|
-
type: consts_1.ProcessApprovalType.PreNS,
|
|
389
|
-
});
|
|
390
|
-
_b.label = 1;
|
|
391
|
-
case 1:
|
|
392
|
-
_b.trys.push([1, 3, , 4]);
|
|
393
|
-
return [4, (0, approval_engine_1.submitPreReviewContent)(ctx, 'test-id', consts_1.ApprovalStatus.approved)];
|
|
394
|
-
case 2:
|
|
395
|
-
_b.sent();
|
|
396
|
-
return [3, 4];
|
|
397
|
-
case 3:
|
|
398
|
-
e_6 = _b.sent();
|
|
399
|
-
expect(e_6.message).not.toContain('无法确定预审字段');
|
|
400
|
-
return [3, 4];
|
|
401
|
-
case 4: return [2];
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
}); });
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
describe('approvalContent — pre-review step', function () {
|
|
408
|
-
test('personnel pre-review: approves and advances to personnel_review', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
409
|
-
var db, ctx, approval, result;
|
|
410
|
-
return tslib_1.__generator(this, function (_a) {
|
|
411
|
-
switch (_a.label) {
|
|
412
|
-
case 0:
|
|
413
|
-
db = createMockDB({ ruleFormula: '${true}' });
|
|
414
|
-
ctx = createMockCtx('pre-user-1', db).ctx;
|
|
415
|
-
approval = makeMaterialApproval({
|
|
416
|
-
_id: 'test-id',
|
|
417
|
-
current_step: consts_1.Step.pre_review,
|
|
418
|
-
person_pending_approve: ['pre-user-1'],
|
|
419
|
-
pre_reviewer: 'pre-user-1',
|
|
420
|
-
pre_approval_status: '',
|
|
421
|
-
pepsico_flow_rule: 'rule-1',
|
|
422
|
-
});
|
|
423
|
-
db.approvalRecords['test-id'] = approval;
|
|
424
|
-
return [4, approval_engine_1.approvalContent.call({}, ctx, 'test-id', { approveField: 'pre_approval_status' })];
|
|
425
|
-
case 1:
|
|
426
|
-
result = _a.sent();
|
|
427
|
-
expect(result).toEqual({});
|
|
428
|
-
expect(db.approvalRecords['test-id'].current_step).toBe(consts_1.Step.personnel_review);
|
|
429
|
-
return [2];
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
}); });
|
|
433
|
-
test('departmental pre-review: waits for all pre-reviewers to complete', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
434
|
-
var db, ctx, approval, result;
|
|
435
|
-
return tslib_1.__generator(this, function (_a) {
|
|
436
|
-
switch (_a.label) {
|
|
437
|
-
case 0:
|
|
438
|
-
db = createMockDB({ ruleFormula: '${false}' });
|
|
439
|
-
ctx = createMockCtx('pre-ns-user', db).ctx;
|
|
440
|
-
approval = makeMaterialApproval({
|
|
441
|
-
_id: 'test-id',
|
|
442
|
-
current_step: consts_1.Step.pre_review,
|
|
443
|
-
person_pending_approve: ['pre-ns-user', 'pre-ca-user'],
|
|
444
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
445
|
-
pre_ns_approval_status: '',
|
|
446
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
447
|
-
pre_ca_approval_status: '',
|
|
448
|
-
pepsico_flow_rule: 'rule-1',
|
|
449
|
-
});
|
|
450
|
-
db.approvalRecords['test-id'] = approval;
|
|
451
|
-
return [4, approval_engine_1.approvalContent.call({}, ctx, 'test-id', { approveField: 'pre_ns_approval_status' })];
|
|
452
|
-
case 1:
|
|
453
|
-
result = _a.sent();
|
|
454
|
-
expect(result).toEqual({});
|
|
455
|
-
return [2];
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}); });
|
|
459
|
-
});
|
|
460
|
-
describe('rejectContent — pre-review step', function () {
|
|
461
|
-
test('departmental pre-review rejection: waits for all pre-reviewers', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
462
|
-
var db, ctx, approval, result;
|
|
463
|
-
return tslib_1.__generator(this, function (_a) {
|
|
464
|
-
switch (_a.label) {
|
|
465
|
-
case 0:
|
|
466
|
-
db = createMockDB({ ruleFormula: '${false}' });
|
|
467
|
-
ctx = createMockCtx('pre-ns-user', db).ctx;
|
|
468
|
-
approval = makeMaterialApproval({
|
|
469
|
-
_id: 'test-id',
|
|
470
|
-
current_step: consts_1.Step.pre_review,
|
|
471
|
-
person_pending_approve: ['pre-ns-user', 'pre-ca-user'],
|
|
472
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
473
|
-
pre_ns_approval_status: '',
|
|
474
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
475
|
-
pre_ca_approval_status: '',
|
|
476
|
-
pepsico_flow_rule: 'rule-1',
|
|
477
|
-
});
|
|
478
|
-
db.approvalRecords['test-id'] = approval;
|
|
479
|
-
return [4, approval_engine_1.rejectContent.call({}, ctx, 'test-id', { approveField: 'pre_ns_approval_status' })];
|
|
480
|
-
case 1:
|
|
481
|
-
result = _a.sent();
|
|
482
|
-
expect(result).toEqual({});
|
|
483
|
-
return [2];
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}); });
|
|
487
|
-
});
|
|
488
|
-
describe('Pre-review departmental aggregation', function () {
|
|
489
|
-
test('all departments approved → proceeds to departmental_review (approved)', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
490
|
-
var db, ctx, approval, result, updatedRecord;
|
|
491
|
-
return tslib_1.__generator(this, function (_a) {
|
|
492
|
-
switch (_a.label) {
|
|
493
|
-
case 0:
|
|
494
|
-
db = createMockDB({ ruleFormula: '${false}' });
|
|
495
|
-
ctx = createMockCtx('pre-ns-user', db).ctx;
|
|
496
|
-
approval = makeMaterialApproval({
|
|
497
|
-
_id: 'test-id',
|
|
498
|
-
current_step: consts_1.Step.pre_review,
|
|
499
|
-
person_pending_approve: ['pre-ns-user'],
|
|
500
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
501
|
-
pre_ns_approval_status: '',
|
|
502
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
503
|
-
pre_ca_approval_status: true,
|
|
504
|
-
pepsico_flow_rule: 'rule-1',
|
|
505
|
-
});
|
|
506
|
-
db.approvalRecords['test-id'] = approval;
|
|
507
|
-
return [4, approval_engine_1.approvalContent.call({}, ctx, 'test-id', { approveField: 'pre_ns_approval_status' })];
|
|
508
|
-
case 1:
|
|
509
|
-
result = _a.sent();
|
|
510
|
-
expect(result).toEqual({});
|
|
511
|
-
updatedRecord = db.approvalRecords['test-id'];
|
|
512
|
-
expect(updatedRecord.current_step).toBe(consts_1.Step.departmental_review);
|
|
513
|
-
return [2];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
}); });
|
|
517
|
-
test('some departments rejected → marks rejected depts, advances if others can proceed', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
518
|
-
var db, ctx, approval, result, updated;
|
|
519
|
-
return tslib_1.__generator(this, function (_a) {
|
|
520
|
-
switch (_a.label) {
|
|
521
|
-
case 0:
|
|
522
|
-
db = createMockDB({ ruleFormula: '${false}' });
|
|
523
|
-
ctx = createMockCtx('pre-ca-user', db).ctx;
|
|
524
|
-
approval = makeMaterialApproval({
|
|
525
|
-
_id: 'test-id',
|
|
526
|
-
current_step: consts_1.Step.pre_review,
|
|
527
|
-
person_pending_approve: ['pre-ca-user'],
|
|
528
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
529
|
-
pre_ns_approval_status: true,
|
|
530
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
531
|
-
pre_ca_approval_status: '',
|
|
532
|
-
pepsico_flow_rule: 'rule-1',
|
|
533
|
-
});
|
|
534
|
-
db.approvalRecords['test-id'] = approval;
|
|
535
|
-
return [4, approval_engine_1.rejectContent.call({}, ctx, 'test-id', { approveField: 'pre_ca_approval_status' })];
|
|
536
|
-
case 1:
|
|
537
|
-
result = _a.sent();
|
|
538
|
-
expect(result).toEqual({});
|
|
539
|
-
updated = db.approvalRecords['test-id'];
|
|
540
|
-
expect(updated.ca_approval_status).toBe(false);
|
|
541
|
-
expect(updated.current_step).toBe(consts_1.Step.departmental_review);
|
|
542
|
-
return [2];
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
}); });
|
|
546
|
-
test('all departments rejected and no non-pre-review depts → rejects to submitter_revisions', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
547
|
-
var db, ctx, approval, result, updated;
|
|
548
|
-
return tslib_1.__generator(this, function (_a) {
|
|
549
|
-
switch (_a.label) {
|
|
550
|
-
case 0:
|
|
551
|
-
db = createMockDB({ ruleFormula: '${false}' });
|
|
552
|
-
ctx = createMockCtx('pre-ca-user', db).ctx;
|
|
553
|
-
approval = makeMaterialApproval({
|
|
554
|
-
_id: 'test-id',
|
|
555
|
-
current_step: consts_1.Step.pre_review,
|
|
556
|
-
person_pending_approve: ['pre-ca-user'],
|
|
557
|
-
pre_ns_reviewer: 'pre-ns-user',
|
|
558
|
-
pre_ns_approval_status: false,
|
|
559
|
-
pre_legal_reviewer: 'pre-legal-user',
|
|
560
|
-
pre_legal_approval_status: false,
|
|
561
|
-
pre_sra_reviewer: 'pre-sra-user',
|
|
562
|
-
pre_sra_approval_status: false,
|
|
563
|
-
pre_ca_reviewer: 'pre-ca-user',
|
|
564
|
-
pre_ca_approval_status: '',
|
|
565
|
-
pepsico_flow_rule: 'rule-1',
|
|
566
|
-
});
|
|
567
|
-
db.approvalRecords['test-id'] = approval;
|
|
568
|
-
return [4, approval_engine_1.rejectContent.call({}, ctx, 'test-id', { approveField: 'pre_ca_approval_status' })];
|
|
569
|
-
case 1:
|
|
570
|
-
result = _a.sent();
|
|
571
|
-
expect(result).toEqual({});
|
|
572
|
-
updated = db.approvalRecords['test-id'];
|
|
573
|
-
expect(updated.ns_approval_status).toBe(false);
|
|
574
|
-
expect(updated.legal_approval_status).toBe(false);
|
|
575
|
-
expect(updated.sra_approval_status).toBe(false);
|
|
576
|
-
expect(updated.ca_approval_status).toBe(false);
|
|
577
|
-
expect(updated.current_step).toBe(consts_1.Step.submitter_revisions);
|
|
578
|
-
return [2];
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
}); });
|
|
582
|
-
});
|
|
583
|
-
//# sourceMappingURL=pre_review_flow.test.js.map
|