@docbrasil/api-systemmanager 1.0.97 → 1.0.98
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/api/admin/doctypes.js +76 -76
- package/api/admin/document.js +332 -332
- package/api/admin/form.js +151 -151
- package/api/admin/index.js +46 -46
- package/api/admin/list.js +133 -133
- package/api/admin/message.js +194 -194
- package/api/admin/notification.js +233 -233
- package/api/admin/organization.js +124 -124
- package/api/admin/plugin.js +116 -116
- package/api/admin/policy.js +78 -78
- package/api/admin/processes.js +370 -370
- package/api/admin/task.js +125 -125
- package/api/admin/user.js +185 -185
- package/api/dispatch.js +101 -101
- package/api/external.js +86 -0
- package/api/general/geoLocation.js +88 -88
- package/api/general/index.js +23 -23
- package/api/login.js +267 -267
- package/api/session.js +85 -85
- package/api/user/datasource.js +144 -144
- package/api/user/document.js +730 -730
- package/api/user/index.js +39 -39
- package/api/user/notification.js +101 -101
- package/api/user/organization.js +230 -230
- package/api/user/process.js +191 -191
- package/api/user/register.js +205 -205
- package/api/user/task.js +201 -202
- package/api/user/task_available.js +135 -135
- package/api/user/user.js +287 -287
- package/api/utils/cypher.js +37 -37
- package/api/utils/promises.js +118 -118
- package/bundleRollup.js +158 -158
- package/dist/bundle.cjs +4878 -4876
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +2453 -2453
- package/doc.md +653 -653
- package/helper/boom.js +487 -487
- package/helper/cryptojs.js +6067 -6067
- package/index.js +87 -85
- package/package-lock.json +4635 -4635
- package/package.json +68 -68
- package/readme.md +25 -25
- package/tests/admin/document.spec.js +45 -45
- package/tests/admin/form.spec.js +74 -74
- package/tests/admin/list.spec.js +86 -86
- package/tests/admin/message.js +92 -92
- package/tests/admin/notification.spec.js +174 -174
- package/tests/admin/pluginspec..js +71 -71
- package/tests/admin/policy.spec.js +71 -71
- package/tests/admin/processes.spec.js +119 -119
- package/tests/admin/users.spec.js +127 -127
- package/tests/documents.spec.js +164 -164
- package/tests/login.spec.js +91 -91
- package/tests/session.spec..js +58 -58
- package/tests/user/documents.js +164 -164
- package/tests/user/organization.js +122 -122
- package/tests/user/process.js +71 -71
- package/tests/user/task_available.js +75 -75
- package/tests/user/user.js +88 -88
package/tests/admin/message.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
|
|
6
|
-
let userId;
|
|
7
|
-
let orgId;
|
|
8
|
-
let sm;
|
|
9
|
-
let session;
|
|
10
|
-
let orgApiKey = '7f8fe8fc-7605-4082-bf83-ca338ecd2fd5';
|
|
11
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
12
|
-
let message = 'emprego.net: Código de validação do seu telefone: 76T5';
|
|
13
|
-
let recipient = '48996011188';
|
|
14
|
-
|
|
15
|
-
const paramsTosendEmail = {
|
|
16
|
-
subject: 'Email de teste',
|
|
17
|
-
message: 'Olá sou um teste <h5>sou um HTML</h5>',
|
|
18
|
-
to: 'thiagoo.anselmoo@gmail.com'
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe('Start API forms', function () {
|
|
22
|
-
before(function (done) {
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
sm = new API();
|
|
26
|
-
done();
|
|
27
|
-
} catch (ex) {
|
|
28
|
-
expect(ex).to.be.empty;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('Login SU', async function () {
|
|
33
|
-
try {
|
|
34
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
35
|
-
|
|
36
|
-
expect(retData).to.not.be.empty;
|
|
37
|
-
expect(retData.auth).to.be.true;
|
|
38
|
-
expect(retData.user).to.be.an('object');
|
|
39
|
-
expect(retData.user).to.be.an('object');
|
|
40
|
-
expect(retData.user).to.not.be.empty;
|
|
41
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
42
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
43
|
-
expect(retData.user.orgId.length).equal(24);
|
|
44
|
-
|
|
45
|
-
session = retData.user.sessionId;
|
|
46
|
-
userId = retData.user._id;
|
|
47
|
-
orgId = retData.user.orgId;
|
|
48
|
-
} catch (ex) {
|
|
49
|
-
expect(ex).to.be.empty;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it.skip('Send SMS', async function () {
|
|
54
|
-
try {
|
|
55
|
-
const paramsToSend = { apiKey: orgApiKey, message, recipient }
|
|
56
|
-
const retData = await sm.admin.message.sendSMS(paramsToSend);
|
|
57
|
-
|
|
58
|
-
expect(retData).to.not.be.empty;
|
|
59
|
-
expect(retData).to.not.be.null;
|
|
60
|
-
expect(retData.success).equal(true);
|
|
61
|
-
expect(retData.send).equal(1);
|
|
62
|
-
} catch (ex) {
|
|
63
|
-
expect(ex).to.be.empty;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('Send Email', async function () {
|
|
68
|
-
try {
|
|
69
|
-
const retData = await sm.admin.message.sendEmail(paramsTosendEmail, session);
|
|
70
|
-
|
|
71
|
-
expect(retData).to.not.be.empty;
|
|
72
|
-
expect(retData).to.not.be.null;
|
|
73
|
-
expect(retData.success).equal(true);
|
|
74
|
-
expect(retData.sent.length).equal(1);
|
|
75
|
-
} catch (ex) {
|
|
76
|
-
expect(ex).to.be.empty;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('Logout user', async function () {
|
|
81
|
-
try {
|
|
82
|
-
const retData = await sm.login.logout(session);
|
|
83
|
-
|
|
84
|
-
expect(retData).to.not.be.empty;
|
|
85
|
-
expect(retData).to.be.an('boolean');
|
|
86
|
-
expect(retData).to.not.be.empty;
|
|
87
|
-
expect(retData).equal(true);
|
|
88
|
-
} catch (ex) {
|
|
89
|
-
expect(ex).to.be.empty;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
|
|
6
|
+
let userId;
|
|
7
|
+
let orgId;
|
|
8
|
+
let sm;
|
|
9
|
+
let session;
|
|
10
|
+
let orgApiKey = '7f8fe8fc-7605-4082-bf83-ca338ecd2fd5';
|
|
11
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
12
|
+
let message = 'emprego.net: Código de validação do seu telefone: 76T5';
|
|
13
|
+
let recipient = '48996011188';
|
|
14
|
+
|
|
15
|
+
const paramsTosendEmail = {
|
|
16
|
+
subject: 'Email de teste',
|
|
17
|
+
message: 'Olá sou um teste <h5>sou um HTML</h5>',
|
|
18
|
+
to: 'thiagoo.anselmoo@gmail.com'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe('Start API forms', function () {
|
|
22
|
+
before(function (done) {
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
sm = new API();
|
|
26
|
+
done();
|
|
27
|
+
} catch (ex) {
|
|
28
|
+
expect(ex).to.be.empty;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Login SU', async function () {
|
|
33
|
+
try {
|
|
34
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
35
|
+
|
|
36
|
+
expect(retData).to.not.be.empty;
|
|
37
|
+
expect(retData.auth).to.be.true;
|
|
38
|
+
expect(retData.user).to.be.an('object');
|
|
39
|
+
expect(retData.user).to.be.an('object');
|
|
40
|
+
expect(retData.user).to.not.be.empty;
|
|
41
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
42
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
43
|
+
expect(retData.user.orgId.length).equal(24);
|
|
44
|
+
|
|
45
|
+
session = retData.user.sessionId;
|
|
46
|
+
userId = retData.user._id;
|
|
47
|
+
orgId = retData.user.orgId;
|
|
48
|
+
} catch (ex) {
|
|
49
|
+
expect(ex).to.be.empty;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it.skip('Send SMS', async function () {
|
|
54
|
+
try {
|
|
55
|
+
const paramsToSend = { apiKey: orgApiKey, message, recipient }
|
|
56
|
+
const retData = await sm.admin.message.sendSMS(paramsToSend);
|
|
57
|
+
|
|
58
|
+
expect(retData).to.not.be.empty;
|
|
59
|
+
expect(retData).to.not.be.null;
|
|
60
|
+
expect(retData.success).equal(true);
|
|
61
|
+
expect(retData.send).equal(1);
|
|
62
|
+
} catch (ex) {
|
|
63
|
+
expect(ex).to.be.empty;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('Send Email', async function () {
|
|
68
|
+
try {
|
|
69
|
+
const retData = await sm.admin.message.sendEmail(paramsTosendEmail, session);
|
|
70
|
+
|
|
71
|
+
expect(retData).to.not.be.empty;
|
|
72
|
+
expect(retData).to.not.be.null;
|
|
73
|
+
expect(retData.success).equal(true);
|
|
74
|
+
expect(retData.sent.length).equal(1);
|
|
75
|
+
} catch (ex) {
|
|
76
|
+
expect(ex).to.be.empty;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('Logout user', async function () {
|
|
81
|
+
try {
|
|
82
|
+
const retData = await sm.login.logout(session);
|
|
83
|
+
|
|
84
|
+
expect(retData).to.not.be.empty;
|
|
85
|
+
expect(retData).to.be.an('boolean');
|
|
86
|
+
expect(retData).to.not.be.empty;
|
|
87
|
+
expect(retData).equal(true);
|
|
88
|
+
} catch (ex) {
|
|
89
|
+
expect(ex).to.be.empty;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
const notificationTotal = 10;
|
|
6
|
-
|
|
7
|
-
let userId;
|
|
8
|
-
let orgId;
|
|
9
|
-
let sm;
|
|
10
|
-
let session;
|
|
11
|
-
let notificationId;
|
|
12
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
13
|
-
|
|
14
|
-
describe('Start API Notification', function () {
|
|
15
|
-
before(function (done) {
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
sm = new API();
|
|
19
|
-
done();
|
|
20
|
-
} catch (ex) {
|
|
21
|
-
expect(ex).to.be.empty;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Login SU', async function () {
|
|
26
|
-
try {
|
|
27
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
28
|
-
|
|
29
|
-
expect(retData).to.not.be.empty;
|
|
30
|
-
expect(retData.auth).to.be.true;
|
|
31
|
-
expect(retData.user).to.be.an('object');
|
|
32
|
-
expect(retData.user).to.be.an('object');
|
|
33
|
-
expect(retData.user).to.not.be.empty;
|
|
34
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
35
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
36
|
-
expect(retData.user.orgId.length).equal(24);
|
|
37
|
-
|
|
38
|
-
session = retData.user.sessionId;
|
|
39
|
-
userId = retData.user._id;
|
|
40
|
-
orgId = retData.user.orgId;
|
|
41
|
-
} catch (ex) {
|
|
42
|
-
expect(ex).to.be.empty;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('Delete notifications by userId', async function () {
|
|
47
|
-
try {
|
|
48
|
-
const params = { id: userId, orgId };
|
|
49
|
-
await sm.admin.notification.findByIdAndRemove(params, session);
|
|
50
|
-
} catch (ex) {
|
|
51
|
-
expect(ex).to.be.empty;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it(`Create ${notificationTotal} notification`, async function () {
|
|
56
|
-
try {
|
|
57
|
-
const params = {
|
|
58
|
-
userId,
|
|
59
|
-
orgId,
|
|
60
|
-
message: {
|
|
61
|
-
text: 'Teste',
|
|
62
|
-
date: new Date()
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
for await (let [idx, count] of new Array(notificationTotal).entries()) {
|
|
67
|
-
params.message.text = `Teste ${idx}`;
|
|
68
|
-
|
|
69
|
-
const retData = await sm.admin.notification.add(params, session);
|
|
70
|
-
|
|
71
|
-
expect(retData).to.not.be.empty;
|
|
72
|
-
expect(retData).to.be.an('object');
|
|
73
|
-
expect(retData).to.include.all.keys('_id', 'userId', 'message', 'created');
|
|
74
|
-
expect(retData._id).to.not.null;
|
|
75
|
-
expect(retData._id).to.not.be.empty;
|
|
76
|
-
expect(retData._id).to.be.an('string');
|
|
77
|
-
|
|
78
|
-
expect(retData.message.text).to.be.an('string');
|
|
79
|
-
expect(retData.message.date).to.be.an('string');
|
|
80
|
-
|
|
81
|
-
notificationId = retData._id;
|
|
82
|
-
}
|
|
83
|
-
} catch (ex) {
|
|
84
|
-
expect(ex).to.be.empty;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('Get notifications by userId', async function () {
|
|
89
|
-
try {
|
|
90
|
-
const params = {
|
|
91
|
-
id: userId,
|
|
92
|
-
orgId
|
|
93
|
-
};
|
|
94
|
-
const retData = await sm.admin.notification.findById(params, session);
|
|
95
|
-
|
|
96
|
-
expect(retData).to.not.be.empty;
|
|
97
|
-
expect(retData).to.be.an('object');
|
|
98
|
-
expect(retData).to.include.all.keys('results', 'total');
|
|
99
|
-
expect(retData.total).to.equal(notificationTotal);
|
|
100
|
-
expect(retData.results).to.not.be.empty;
|
|
101
|
-
expect(retData.results).to.be.an('array');
|
|
102
|
-
} catch (ex) {
|
|
103
|
-
expect(ex).to.be.empty;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('Get notifications by notificationId', async function () {
|
|
108
|
-
try {
|
|
109
|
-
const params = {
|
|
110
|
-
id: notificationId,
|
|
111
|
-
orgId
|
|
112
|
-
};
|
|
113
|
-
const retData = await sm.admin.notification.findById(params, session);
|
|
114
|
-
|
|
115
|
-
expect(retData).to.not.be.empty;
|
|
116
|
-
expect(retData).to.be.an('object');
|
|
117
|
-
expect(retData).to.include.all.keys('results', 'total');
|
|
118
|
-
expect(retData.total).to.equal(1);
|
|
119
|
-
expect(retData.results).to.not.be.empty;
|
|
120
|
-
expect(retData.results).to.be.an('array');
|
|
121
|
-
expect(retData.results[0].message.text).to.equal('Teste 9');
|
|
122
|
-
} catch (ex) {
|
|
123
|
-
expect(ex).to.be.empty;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('Update read all notifications by userId', async function () {
|
|
128
|
-
try {
|
|
129
|
-
const params = {
|
|
130
|
-
id: userId,
|
|
131
|
-
orgId,
|
|
132
|
-
read: true
|
|
133
|
-
};
|
|
134
|
-
const retData = await sm.admin.notification.findByIdAndUpdate(params, session);
|
|
135
|
-
|
|
136
|
-
expect(retData).to.not.be.empty;
|
|
137
|
-
expect(retData).to.be.an('object');
|
|
138
|
-
expect(retData).to.include.all.keys('nModified');
|
|
139
|
-
expect(retData.nModified).to.equal(notificationTotal);
|
|
140
|
-
} catch (ex) {
|
|
141
|
-
expect(ex).to.be.empty;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('Delete notifications by notificationId', async function () {
|
|
146
|
-
try {
|
|
147
|
-
const params = { id: notificationId, orgId };
|
|
148
|
-
const retData = await sm.admin.notification.findByIdAndDelete(params, session);
|
|
149
|
-
|
|
150
|
-
expect(retData).to.not.be.empty;
|
|
151
|
-
expect(retData).to.be.an('object');
|
|
152
|
-
expect(retData).to.include.all.keys('ok', 'deletedCount');
|
|
153
|
-
expect(retData.deletedCount).to.equal(1);
|
|
154
|
-
} catch (ex) {
|
|
155
|
-
expect(ex).to.be.empty;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('Logout user', async function () {
|
|
160
|
-
try {
|
|
161
|
-
const retData = await sm.login.logout(session);
|
|
162
|
-
|
|
163
|
-
expect(retData).to.not.be.empty;
|
|
164
|
-
expect(retData).to.be.an('boolean');
|
|
165
|
-
expect(retData).to.not.be.empty;
|
|
166
|
-
expect(retData).equal(true);
|
|
167
|
-
} catch (ex) {
|
|
168
|
-
expect(ex).to.be.empty;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
const notificationTotal = 10;
|
|
6
|
+
|
|
7
|
+
let userId;
|
|
8
|
+
let orgId;
|
|
9
|
+
let sm;
|
|
10
|
+
let session;
|
|
11
|
+
let notificationId;
|
|
12
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
13
|
+
|
|
14
|
+
describe('Start API Notification', function () {
|
|
15
|
+
before(function (done) {
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
sm = new API();
|
|
19
|
+
done();
|
|
20
|
+
} catch (ex) {
|
|
21
|
+
expect(ex).to.be.empty;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('Login SU', async function () {
|
|
26
|
+
try {
|
|
27
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
28
|
+
|
|
29
|
+
expect(retData).to.not.be.empty;
|
|
30
|
+
expect(retData.auth).to.be.true;
|
|
31
|
+
expect(retData.user).to.be.an('object');
|
|
32
|
+
expect(retData.user).to.be.an('object');
|
|
33
|
+
expect(retData.user).to.not.be.empty;
|
|
34
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
35
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
36
|
+
expect(retData.user.orgId.length).equal(24);
|
|
37
|
+
|
|
38
|
+
session = retData.user.sessionId;
|
|
39
|
+
userId = retData.user._id;
|
|
40
|
+
orgId = retData.user.orgId;
|
|
41
|
+
} catch (ex) {
|
|
42
|
+
expect(ex).to.be.empty;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('Delete notifications by userId', async function () {
|
|
47
|
+
try {
|
|
48
|
+
const params = { id: userId, orgId };
|
|
49
|
+
await sm.admin.notification.findByIdAndRemove(params, session);
|
|
50
|
+
} catch (ex) {
|
|
51
|
+
expect(ex).to.be.empty;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it(`Create ${notificationTotal} notification`, async function () {
|
|
56
|
+
try {
|
|
57
|
+
const params = {
|
|
58
|
+
userId,
|
|
59
|
+
orgId,
|
|
60
|
+
message: {
|
|
61
|
+
text: 'Teste',
|
|
62
|
+
date: new Date()
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
for await (let [idx, count] of new Array(notificationTotal).entries()) {
|
|
67
|
+
params.message.text = `Teste ${idx}`;
|
|
68
|
+
|
|
69
|
+
const retData = await sm.admin.notification.add(params, session);
|
|
70
|
+
|
|
71
|
+
expect(retData).to.not.be.empty;
|
|
72
|
+
expect(retData).to.be.an('object');
|
|
73
|
+
expect(retData).to.include.all.keys('_id', 'userId', 'message', 'created');
|
|
74
|
+
expect(retData._id).to.not.null;
|
|
75
|
+
expect(retData._id).to.not.be.empty;
|
|
76
|
+
expect(retData._id).to.be.an('string');
|
|
77
|
+
|
|
78
|
+
expect(retData.message.text).to.be.an('string');
|
|
79
|
+
expect(retData.message.date).to.be.an('string');
|
|
80
|
+
|
|
81
|
+
notificationId = retData._id;
|
|
82
|
+
}
|
|
83
|
+
} catch (ex) {
|
|
84
|
+
expect(ex).to.be.empty;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('Get notifications by userId', async function () {
|
|
89
|
+
try {
|
|
90
|
+
const params = {
|
|
91
|
+
id: userId,
|
|
92
|
+
orgId
|
|
93
|
+
};
|
|
94
|
+
const retData = await sm.admin.notification.findById(params, session);
|
|
95
|
+
|
|
96
|
+
expect(retData).to.not.be.empty;
|
|
97
|
+
expect(retData).to.be.an('object');
|
|
98
|
+
expect(retData).to.include.all.keys('results', 'total');
|
|
99
|
+
expect(retData.total).to.equal(notificationTotal);
|
|
100
|
+
expect(retData.results).to.not.be.empty;
|
|
101
|
+
expect(retData.results).to.be.an('array');
|
|
102
|
+
} catch (ex) {
|
|
103
|
+
expect(ex).to.be.empty;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('Get notifications by notificationId', async function () {
|
|
108
|
+
try {
|
|
109
|
+
const params = {
|
|
110
|
+
id: notificationId,
|
|
111
|
+
orgId
|
|
112
|
+
};
|
|
113
|
+
const retData = await sm.admin.notification.findById(params, session);
|
|
114
|
+
|
|
115
|
+
expect(retData).to.not.be.empty;
|
|
116
|
+
expect(retData).to.be.an('object');
|
|
117
|
+
expect(retData).to.include.all.keys('results', 'total');
|
|
118
|
+
expect(retData.total).to.equal(1);
|
|
119
|
+
expect(retData.results).to.not.be.empty;
|
|
120
|
+
expect(retData.results).to.be.an('array');
|
|
121
|
+
expect(retData.results[0].message.text).to.equal('Teste 9');
|
|
122
|
+
} catch (ex) {
|
|
123
|
+
expect(ex).to.be.empty;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('Update read all notifications by userId', async function () {
|
|
128
|
+
try {
|
|
129
|
+
const params = {
|
|
130
|
+
id: userId,
|
|
131
|
+
orgId,
|
|
132
|
+
read: true
|
|
133
|
+
};
|
|
134
|
+
const retData = await sm.admin.notification.findByIdAndUpdate(params, session);
|
|
135
|
+
|
|
136
|
+
expect(retData).to.not.be.empty;
|
|
137
|
+
expect(retData).to.be.an('object');
|
|
138
|
+
expect(retData).to.include.all.keys('nModified');
|
|
139
|
+
expect(retData.nModified).to.equal(notificationTotal);
|
|
140
|
+
} catch (ex) {
|
|
141
|
+
expect(ex).to.be.empty;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('Delete notifications by notificationId', async function () {
|
|
146
|
+
try {
|
|
147
|
+
const params = { id: notificationId, orgId };
|
|
148
|
+
const retData = await sm.admin.notification.findByIdAndDelete(params, session);
|
|
149
|
+
|
|
150
|
+
expect(retData).to.not.be.empty;
|
|
151
|
+
expect(retData).to.be.an('object');
|
|
152
|
+
expect(retData).to.include.all.keys('ok', 'deletedCount');
|
|
153
|
+
expect(retData.deletedCount).to.equal(1);
|
|
154
|
+
} catch (ex) {
|
|
155
|
+
expect(ex).to.be.empty;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('Logout user', async function () {
|
|
160
|
+
try {
|
|
161
|
+
const retData = await sm.login.logout(session);
|
|
162
|
+
|
|
163
|
+
expect(retData).to.not.be.empty;
|
|
164
|
+
expect(retData).to.be.an('boolean');
|
|
165
|
+
expect(retData).to.not.be.empty;
|
|
166
|
+
expect(retData).equal(true);
|
|
167
|
+
} catch (ex) {
|
|
168
|
+
expect(ex).to.be.empty;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
|
|
6
|
-
let userId;
|
|
7
|
-
let orgId;
|
|
8
|
-
let sm;
|
|
9
|
-
let session;
|
|
10
|
-
let pluginId = '5ecea0030878f140eee13e3a';
|
|
11
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
12
|
-
|
|
13
|
-
describe('Start API plugin', function () {
|
|
14
|
-
before(function (done) {
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
sm = new API();
|
|
18
|
-
done();
|
|
19
|
-
} catch (ex) {
|
|
20
|
-
expect(ex).to.be.empty;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('Login SU', async function () {
|
|
25
|
-
try {
|
|
26
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
27
|
-
|
|
28
|
-
expect(retData).to.not.be.empty;
|
|
29
|
-
expect(retData.auth).to.be.true;
|
|
30
|
-
expect(retData.user).to.be.an('object');
|
|
31
|
-
expect(retData.user).to.be.an('object');
|
|
32
|
-
expect(retData.user).to.not.be.empty;
|
|
33
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
34
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
35
|
-
expect(retData.user.orgId.length).equal(24);
|
|
36
|
-
|
|
37
|
-
session = retData.user.sessionId;
|
|
38
|
-
userId = retData.user._id;
|
|
39
|
-
orgId = retData.user.orgId;
|
|
40
|
-
} catch (ex) {
|
|
41
|
-
expect(ex).to.be.empty;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('Get plugin by ID', async function () {
|
|
46
|
-
try {
|
|
47
|
-
const retData = await sm.admin.plugin.findById(pluginId, session);
|
|
48
|
-
|
|
49
|
-
expect(retData).to.not.be.empty;
|
|
50
|
-
expect(retData).to.be.an('object');
|
|
51
|
-
expect(retData._id).equal(pluginId);
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
expect(ex).to.be.empty;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('Logout user', async function () {
|
|
58
|
-
try {
|
|
59
|
-
const retData = await sm.login.logout(session);
|
|
60
|
-
|
|
61
|
-
expect(retData).to.not.be.empty;
|
|
62
|
-
expect(retData).to.be.an('object');
|
|
63
|
-
expect(retData.response).to.not.be.empty;
|
|
64
|
-
expect(retData.response).equal('OK');
|
|
65
|
-
} catch (ex) {
|
|
66
|
-
expect(ex).to.be.empty;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
|
|
6
|
+
let userId;
|
|
7
|
+
let orgId;
|
|
8
|
+
let sm;
|
|
9
|
+
let session;
|
|
10
|
+
let pluginId = '5ecea0030878f140eee13e3a';
|
|
11
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
12
|
+
|
|
13
|
+
describe('Start API plugin', function () {
|
|
14
|
+
before(function (done) {
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
sm = new API();
|
|
18
|
+
done();
|
|
19
|
+
} catch (ex) {
|
|
20
|
+
expect(ex).to.be.empty;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('Login SU', async function () {
|
|
25
|
+
try {
|
|
26
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
27
|
+
|
|
28
|
+
expect(retData).to.not.be.empty;
|
|
29
|
+
expect(retData.auth).to.be.true;
|
|
30
|
+
expect(retData.user).to.be.an('object');
|
|
31
|
+
expect(retData.user).to.be.an('object');
|
|
32
|
+
expect(retData.user).to.not.be.empty;
|
|
33
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
34
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
35
|
+
expect(retData.user.orgId.length).equal(24);
|
|
36
|
+
|
|
37
|
+
session = retData.user.sessionId;
|
|
38
|
+
userId = retData.user._id;
|
|
39
|
+
orgId = retData.user.orgId;
|
|
40
|
+
} catch (ex) {
|
|
41
|
+
expect(ex).to.be.empty;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Get plugin by ID', async function () {
|
|
46
|
+
try {
|
|
47
|
+
const retData = await sm.admin.plugin.findById(pluginId, session);
|
|
48
|
+
|
|
49
|
+
expect(retData).to.not.be.empty;
|
|
50
|
+
expect(retData).to.be.an('object');
|
|
51
|
+
expect(retData._id).equal(pluginId);
|
|
52
|
+
} catch (ex) {
|
|
53
|
+
expect(ex).to.be.empty;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('Logout user', async function () {
|
|
58
|
+
try {
|
|
59
|
+
const retData = await sm.login.logout(session);
|
|
60
|
+
|
|
61
|
+
expect(retData).to.not.be.empty;
|
|
62
|
+
expect(retData).to.be.an('object');
|
|
63
|
+
expect(retData.response).to.not.be.empty;
|
|
64
|
+
expect(retData.response).equal('OK');
|
|
65
|
+
} catch (ex) {
|
|
66
|
+
expect(ex).to.be.empty;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|