emberflow 1.3.81 → 1.3.83
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/lib/index-utils.js +85 -28
- package/lib/index-utils.js.map +1 -1
- package/lib/index.js +5 -11
- package/lib/index.js.map +1 -1
- package/lib/init-db-structure.d.ts +1 -1
- package/lib/init-db-structure.js +34 -14
- package/lib/init-db-structure.js.map +1 -1
- package/lib/logics/view-logics.js +148 -88
- package/lib/logics/view-logics.js.map +1 -1
- package/lib/sample-custom/db-structure.d.ts +1 -0
- package/lib/sample-custom/db-structure.js +1 -0
- package/lib/sample-custom/db-structure.js.map +1 -1
- package/lib/tests/index-utils.test.js +246 -28
- package/lib/tests/index-utils.test.js.map +1 -1
- package/lib/tests/init-db-structure.test.js +18 -7
- package/lib/tests/init-db-structure.test.js.map +1 -1
- package/lib/tests/logics/view-logics.test.js +165 -48
- package/lib/tests/logics/view-logics.test.js.map +1 -1
- package/lib/types.d.ts +8 -1
- package/lib/utils/paths.d.ts +2 -2
- package/lib/utils/paths.js.map +1 -1
- package/package.json +1 -1
- package/src/sample-custom/db-structure.ts +1 -0
|
@@ -35,7 +35,6 @@ const paths_1 = require("../utils/paths");
|
|
|
35
35
|
const batch_1 = require("../utils/batch");
|
|
36
36
|
const distribution = __importStar(require("../utils/distribution"));
|
|
37
37
|
const forms = __importStar(require("../utils/forms"));
|
|
38
|
-
const indexutils = __importStar(require("../index-utils"));
|
|
39
38
|
const misc = __importStar(require("../utils/misc"));
|
|
40
39
|
const index_utils_1 = require("../index-utils");
|
|
41
40
|
const viewLogics = __importStar(require("../logics/view-logics"));
|
|
@@ -86,36 +85,21 @@ describe("distributeDoc", () => {
|
|
|
86
85
|
queueInstructionsSpy.mockRestore();
|
|
87
86
|
queueRunViewLogicsSpy.mockRestore();
|
|
88
87
|
});
|
|
89
|
-
it("should
|
|
88
|
+
it("should create a document to dstPath", async () => {
|
|
90
89
|
const logicResultDoc = {
|
|
91
|
-
action: "
|
|
90
|
+
action: "create",
|
|
92
91
|
priority: "normal",
|
|
93
92
|
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
93
|
+
doc: { name: "test-doc-name-updated" },
|
|
94
94
|
};
|
|
95
|
+
const expectedData = Object.assign(Object.assign({}, logicResultDoc.doc), { "@id": "test-doc-id", "@dateCreated": expect.any(Timestamp) });
|
|
95
96
|
await indexUtils.distributeDoc(logicResultDoc);
|
|
96
97
|
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
97
98
|
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
98
|
-
expect(dbDoc.
|
|
99
|
-
expect(dbDoc.
|
|
100
|
-
expect(dbDoc.delete).toHaveBeenCalled();
|
|
101
|
-
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
102
|
-
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
103
|
-
});
|
|
104
|
-
it("should delete documents in batch", async () => {
|
|
105
|
-
const batchDeleteSpy = jest.spyOn(batch, "deleteDoc").mockResolvedValue(undefined);
|
|
106
|
-
const logicResultDoc = {
|
|
107
|
-
action: "delete",
|
|
108
|
-
priority: "normal",
|
|
109
|
-
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
110
|
-
};
|
|
111
|
-
await indexUtils.distributeDoc(logicResultDoc, batch);
|
|
112
|
-
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
114
|
-
expect(dbDoc.get).toHaveBeenCalledTimes(1);
|
|
115
|
-
expect(batchDeleteSpy).toHaveBeenCalledTimes(1);
|
|
99
|
+
expect(dbDoc.set).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(dbDoc.set).toHaveBeenCalledWith(expectedData);
|
|
116
101
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
117
102
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
118
|
-
batchDeleteSpy.mockRestore();
|
|
119
103
|
});
|
|
120
104
|
it("should merge a document to dstPath", async () => {
|
|
121
105
|
const logicResultDoc = {
|
|
@@ -157,20 +141,33 @@ describe("distributeDoc", () => {
|
|
|
157
141
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
158
142
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
159
143
|
});
|
|
160
|
-
it("should merge
|
|
161
|
-
const batchSetSpy = jest.spyOn(batch, "update").mockResolvedValue(undefined);
|
|
144
|
+
it("should not merge when document is undefined", async () => {
|
|
162
145
|
const logicResultDoc = {
|
|
163
146
|
action: "merge",
|
|
164
147
|
priority: "normal",
|
|
165
148
|
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
166
149
|
};
|
|
167
|
-
await indexUtils.distributeDoc(logicResultDoc
|
|
150
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
168
151
|
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
169
152
|
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
170
|
-
expect(
|
|
153
|
+
expect(dbDoc.update).not.toHaveBeenCalled();
|
|
154
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
155
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
156
|
+
});
|
|
157
|
+
it("should delete a document from dstPath", async () => {
|
|
158
|
+
const logicResultDoc = {
|
|
159
|
+
action: "delete",
|
|
160
|
+
priority: "normal",
|
|
161
|
+
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
162
|
+
};
|
|
163
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
164
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
165
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
166
|
+
expect(dbDoc.get).toHaveBeenCalledTimes(1);
|
|
167
|
+
expect(dbDoc.delete).toHaveBeenCalledTimes(1);
|
|
168
|
+
expect(dbDoc.delete).toHaveBeenCalled();
|
|
171
169
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
172
170
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
173
|
-
batchSetSpy.mockRestore();
|
|
174
171
|
});
|
|
175
172
|
it("should queue a document to submit form", async () => {
|
|
176
173
|
const queueSubmitFormSpy = jest.spyOn(forms, "queueSubmitForm").mockResolvedValue("test-message-id");
|
|
@@ -189,6 +186,188 @@ describe("distributeDoc", () => {
|
|
|
189
186
|
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(0);
|
|
190
187
|
queueSubmitFormSpy.mockRestore();
|
|
191
188
|
});
|
|
189
|
+
describe("batched", () => {
|
|
190
|
+
it("should create a document to dstPath", async () => {
|
|
191
|
+
const batchSetSpy = jest.spyOn(batch, "set").mockResolvedValue(undefined);
|
|
192
|
+
const logicResultDoc = {
|
|
193
|
+
action: "create",
|
|
194
|
+
priority: "normal",
|
|
195
|
+
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
196
|
+
doc: { name: "test-doc-name-updated" },
|
|
197
|
+
};
|
|
198
|
+
const expectedData = Object.assign(Object.assign({}, logicResultDoc.doc), { "@id": "test-doc-id", "@dateCreated": expect.any(Timestamp) });
|
|
199
|
+
await indexUtils.distributeDoc(logicResultDoc, batch);
|
|
200
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
201
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
202
|
+
expect(batchSetSpy).toHaveBeenCalledTimes(1);
|
|
203
|
+
expect(batchSetSpy.mock.calls[0][1]).toEqual(expectedData);
|
|
204
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
205
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
206
|
+
batchSetSpy.mockRestore();
|
|
207
|
+
});
|
|
208
|
+
it("should merge a document to dstPath", async () => {
|
|
209
|
+
const batchUpdateSpy = jest.spyOn(batch, "update").mockResolvedValue(undefined);
|
|
210
|
+
const logicResultDoc = {
|
|
211
|
+
action: "merge",
|
|
212
|
+
priority: "normal",
|
|
213
|
+
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
214
|
+
doc: { name: "test-doc-name-updated" },
|
|
215
|
+
};
|
|
216
|
+
const expectedData = Object.assign(Object.assign({}, logicResultDoc.doc), { "@id": "test-doc-id" });
|
|
217
|
+
await indexUtils.distributeDoc(logicResultDoc, batch);
|
|
218
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
219
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
220
|
+
expect(batchUpdateSpy).toHaveBeenCalledTimes(1);
|
|
221
|
+
expect(batchUpdateSpy.mock.calls[0][1]).toEqual(expectedData);
|
|
222
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
223
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
224
|
+
batchUpdateSpy.mockRestore();
|
|
225
|
+
});
|
|
226
|
+
it("should a delete document from dstPath", async () => {
|
|
227
|
+
const batchDeleteSpy = jest.spyOn(batch, "deleteDoc").mockResolvedValue(undefined);
|
|
228
|
+
const logicResultDoc = {
|
|
229
|
+
action: "delete",
|
|
230
|
+
priority: "normal",
|
|
231
|
+
dstPath: "/users/test-user-id/documents/test-doc-id",
|
|
232
|
+
};
|
|
233
|
+
await indexUtils.distributeDoc(logicResultDoc, batch);
|
|
234
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
235
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
236
|
+
expect(dbDoc.get).toHaveBeenCalledTimes(1);
|
|
237
|
+
expect(batchDeleteSpy).toHaveBeenCalledTimes(1);
|
|
238
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
239
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
240
|
+
batchDeleteSpy.mockRestore();
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
describe("map destProp", () => {
|
|
244
|
+
it("should create destProp", async () => {
|
|
245
|
+
const logicResultDoc = {
|
|
246
|
+
action: "create",
|
|
247
|
+
priority: "normal",
|
|
248
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#createdBy",
|
|
249
|
+
doc: { name: "test-doc-name-updated" },
|
|
250
|
+
};
|
|
251
|
+
const expectedData = {
|
|
252
|
+
"createdBy": logicResultDoc.doc,
|
|
253
|
+
};
|
|
254
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
255
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
256
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
257
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
258
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
259
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
260
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
261
|
+
});
|
|
262
|
+
it("should update destProp", async () => {
|
|
263
|
+
const logicResultDoc = {
|
|
264
|
+
action: "merge",
|
|
265
|
+
priority: "normal",
|
|
266
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#createdBy",
|
|
267
|
+
doc: { name: "test-doc-name-updated" },
|
|
268
|
+
};
|
|
269
|
+
const expectedData = {
|
|
270
|
+
"createdBy.name": "test-doc-name-updated",
|
|
271
|
+
};
|
|
272
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
273
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
274
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
275
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
276
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
277
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
278
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
279
|
+
});
|
|
280
|
+
it("should delete destProp", async () => {
|
|
281
|
+
const logicResultDoc = {
|
|
282
|
+
action: "delete",
|
|
283
|
+
priority: "normal",
|
|
284
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#createdBy",
|
|
285
|
+
};
|
|
286
|
+
const expectedData = {
|
|
287
|
+
"createdBy": admin.firestore.FieldValue.delete(),
|
|
288
|
+
};
|
|
289
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
290
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
291
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
292
|
+
expect(dbDoc.get).toHaveBeenCalledTimes(1);
|
|
293
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
294
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
295
|
+
expect(dbDoc.delete).not.toHaveBeenCalled();
|
|
296
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
297
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
describe("array map destProp", () => {
|
|
301
|
+
it("should return when destProp id is empty", async () => {
|
|
302
|
+
const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation();
|
|
303
|
+
const logicResultDoc = {
|
|
304
|
+
action: "merge",
|
|
305
|
+
priority: "normal",
|
|
306
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#followers[]",
|
|
307
|
+
doc: { name: "test-doc-name-updated" },
|
|
308
|
+
};
|
|
309
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
310
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("destPropId should not be blank for array map");
|
|
311
|
+
expect(admin.firestore().doc).not.toHaveBeenCalled();
|
|
312
|
+
expect(dbDoc.update).not.toHaveBeenCalled();
|
|
313
|
+
expect(queueRunViewLogicsSpy).not.toHaveBeenCalled();
|
|
314
|
+
});
|
|
315
|
+
it("should create destProp", async () => {
|
|
316
|
+
const logicResultDoc = {
|
|
317
|
+
action: "create",
|
|
318
|
+
priority: "normal",
|
|
319
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#followers[test-another-user]",
|
|
320
|
+
doc: { name: "test-doc-name-updated" },
|
|
321
|
+
};
|
|
322
|
+
const expectedData = {
|
|
323
|
+
"followers.test-another-user": logicResultDoc.doc,
|
|
324
|
+
};
|
|
325
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
326
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
327
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
328
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
329
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
330
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
331
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
332
|
+
});
|
|
333
|
+
it("should update destProp", async () => {
|
|
334
|
+
const logicResultDoc = {
|
|
335
|
+
action: "merge",
|
|
336
|
+
priority: "normal",
|
|
337
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#followers[test-another-user]",
|
|
338
|
+
doc: { name: "test-doc-name-updated" },
|
|
339
|
+
};
|
|
340
|
+
const expectedData = {
|
|
341
|
+
"followers.test-another-user.name": "test-doc-name-updated",
|
|
342
|
+
};
|
|
343
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
344
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
345
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
346
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
347
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
348
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
349
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
350
|
+
});
|
|
351
|
+
it("should delete destProp", async () => {
|
|
352
|
+
const logicResultDoc = {
|
|
353
|
+
action: "delete",
|
|
354
|
+
priority: "normal",
|
|
355
|
+
dstPath: "/users/test-user-id/documents/test-doc-id#followers[test-another-user]",
|
|
356
|
+
};
|
|
357
|
+
const expectedData = {
|
|
358
|
+
"followers.test-another-user": admin.firestore.FieldValue.delete(),
|
|
359
|
+
};
|
|
360
|
+
await indexUtils.distributeDoc(logicResultDoc);
|
|
361
|
+
expect(admin.firestore().doc).toHaveBeenCalledTimes(1);
|
|
362
|
+
expect(admin.firestore().doc).toHaveBeenCalledWith("/users/test-user-id/documents/test-doc-id");
|
|
363
|
+
expect(dbDoc.get).toHaveBeenCalledTimes(1);
|
|
364
|
+
expect(dbDoc.update).toHaveBeenCalledTimes(1);
|
|
365
|
+
expect(dbDoc.update).toHaveBeenCalledWith(expectedData);
|
|
366
|
+
expect(dbDoc.delete).not.toHaveBeenCalled();
|
|
367
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledTimes(1);
|
|
368
|
+
expect(queueRunViewLogicsSpy).toHaveBeenCalledWith(logicResultDoc);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
192
371
|
});
|
|
193
372
|
describe("distribute", () => {
|
|
194
373
|
let dbSpy;
|
|
@@ -410,6 +589,9 @@ describe("runBusinessLogics", () => {
|
|
|
410
589
|
let logicFn1;
|
|
411
590
|
let logicFn2;
|
|
412
591
|
let logicFn3;
|
|
592
|
+
let logicFn4;
|
|
593
|
+
let logicFn5;
|
|
594
|
+
let logicFn6;
|
|
413
595
|
let dbSpy;
|
|
414
596
|
let simulateSubmitFormSpy;
|
|
415
597
|
let createMetricExecutionSpy;
|
|
@@ -419,6 +601,9 @@ describe("runBusinessLogics", () => {
|
|
|
419
601
|
logicFn1 = jest.fn().mockResolvedValue({ status: "finished" });
|
|
420
602
|
logicFn2 = jest.fn().mockResolvedValue({ status: "finished" });
|
|
421
603
|
logicFn3 = jest.fn().mockResolvedValue({ status: "error", message: "Error message" });
|
|
604
|
+
logicFn4 = jest.fn().mockResolvedValue({ status: "finished" });
|
|
605
|
+
logicFn5 = jest.fn().mockResolvedValue({ status: "finished" });
|
|
606
|
+
logicFn6 = jest.fn().mockResolvedValue({ status: "finished" });
|
|
422
607
|
simulateSubmitFormSpy = jest.spyOn(indexUtils._mockable, "simulateSubmitForm").mockResolvedValue();
|
|
423
608
|
createMetricExecutionSpy = jest.spyOn(indexUtils._mockable, "createMetricExecution").mockResolvedValue();
|
|
424
609
|
const dbDoc = {
|
|
@@ -474,12 +659,45 @@ describe("runBusinessLogics", () => {
|
|
|
474
659
|
entities: ["user"],
|
|
475
660
|
logicFn: logicFn3,
|
|
476
661
|
},
|
|
662
|
+
{
|
|
663
|
+
name: "Logic 4",
|
|
664
|
+
actionTypes: ["create"],
|
|
665
|
+
modifiedFields: ["field1"],
|
|
666
|
+
entities: ["user"],
|
|
667
|
+
logicFn: logicFn4,
|
|
668
|
+
addtlFilterFn(actionType) {
|
|
669
|
+
return actionType !== "create";
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
name: "Logic 5",
|
|
674
|
+
actionTypes: ["create"],
|
|
675
|
+
modifiedFields: ["field2"],
|
|
676
|
+
entities: ["user"],
|
|
677
|
+
logicFn: logicFn5,
|
|
678
|
+
addtlFilterFn(actionType, modifiedFields) {
|
|
679
|
+
return !Object.prototype.hasOwnProperty.call(modifiedFields, "field1");
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: "Logic 6",
|
|
684
|
+
actionTypes: ["create"],
|
|
685
|
+
modifiedFields: ["field2"],
|
|
686
|
+
entities: ["user"],
|
|
687
|
+
logicFn: logicFn6,
|
|
688
|
+
addtlFilterFn(actionType, modifiedFields, document) {
|
|
689
|
+
return !Object.prototype.hasOwnProperty.call(document, "field3");
|
|
690
|
+
},
|
|
691
|
+
},
|
|
477
692
|
];
|
|
478
693
|
(0, index_1.initializeEmberFlow)(projectConfig, admin, db_structure_1.dbStructure, db_structure_1.Entity, security_1.securityConfig, validators_1.validatorConfig, logics);
|
|
479
694
|
const runStatus = await indexUtils.runBusinessLogics(actionRef, action, distributeFn);
|
|
480
695
|
expect(logicFn1).toHaveBeenCalledWith(action, new Map(), undefined);
|
|
481
696
|
expect(logicFn2).toHaveBeenCalledWith(action, new Map(), undefined);
|
|
482
697
|
expect(logicFn3).not.toHaveBeenCalled();
|
|
698
|
+
expect(logicFn4).not.toHaveBeenCalled();
|
|
699
|
+
expect(logicFn5).not.toHaveBeenCalled();
|
|
700
|
+
expect(logicFn6).not.toHaveBeenCalled();
|
|
483
701
|
expect(distributeFn).toHaveBeenCalledTimes(1);
|
|
484
702
|
expect(distributeFn).toHaveBeenCalledWith(actionRef, [expect.objectContaining({
|
|
485
703
|
status: "finished",
|
|
@@ -735,7 +953,7 @@ describe("simulateSubmitForm", () => {
|
|
|
735
953
|
now = Timestamp.now();
|
|
736
954
|
jest.spyOn(indexUtils._mockable, "createNowTimestamp").mockReturnValue(now);
|
|
737
955
|
runBusinessLogicsSpy =
|
|
738
|
-
jest.spyOn(
|
|
956
|
+
jest.spyOn(indexUtils, "runBusinessLogics").mockResolvedValue("done");
|
|
739
957
|
});
|
|
740
958
|
afterEach(() => {
|
|
741
959
|
jest.restoreAllMocks();
|