@tiledesk/tiledesk-server 3.0.1 → 3.1.0
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/.circleci/config.yml +1 -1
- package/CHANGELOG.md +34 -0
- package/Dockerfile +3 -2
- package/Dockerfile-en +3 -2
- package/Dockerfile-jobs +3 -2
- package/Dockerfile-profiler +3 -2
- package/README.md +15 -0
- package/app.js +12 -1
- package/bin/quota-reset +68 -0
- package/bin/quota-restore +86 -0
- package/channels/chat21/chat21Handler.js +50 -34
- package/channels/chat21/chat21JoinTracker.js +43 -0
- package/config/database.js +5 -5
- package/config/native_mcp/native_mcp_servers.json +1 -0
- package/controllers/chatbot.controller.js +80 -27
- package/controllers/intents.controller.js +42 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-chat21-ionic.md +468 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-design-studio.md +1349 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md +1694 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-tybot.md +789 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-server.md +83 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-tybot.md +76 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-chat21-ionic.md +97 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-design-studio.md +72 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-server.md +223 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-tybot.md +121 -0
- package/docs/superpowers/plans/2026-09-29-hitl-pre-branch-ports.md +65 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-design-studio.md +88 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-server.md +103 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-tybot.md +43 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-design-studio.md +80 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-runtime.md +39 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-server.md +106 -0
- package/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md +715 -0
- package/docs/superpowers/specs/2026-09-30-flow-start-points-design.md +156 -0
- package/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md +303 -0
- package/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md +191 -0
- package/event/botEvent.js +12 -1
- package/event/emailEvent.js +3 -0
- package/event/messageEvent.js +44 -0
- package/jobs.js +10 -0
- package/jobsManager.js +19 -0
- package/middleware/errorHandler.js +6 -2
- package/models/analyticResult.js +1 -1
- package/models/channelConstants.js +3 -2
- package/models/quotaUsage.js +71 -0
- package/models/request.js +6 -0
- package/models/requestSnapshot.js +12 -0
- package/models/routerLogger.js +1 -1
- package/models/webhook.js +44 -0
- package/package.json +7 -5
- package/pubmodules/emailNotification/requestNotification.js +14 -22
- package/pubmodules/events/test/eventRoute.js +7 -6
- package/pubmodules/rules/conciergeBot.js +9 -4
- package/routes/auth.js +1 -12
- package/routes/campaigns.js +0 -13
- package/routes/dataTable.js +0 -3
- package/routes/faq_kb.js +12 -1
- package/routes/messagesRoot.js +0 -1
- package/routes/quotes.js +38 -1
- package/routes/request.js +81 -5
- package/routes/users.js +0 -1
- package/routes/webhook.js +160 -8
- package/routes/webhooks.js +276 -6
- package/routes/widgetLoader.js +6 -3
- package/services/QuoteManager.js +77 -16
- package/services/aiService.js +1 -1
- package/services/chatbotService.js +55 -1
- package/services/departmentService.js +60 -43
- package/services/dolphinSchedulerClient.js +116 -0
- package/services/emailService.js +6 -1
- package/services/hitlParticipantListener.js +260 -0
- package/services/participantInviteService.js +302 -0
- package/services/participantRemoveService.js +79 -0
- package/services/quotaSnapshotService.js +1167 -0
- package/services/requestService.js +102 -144
- package/services/scheduledStart/dolphinBackend.js +246 -0
- package/services/scheduledStart/schedulerBackend.js +101 -0
- package/services/scheduledStart/schedulerServiceClient.js +41 -0
- package/services/scheduledStartPublishListener.js +186 -0
- package/services/scheduledStartRules.js +173 -0
- package/services/scheduledStartService.js +130 -0
- package/services/startPointCleanupListener.js +30 -0
- package/services/startPointService.js +158 -0
- package/services/testWsService.js +1 -4
- package/services/updateRequestSnapshotQueued.js +8 -9
- package/services/webhookConversationService.js +185 -0
- package/services/webhookSettingsValidator.js +61 -0
- package/template/email/checkpointReachedEmail.html +5 -0
- package/test/agentPromptsRoute.test.js +3 -2
- package/test/agentTokensQuota.js +237 -0
- package/test/botEventHitlFallback.js +19 -0
- package/test/chat21HandlerJoinWiring.js +59 -0
- package/test/dataTablesRoute.test.js +10 -2
- package/test/dateUtils.test.js +0 -3
- package/test/departmentService.js +8 -12
- package/test/{fileRoute.js → deprecated/_deprecated_fileRoute} +2 -2
- package/test/{kbsettingsRoute.js → deprecated/_deprecated_kbsettingsRoute} +3 -3
- package/test/faqRoute.js +6 -1
- package/test/faqkbRoute.js +14 -10
- package/test/faqkbV3Route.js +1 -1
- package/test/filepRoute.js +4 -50
- package/test/hitlParticipantListener.js +446 -0
- package/test/hitlQueueWiring.js +191 -0
- package/test/hitlWaitingReset.js +124 -0
- package/test/inviteParticipantsRoute.js +492 -0
- package/test/kbRoute.js +1 -1
- package/test/messageRoute.js +33 -21
- package/test/nativemcp.test.js +7 -1
- package/test/openaiRoute.js +2 -8
- package/test/publishFailLoud.test.js +414 -0
- package/test/quotaSnapshots.js +1044 -0
- package/test/removeParticipantsRoute.js +186 -0
- package/test/requestService.js +24 -16
- package/test/requestServiceRemoveParticipant.js +144 -0
- package/test/requestVisibility.test.js +186 -0
- package/test/scheduledStartFacade.js +184 -0
- package/test/scheduledStartHandover.js +95 -0
- package/test/scheduledStartPublish.js +320 -0
- package/test/scheduledStartRoute.js +163 -0
- package/test/scheduledStartRules.js +177 -0
- package/test/scheduledStartRun.js +299 -0
- package/test/scheduledStartSchedulerBackend.js +116 -0
- package/test/scheduledStartService.js +290 -0
- package/test/startPointsCleanup.js +69 -0
- package/test/startPointsRegression.js +169 -0
- package/test/startPointsRoute.js +158 -0
- package/test/webhookConversationRoute.js +347 -0
- package/test/webhookConversationService.js +261 -0
- package/test/webhookConversationTestUtils.js +55 -0
- package/utils/aiUtils.js +95 -1
- package/utils/intentFieldNames.js +192 -0
- package/utils/quotaCliUtil.js +43 -0
- package/utils/requestVisibility.js +355 -0
- package/websocket/webSocketServer.js +36 -31
- /package/test/{imageRoute.js → deprecated/_deprecated_imageRoute} +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
process.env.NODE_ENV = 'test';
|
|
2
|
+
process.env.QUOTES_ENABLED = 'true';
|
|
3
|
+
|
|
4
|
+
const projectService = require('../services/projectService');
|
|
5
|
+
const userService = require('../services/userService');
|
|
6
|
+
const Project = require('../models/project');
|
|
7
|
+
const { QuoteManager, PLANS_LIST } = require('../services/QuoteManager');
|
|
8
|
+
const { computeAgentTokens, AGENT_TOKENS_RATES } = require('../utils/aiUtils');
|
|
9
|
+
|
|
10
|
+
let chai = require('chai');
|
|
11
|
+
let chaiHttp = require('chai-http');
|
|
12
|
+
let server = require('../app');
|
|
13
|
+
let should = chai.should();
|
|
14
|
+
let expect = chai.expect;
|
|
15
|
+
|
|
16
|
+
chai.use(chaiHttp);
|
|
17
|
+
|
|
18
|
+
const projectMock = require('./mock/projectMock');
|
|
19
|
+
|
|
20
|
+
let log = false;
|
|
21
|
+
|
|
22
|
+
function createUserAndProject(name) {
|
|
23
|
+
let email = "test-agent-tokens-" + Date.now() + "-" + Math.floor(Math.random() * 100000) + "@email.com";
|
|
24
|
+
let pwd = "pwd";
|
|
25
|
+
return userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
|
26
|
+
return projectService.create(name, savedUser._id).then((savedProject) => {
|
|
27
|
+
return { email, pwd, savedUser, savedProject };
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('AgentTokensQuota', function () {
|
|
33
|
+
|
|
34
|
+
describe('computeAgentTokens', function () {
|
|
35
|
+
|
|
36
|
+
const rates = { per_usd: 1000000, fallback_multiplier: 1 };
|
|
37
|
+
|
|
38
|
+
it('default rates are 1000000 per USD and fallback multiplier 1', function () {
|
|
39
|
+
expect(AGENT_TOKENS_RATES.per_usd).to.equal(1000000);
|
|
40
|
+
expect(AGENT_TOKENS_RATES.fallback_multiplier).to.equal(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('converts a USD cost with ceil', function () {
|
|
44
|
+
expect(computeAgentTokens({ tokens: 500, cost: { amount: 0.0123451, currency: 'USD' } }, rates))
|
|
45
|
+
.to.deep.equal({ counted: 12346, mode: 'cost' });
|
|
46
|
+
expect(computeAgentTokens({ tokens: 500, cost: { amount: 0.5, currency: 'usd' } }, rates).counted).to.equal(500000);
|
|
47
|
+
expect(computeAgentTokens({ cost: { amount: 0, currency: 'USD' } }, rates)).to.deep.equal({ counted: 0, mode: 'cost' });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('falls back to tokens * multiplier without a usable cost', function () {
|
|
51
|
+
expect(computeAgentTokens({ tokens: 300 }, rates)).to.deep.equal({ counted: 300, mode: 'tokens' });
|
|
52
|
+
expect(computeAgentTokens({ tokens: 300, cost: null }, rates).counted).to.equal(300);
|
|
53
|
+
expect(computeAgentTokens({ tokens: 300, cost: { amount: 1, currency: 'EUR' } }, rates).counted).to.equal(300);
|
|
54
|
+
expect(computeAgentTokens({ tokens: 300, cost: { amount: "1", currency: 'USD' } }, rates).counted).to.equal(300);
|
|
55
|
+
expect(computeAgentTokens({ tokens: 300 }, { per_usd: 1000000, fallback_multiplier: 2.5 }).counted).to.equal(750);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('does not add 1 to exact micro-dollar amounts', function () {
|
|
59
|
+
for (let n of [1, 3, 7, 10, 29, 57, 123, 1001, 2124, 99999, 123457]) {
|
|
60
|
+
let amount = n * 1e-6;
|
|
61
|
+
expect(computeAgentTokens({ cost: { amount: amount, currency: 'USD' } }, rates).counted, String(amount)).to.equal(n);
|
|
62
|
+
}
|
|
63
|
+
expect(computeAgentTokens({ cost: { amount: 0.1 + 0.2, currency: 'USD' } }, rates).counted).to.equal(300000);
|
|
64
|
+
expect(computeAgentTokens({ cost: { amount: 0.0000011, currency: 'USD' } }, rates).counted).to.equal(2);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('rounds the fallback path up', function () {
|
|
68
|
+
expect(computeAgentTokens({ tokens: 3 }, { per_usd: 1000000, fallback_multiplier: 0.5 }).counted).to.equal(2);
|
|
69
|
+
expect(computeAgentTokens({ tokens: 10.2 }, rates).counted).to.equal(11);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('rejects values over the sanity caps or not finite', function () {
|
|
73
|
+
expect(computeAgentTokens({ tokens: 1e9 }, rates).counted).to.equal(1e9);
|
|
74
|
+
expect(computeAgentTokens({ tokens: 1e9 + 1 }, rates).error).to.be.a('string');
|
|
75
|
+
expect(computeAgentTokens({ cost: { amount: 1e4, currency: 'USD' } }, rates).counted).to.equal(1e10);
|
|
76
|
+
expect(computeAgentTokens({ cost: { amount: 1e303, currency: 'USD' } }, rates).error).to.be.a('string');
|
|
77
|
+
expect(computeAgentTokens({ tokens: 10, cost: { amount: 10001, currency: 'USD' } }, rates).error).to.be.a('string');
|
|
78
|
+
expect(computeAgentTokens({ tokens: 1e9 }, { per_usd: 1, fallback_multiplier: 1e308 }).error).to.be.a('string');
|
|
79
|
+
expect(computeAgentTokens({ cost: { amount: 1e4, currency: 'USD' } }, { per_usd: 1e306, fallback_multiplier: 1 }).error).to.be.a('string');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('rejects invalid bodies', function () {
|
|
83
|
+
expect(computeAgentTokens({}, rates).error).to.be.a('string');
|
|
84
|
+
expect(computeAgentTokens({ tokens: -1 }, rates).error).to.be.a('string');
|
|
85
|
+
expect(computeAgentTokens({ tokens: NaN }, rates).error).to.be.a('string');
|
|
86
|
+
expect(computeAgentTokens({ tokens: "12" }, rates).error).to.be.a('string');
|
|
87
|
+
expect(computeAgentTokens({ cost: { amount: 1, currency: 'EUR' } }, rates).error).to.be.a('string');
|
|
88
|
+
expect(computeAgentTokens({ tokens: 10, cost: { amount: -1, currency: 'USD' } }, rates).error).to.be.a('string');
|
|
89
|
+
expect(computeAgentTokens({ tokens: 10, cost: "1 USD" }, rates).error).to.be.a('string');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('invalid env values fall back to defaults', function () {
|
|
93
|
+
const path = require.resolve('../utils/aiUtils');
|
|
94
|
+
const saved = require.cache[path];
|
|
95
|
+
const env = { per: process.env.AGENT_TOKENS_PER_USD, fb: process.env.AGENT_TOKENS_FALLBACK_MULTIPLIER };
|
|
96
|
+
try {
|
|
97
|
+
delete require.cache[path];
|
|
98
|
+
process.env.AGENT_TOKENS_PER_USD = 'abc';
|
|
99
|
+
process.env.AGENT_TOKENS_FALLBACK_MULTIPLIER = '-3';
|
|
100
|
+
expect(require('../utils/aiUtils').AGENT_TOKENS_RATES).to.deep.equal({ per_usd: 1000000, fallback_multiplier: 1 });
|
|
101
|
+
|
|
102
|
+
delete require.cache[path];
|
|
103
|
+
process.env.AGENT_TOKENS_PER_USD = '2000000';
|
|
104
|
+
process.env.AGENT_TOKENS_FALLBACK_MULTIPLIER = '3';
|
|
105
|
+
expect(require('../utils/aiUtils').AGENT_TOKENS_RATES).to.deep.equal({ per_usd: 2000000, fallback_multiplier: 3 });
|
|
106
|
+
} finally {
|
|
107
|
+
if (env.per === undefined) delete process.env.AGENT_TOKENS_PER_USD; else process.env.AGENT_TOKENS_PER_USD = env.per;
|
|
108
|
+
if (env.fb === undefined) delete process.env.AGENT_TOKENS_FALLBACK_MULTIPLIER; else process.env.AGENT_TOKENS_FALLBACK_MULTIPLIER = env.fb;
|
|
109
|
+
require.cache[path] = saved;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('plan limits', function () {
|
|
115
|
+
|
|
116
|
+
it('agent_tokens equals tokens for every plan', function () {
|
|
117
|
+
Object.keys(PLANS_LIST).forEach((plan) => {
|
|
118
|
+
expect(PLANS_LIST[plan].agent_tokens, plan).to.equal(PLANS_LIST[plan].tokens);
|
|
119
|
+
});
|
|
120
|
+
expect(PLANS_LIST.SANDBOX.agent_tokens).to.equal(100000);
|
|
121
|
+
expect(PLANS_LIST.BASIC.agent_tokens).to.equal(2000000);
|
|
122
|
+
expect(PLANS_LIST.STARTER.agent_tokens).to.equal(2000000);
|
|
123
|
+
expect(PLANS_LIST.PREMIUM.agent_tokens).to.equal(5000000);
|
|
124
|
+
expect(PLANS_LIST.PRO.agent_tokens).to.equal(5000000);
|
|
125
|
+
expect(PLANS_LIST.TEAM.agent_tokens).to.equal(10000000);
|
|
126
|
+
expect(PLANS_LIST.BUSINESS.agent_tokens).to.equal(10000000);
|
|
127
|
+
expect(PLANS_LIST.CUSTOM.agent_tokens).to.equal(10000000);
|
|
128
|
+
expect(PLANS_LIST.FREE_TRIAL.agent_tokens).to.equal(5000000);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('getPlanLimits returns agent_tokens and merges the project override', async function () {
|
|
132
|
+
const qm = new QuoteManager({ tdCache: {} });
|
|
133
|
+
let basic = await qm.getPlanLimits(projectMock.mockProjectBasicPlan);
|
|
134
|
+
expect(basic.agent_tokens).to.equal(2000000);
|
|
135
|
+
let premium = await qm.getPlanLimits(projectMock.mockProjectPremiumPlan);
|
|
136
|
+
expect(premium.agent_tokens).to.equal(5000000);
|
|
137
|
+
|
|
138
|
+
let overridden = JSON.parse(JSON.stringify(projectMock.mockProjectBasicPlan));
|
|
139
|
+
overridden.profile.quotes = { agent_tokens: 42 };
|
|
140
|
+
let limits = await qm.getPlanLimits(overridden);
|
|
141
|
+
expect(limits.agent_tokens).to.equal(42);
|
|
142
|
+
expect(limits.tokens).to.equal(2000000);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('routes', function () {
|
|
147
|
+
|
|
148
|
+
it('incr agent_tokens with a USD cost counts ceil(amount * 1e6)', async function () {
|
|
149
|
+
const { email, pwd, savedProject } = await createUserAndProject("agent-tokens-cost");
|
|
150
|
+
let res = await chai.request(server)
|
|
151
|
+
.post('/' + savedProject._id + '/quotes/incr/agent_tokens')
|
|
152
|
+
.auth(email, pwd)
|
|
153
|
+
.send({ tokens: 1500, input_tokens: 1000, output_tokens: 500, cost: { amount: 0.0021234, currency: 'USD' }, model: 'openai/gpt-4o', source: 'vibe-coder' });
|
|
154
|
+
if (log) { console.log(res.body); }
|
|
155
|
+
res.should.have.status(200);
|
|
156
|
+
expect(res.body.counted).to.equal(2124);
|
|
157
|
+
expect(res.body.currentQuote).to.equal(2124);
|
|
158
|
+
expect(res.body.key).to.match(new RegExp('^quotes:agent_tokens:' + savedProject._id + ':'));
|
|
159
|
+
expect(res.body.message).to.equal('value incremented for key ' + res.body.key);
|
|
160
|
+
|
|
161
|
+
res = await chai.request(server)
|
|
162
|
+
.post('/' + savedProject._id + '/quotes/incr/agent_tokens')
|
|
163
|
+
.auth(email, pwd)
|
|
164
|
+
.send({ tokens: 300, cost: null });
|
|
165
|
+
res.should.have.status(200);
|
|
166
|
+
expect(res.body.counted).to.equal(300);
|
|
167
|
+
expect(res.body.currentQuote).to.equal(2424);
|
|
168
|
+
|
|
169
|
+
// the chatbot tokens quota is untouched
|
|
170
|
+
res = await chai.request(server).post('/' + savedProject._id + '/quotes').auth(email, pwd).send({});
|
|
171
|
+
res.should.have.status(200);
|
|
172
|
+
expect(res.body.quotes.tokens.quote).to.equal(0);
|
|
173
|
+
expect(res.body.quotes.agent_tokens).to.deep.equal({ quote: 2424 });
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('incr agent_tokens rejects invalid bodies with 400', async function () {
|
|
177
|
+
const { email, pwd, savedProject } = await createUserAndProject("agent-tokens-400");
|
|
178
|
+
const bodies = [{}, { tokens: 1e10 }, { cost: { amount: 1e303, currency: 'USD' } }, { tokens: -5 }, { tokens: "abc" }, { cost: { amount: 1, currency: 'EUR' } }, { tokens: 1, cost: { amount: -1, currency: 'USD' } }];
|
|
179
|
+
for (let body of bodies) {
|
|
180
|
+
let res = await chai.request(server)
|
|
181
|
+
.post('/' + savedProject._id + '/quotes/incr/agent_tokens')
|
|
182
|
+
.auth(email, pwd)
|
|
183
|
+
.send(body);
|
|
184
|
+
expect(res.status, JSON.stringify(body)).to.equal(400);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('incr of an unknown type answers 400', async function () {
|
|
189
|
+
const { email, pwd, savedProject } = await createUserAndProject("agent-tokens-unknown");
|
|
190
|
+
let res = await chai.request(server)
|
|
191
|
+
.post('/' + savedProject._id + '/quotes/incr/requests')
|
|
192
|
+
.auth(email, pwd)
|
|
193
|
+
.send({ tokens: 10 });
|
|
194
|
+
res.should.have.status(400);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('incr tokens keeps the existing behaviour', async function () {
|
|
198
|
+
const { email, pwd, savedProject } = await createUserAndProject("agent-tokens-tokens");
|
|
199
|
+
let res = await chai.request(server)
|
|
200
|
+
.post('/' + savedProject._id + '/quotes/incr/tokens')
|
|
201
|
+
.auth(email, pwd)
|
|
202
|
+
.send({ tokens: 128, model: 'unknown-model-xyz' });
|
|
203
|
+
res.should.have.status(200);
|
|
204
|
+
expect(res.body.currentQuote).to.equal(128);
|
|
205
|
+
expect(res.body.key).to.match(new RegExp('^quotes:tokens:' + savedProject._id + ':'));
|
|
206
|
+
expect(res.body).to.not.have.property('counted');
|
|
207
|
+
|
|
208
|
+
res = await chai.request(server).post('/' + savedProject._id + '/quotes').auth(email, pwd).send({});
|
|
209
|
+
expect(res.body.quotes.tokens.quote).to.equal(128);
|
|
210
|
+
expect(res.body.quotes.agent_tokens.quote).to.equal(0);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('GET agent_tokens availability honours profile.quotes.agent_tokens', async function () {
|
|
214
|
+
const { email, pwd, savedProject } = await createUserAndProject("agent-tokens-avail");
|
|
215
|
+
await Project.findByIdAndUpdate(savedProject._id, { "profile.quotes": { agent_tokens: 1000 } });
|
|
216
|
+
|
|
217
|
+
let res = await chai.request(server).get('/' + savedProject._id + '/quotes/agent_tokens').auth(email, pwd);
|
|
218
|
+
res.should.have.status(200);
|
|
219
|
+
expect(res.body.isAvailable).to.equal(true);
|
|
220
|
+
|
|
221
|
+
res = await chai.request(server)
|
|
222
|
+
.post('/' + savedProject._id + '/quotes/incr/agent_tokens')
|
|
223
|
+
.auth(email, pwd)
|
|
224
|
+
.send({ tokens: 10, cost: { amount: 0.001, currency: 'USD' } });
|
|
225
|
+
res.should.have.status(200);
|
|
226
|
+
expect(res.body.counted).to.equal(1000);
|
|
227
|
+
|
|
228
|
+
res = await chai.request(server).get('/' + savedProject._id + '/quotes/agent_tokens').auth(email, pwd);
|
|
229
|
+
res.should.have.status(200);
|
|
230
|
+
expect(res.body.isAvailable).to.equal(false);
|
|
231
|
+
|
|
232
|
+
// the chatbot tokens quota is still available
|
|
233
|
+
res = await chai.request(server).get('/' + savedProject._id + '/quotes/tokens').auth(email, pwd);
|
|
234
|
+
expect(res.body.isAvailable).to.equal(true);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
process.env.NODE_ENV = 'test';
|
|
2
|
+
process.env.LOG_LEVEL = 'error';
|
|
3
|
+
|
|
4
|
+
const expect = require('chai').expect;
|
|
5
|
+
// faq_kb and botEvent require each other: load the model first, or faq_kb keeps an empty
|
|
6
|
+
// botEvent when this file is the first to load them and later publish tests fail.
|
|
7
|
+
require('../models/faq_kb');
|
|
8
|
+
const botEvent = require('../event/botEvent');
|
|
9
|
+
|
|
10
|
+
describe('botEvent.shouldForwardSystemMessage', () => {
|
|
11
|
+
it('forwards /start and the HITL fallback system message only', () => {
|
|
12
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: '/start' })).to.equal(true);
|
|
13
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: '\\start' })).to.equal(true);
|
|
14
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: 'x', attributes: { hitl_fallback: true, action: '#noone-id' } })).to.equal(true);
|
|
15
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: 'x', attributes: { action: '#noone-id' } })).to.equal(false);
|
|
16
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: 'x', attributes: { hitl_fallback: true } })).to.equal(false);
|
|
17
|
+
expect(botEvent.shouldForwardSystemMessage({ sender: 'system', text: 'x' })).to.equal(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
process.env.NODE_ENV = 'test';
|
|
2
|
+
// chat21Handler.listen() must route request.participants.join through onParticipantsJoin, which
|
|
3
|
+
// registers the join in chat21JoinTracker; the HITL invite route waits on that registration.
|
|
4
|
+
// listen() is disabled in tests (channelManager): here it is called once and every listener it
|
|
5
|
+
// adds is removed afterwards so the rest of the suite is unaffected.
|
|
6
|
+
const assert = require('assert');
|
|
7
|
+
|
|
8
|
+
// Required lazily (in before): loading the event modules ahead of the app breaks a require cycle
|
|
9
|
+
// for the test files that load after this one.
|
|
10
|
+
let EMITTERS, requestEvent, chat21, chat21JoinTracker, chat21Handler;
|
|
11
|
+
|
|
12
|
+
function snapshot() {
|
|
13
|
+
return EMITTERS.map((emitter) => new Map(emitter.eventNames().map((e) => [e, emitter.listeners(e).slice()])));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('chat21Handler participants.join wiring', function () {
|
|
17
|
+
let before;
|
|
18
|
+
let originalJoin;
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line no-undef
|
|
21
|
+
this.beforeAll(() => {
|
|
22
|
+
EMITTERS = ['messageEvent', 'authEvent', 'botEvent', 'requestEvent', 'groupEvent', 'leadEvent']
|
|
23
|
+
.map((name) => require('../event/' + name));
|
|
24
|
+
requestEvent = require('../event/requestEvent');
|
|
25
|
+
chat21 = require('../channels/chat21/chat21Client');
|
|
26
|
+
chat21JoinTracker = require('../channels/chat21/chat21JoinTracker');
|
|
27
|
+
chat21Handler = require('../channels/chat21/chat21Handler');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
originalJoin = chat21.groups.join;
|
|
32
|
+
chat21.groups.join = () => Promise.resolve({ ok: true });
|
|
33
|
+
before = snapshot();
|
|
34
|
+
chat21Handler.listen();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
chat21.groups.join = originalJoin;
|
|
39
|
+
EMITTERS.forEach((emitter, i) => {
|
|
40
|
+
emitter.eventNames().forEach((e) => {
|
|
41
|
+
const kept = before[i].get(e) || [];
|
|
42
|
+
emitter.listeners(e).filter((l) => !kept.includes(l)).forEach((l) => emitter.removeListener(e, l));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('registers the join in chat21JoinTracker while the event is emitted', async () => {
|
|
48
|
+
const added = requestEvent.listeners('request.participants.join').filter((l) => !(before[3].get('request.participants.join') || []).includes(l));
|
|
49
|
+
assert.strictEqual(added.length, 1, 'listen() adds one request.participants.join listener');
|
|
50
|
+
|
|
51
|
+
const request = { request_id: 'support-group-wiring-' + Date.now(), id_project: 'p1', channelOutbound: { name: 'chat21' } };
|
|
52
|
+
added[0]({ request: request, member: 'agent-1' });
|
|
53
|
+
|
|
54
|
+
const pending = chat21JoinTracker.get(request.request_id, 'agent-1');
|
|
55
|
+
assert.ok(pending, 'join registered in chat21JoinTracker synchronously');
|
|
56
|
+
const settled = await pending;
|
|
57
|
+
assert.strictEqual(settled.ok, true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -187,10 +187,15 @@ describe('Data Tables Route', () => {
|
|
|
187
187
|
const id_table = res.body._id;
|
|
188
188
|
|
|
189
189
|
chai.request(server)
|
|
190
|
-
.
|
|
190
|
+
.post('/' + savedProject._id + '/tables/' + id_table + '/row/insert')
|
|
191
191
|
.auth(email, pwd)
|
|
192
192
|
.send({ data: { name: "John Doe", repo: 100 } })
|
|
193
|
-
.end(() => {
|
|
193
|
+
.end((err, insertRes) => {
|
|
194
|
+
if (err) { console.error("err: ", err); }
|
|
195
|
+
if (log) { console.log("insertRes.body: ", insertRes.body); }
|
|
196
|
+
|
|
197
|
+
insertRes.should.have.status(200);
|
|
198
|
+
|
|
194
199
|
let updateSchema = [
|
|
195
200
|
...res.body.schema,
|
|
196
201
|
{ name: "country", type: "string" }
|
|
@@ -211,6 +216,9 @@ describe('Data Tables Route', () => {
|
|
|
211
216
|
.get('/' + savedProject._id + '/tables/' + id_table + '/rows/list')
|
|
212
217
|
.auth(email, pwd)
|
|
213
218
|
.end((err2, listRes) => {
|
|
219
|
+
if (err2) { console.error("err: ", err2); }
|
|
220
|
+
if (log) { console.log("listRes.body: ", listRes.body); }
|
|
221
|
+
|
|
214
222
|
listRes.should.have.status(200);
|
|
215
223
|
expect(listRes.body[0].name).to.equal("John Doe");
|
|
216
224
|
expect(listRes.body[0].repo).to.equal(100);
|
package/test/dateUtils.test.js
CHANGED
|
@@ -28,9 +28,6 @@ describe('datesUtil', () => {
|
|
|
28
28
|
const timezone = 'Europe/Rome';
|
|
29
29
|
|
|
30
30
|
const res = datesUtil.createDateRangeQuery(startDate, endDate, timezone);
|
|
31
|
-
|
|
32
|
-
console.log(res);
|
|
33
|
-
|
|
34
31
|
expect(res).to.have.property('createdAt');
|
|
35
32
|
expect(res.createdAt).to.have.property('$gte');
|
|
36
33
|
expect(res.createdAt).to.have.property('$lte');
|
|
@@ -8,7 +8,7 @@ var assert = require('chai').assert;
|
|
|
8
8
|
var config = require('../config/database');
|
|
9
9
|
var mongoose = require('mongoose');
|
|
10
10
|
var winston = require('../config/winston');
|
|
11
|
-
|
|
11
|
+
const RoleConstants = require('../models/roleConstants');
|
|
12
12
|
var Project_user = require("../models/project_user");
|
|
13
13
|
var userService = require('../services/userService');
|
|
14
14
|
var departmentService = require('../services/departmentService');
|
|
@@ -41,13 +41,11 @@ describe('DepartmentService()', function () {
|
|
|
41
41
|
userService.signup(email + '3', pwd, "Test Firstname3", "Test lastname3").then(function (savedUser3) {
|
|
42
42
|
projectService.create("createWithAssignedDepartment", savedUser._id).then(function (savedProject) {
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
44
|
var pu1 = new Project_user({
|
|
47
45
|
// _id: new mongoose.Types.ObjectId(),
|
|
48
46
|
id_project: savedProject._id,
|
|
49
47
|
id_user: savedUser2._id,
|
|
50
|
-
role:
|
|
48
|
+
role: RoleConstants.AGENT,
|
|
51
49
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
52
50
|
user_available: true,
|
|
53
51
|
createdBy: savedUser2._id,
|
|
@@ -57,12 +55,11 @@ describe('DepartmentService()', function () {
|
|
|
57
55
|
winston.debug("err", err);
|
|
58
56
|
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
|
59
57
|
|
|
60
|
-
|
|
61
58
|
var pu2 = new Project_user({
|
|
62
59
|
// _id: new mongoose.Types.ObjectId(),
|
|
63
60
|
id_project: savedProject._id,
|
|
64
61
|
id_user: savedUser3._id,
|
|
65
|
-
role:
|
|
62
|
+
role: RoleConstants.AGENT,
|
|
66
63
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
67
64
|
user_available: true,
|
|
68
65
|
createdBy: savedUser3._id,
|
|
@@ -71,12 +68,11 @@ describe('DepartmentService()', function () {
|
|
|
71
68
|
|
|
72
69
|
pu2.save(function (err, savedProject_user3) {
|
|
73
70
|
winston.debug("savedProject_user3", savedProject_user3.toObject());
|
|
74
|
-
|
|
71
|
+
|
|
75
72
|
departmentService.create("PooledDepartment-for-createWithIdWith-createFirstWithAssignedDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
|
76
73
|
|
|
77
74
|
expect(createdDepartment.hasBot).to.equal(false);
|
|
78
75
|
|
|
79
|
-
|
|
80
76
|
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
|
81
77
|
|
|
82
78
|
// getOperators(departmentid, projectid, nobot) {
|
|
@@ -127,7 +123,7 @@ describe('DepartmentService()', function () {
|
|
|
127
123
|
// _id: new mongoose.Types.ObjectId(),
|
|
128
124
|
id_project: savedProject._id,
|
|
129
125
|
id_user: savedUser2._id,
|
|
130
|
-
role:
|
|
126
|
+
role: RoleConstants.AGENT,
|
|
131
127
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
132
128
|
user_available: true,
|
|
133
129
|
createdBy: savedUser2._id,
|
|
@@ -142,7 +138,7 @@ describe('DepartmentService()', function () {
|
|
|
142
138
|
// // _id: new mongoose.Types.ObjectId(),
|
|
143
139
|
// id_project: savedProject._id,
|
|
144
140
|
// id_user: savedUser3._id,
|
|
145
|
-
// role:
|
|
141
|
+
// role: RoleConstants.AGENT,
|
|
146
142
|
// user_available: true,
|
|
147
143
|
// createdBy: savedUser3._id,
|
|
148
144
|
// updatedBy: savedUser3._id,
|
|
@@ -249,7 +245,7 @@ describe('DepartmentService()', function () {
|
|
|
249
245
|
var pu1 = new Project_user({
|
|
250
246
|
id_project: savedProject._id,
|
|
251
247
|
id_user: savedUser2._id,
|
|
252
|
-
role:
|
|
248
|
+
role: RoleConstants.AGENT,
|
|
253
249
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
254
250
|
user_available: false,
|
|
255
251
|
createdBy: savedUser2._id,
|
|
@@ -328,7 +324,7 @@ describe('DepartmentService()', function () {
|
|
|
328
324
|
var pu1 = new Project_user({
|
|
329
325
|
id_project: savedProject._id,
|
|
330
326
|
id_user: savedUser2._id,
|
|
331
|
-
role:
|
|
327
|
+
role: RoleConstants.AGENT,
|
|
332
328
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
333
329
|
user_available: false,
|
|
334
330
|
createdBy: savedUser2._id,
|
|
@@ -5,10 +5,10 @@ process.env.LOG_LEVEL = 'critical';
|
|
|
5
5
|
//Require the dev-dependencies
|
|
6
6
|
let chai = require('chai');
|
|
7
7
|
let chaiHttp = require('chai-http');
|
|
8
|
-
let server = require('
|
|
8
|
+
let server = require('../../app');
|
|
9
9
|
let should = chai.should();
|
|
10
10
|
var fs = require('fs');
|
|
11
|
-
var userService = require('
|
|
11
|
+
var userService = require('../../services/userService');
|
|
12
12
|
|
|
13
13
|
let log = false;
|
|
14
14
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//During the test the env variable is set to test
|
|
2
2
|
process.env.NODE_ENV = 'test';
|
|
3
3
|
|
|
4
|
-
var userService = require('
|
|
5
|
-
var projectService = require('
|
|
4
|
+
var userService = require('../../services/userService');
|
|
5
|
+
var projectService = require('../../services/projectService');
|
|
6
6
|
|
|
7
7
|
let log = false;
|
|
8
8
|
|
|
9
9
|
//Require the dev-dependencies
|
|
10
10
|
let chai = require('chai');
|
|
11
11
|
let chaiHttp = require('chai-http');
|
|
12
|
-
let server = require('
|
|
12
|
+
let server = require('../../app');
|
|
13
13
|
let should = chai.should();
|
|
14
14
|
var fs = require('fs');
|
|
15
15
|
const path = require('path');
|
package/test/faqRoute.js
CHANGED
|
@@ -19,6 +19,7 @@ const path = require('path');
|
|
|
19
19
|
const uuidv4 = require('uuid/v4');
|
|
20
20
|
const project_user = require('../models/project_user');
|
|
21
21
|
const roleConstants = require('../models/roleConstants');
|
|
22
|
+
const cachegoose = require('cachegoose');
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
// chai.config.includeStack = true;
|
|
@@ -301,7 +302,7 @@ describe('FaqKBRoute', () => {
|
|
|
301
302
|
|
|
302
303
|
res.should.have.status(200);
|
|
303
304
|
res.body.should.be.a('array');
|
|
304
|
-
expect(res.body.length).to.equal(
|
|
305
|
+
expect(res.body.length).to.equal(4);
|
|
305
306
|
|
|
306
307
|
let intent = res.body.find(f => f.intent_display_name === 'welcome');
|
|
307
308
|
expect(intent.agents_available).to.equal(false);
|
|
@@ -323,6 +324,9 @@ describe('FaqKBRoute', () => {
|
|
|
323
324
|
|
|
324
325
|
Project_user.findOneAndUpdate({ id_project: savedProject._id, id_user: savedUser._id }, { role: roleConstants.AGENT }, (err, savedProject_user) => {
|
|
325
326
|
|
|
327
|
+
const projectUserCacheKey = savedProject._id + ":project_users:iduser:" + savedUser._id;
|
|
328
|
+
cachegoose.clearCache(projectUserCacheKey, () => {
|
|
329
|
+
|
|
326
330
|
chai.request(server)
|
|
327
331
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
|
328
332
|
.auth(email, pwd)
|
|
@@ -340,6 +344,7 @@ describe('FaqKBRoute', () => {
|
|
|
340
344
|
done();
|
|
341
345
|
|
|
342
346
|
})
|
|
347
|
+
});
|
|
343
348
|
})
|
|
344
349
|
})
|
|
345
350
|
|
package/test/faqkbRoute.js
CHANGED
|
@@ -1129,13 +1129,18 @@ describe('FaqKBRoute', () => {
|
|
|
1129
1129
|
expect(exported.subagents[0]._id).to.equal(source_subagent_id);
|
|
1130
1130
|
expect(exported.subagents[0].id_project).to.be.undefined;
|
|
1131
1131
|
expect(exported.subagents[0].language).to.equal("en");
|
|
1132
|
-
expect(exported.subagents[0].intents.length).to.equal(
|
|
1133
|
-
|
|
1134
|
-
expect(
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1132
|
+
expect(exported.subagents[0].intents.length).to.equal(5);
|
|
1133
|
+
const intentNames = exported.subagents[0].intents.map((intent) => intent.intent_display_name);
|
|
1134
|
+
expect(intentNames).to.have.members([
|
|
1135
|
+
"start",
|
|
1136
|
+
"untitled_block_1",
|
|
1137
|
+
"return",
|
|
1138
|
+
"defaultFallback",
|
|
1139
|
+
"untitled_block_2"
|
|
1140
|
+
]);
|
|
1141
|
+
exported.subagents[0].intents.forEach((intent) => {
|
|
1142
|
+
expect(intent._id).to.be.undefined;
|
|
1143
|
+
});
|
|
1139
1144
|
done();
|
|
1140
1145
|
})
|
|
1141
1146
|
})
|
|
@@ -1675,7 +1680,6 @@ describe('FaqKBRoute', () => {
|
|
|
1675
1680
|
if (err) { console.error("err: ", err); }
|
|
1676
1681
|
if (log) { console.log("res.body", res.body); }
|
|
1677
1682
|
|
|
1678
|
-
console.log("chatbot trashed: ", res.body);
|
|
1679
1683
|
res.should.have.status(200);
|
|
1680
1684
|
res.body.should.be.a('object');
|
|
1681
1685
|
expect(res.body.trashed).to.equal(true);
|
|
@@ -1691,7 +1695,7 @@ describe('FaqKBRoute', () => {
|
|
|
1691
1695
|
|
|
1692
1696
|
res.should.have.status(200);
|
|
1693
1697
|
res.body.should.be.a('array');
|
|
1694
|
-
expect(res.body.length).to.equal(
|
|
1698
|
+
expect(res.body.length).to.equal(4);
|
|
1695
1699
|
expect(res.body[0].trashed).to.equal(true);
|
|
1696
1700
|
expect(res.body[0].trashedAt).to.exist;
|
|
1697
1701
|
|
|
@@ -1922,7 +1926,7 @@ describe('FaqKBRoute', () => {
|
|
|
1922
1926
|
|
|
1923
1927
|
res.should.have.status(200);
|
|
1924
1928
|
res.body.should.be.a('array');
|
|
1925
|
-
res.body.length.should.equal(
|
|
1929
|
+
res.body.length.should.equal(5);
|
|
1926
1930
|
|
|
1927
1931
|
done()
|
|
1928
1932
|
})
|
package/test/faqkbV3Route.js
CHANGED
package/test/filepRoute.js
CHANGED
|
@@ -91,10 +91,11 @@ describe('FileRoute', () => {
|
|
|
91
91
|
if (err) { console.error("err: ", err); }
|
|
92
92
|
if (log) { console.log("res.body", res.body); }
|
|
93
93
|
|
|
94
|
-
res.should.have.status(
|
|
94
|
+
res.should.have.status(201);
|
|
95
95
|
res.body.should.be.a('object');
|
|
96
|
-
expect(res.body.
|
|
97
|
-
expect(res.body.
|
|
96
|
+
expect(res.body.message).to.equal('Image uploaded successfully');
|
|
97
|
+
expect(res.body.filename).to.equal(`uploads%2Fusers%2F${savedUser._id}%2Fimages%2Fphoto.jpg`);
|
|
98
|
+
expect(res.body.thumbnail).to.equal(`uploads%2Fusers%2F${savedUser._id}%2Fimages%2Fthumbnails_200_200-photo.jpg`);
|
|
98
99
|
|
|
99
100
|
done();
|
|
100
101
|
})
|
|
@@ -314,53 +315,6 @@ describe('FileRoute', () => {
|
|
|
314
315
|
})
|
|
315
316
|
});
|
|
316
317
|
|
|
317
|
-
it('post-assets-images-retro-compatibility', (done) => {
|
|
318
|
-
|
|
319
|
-
var email = "test-signup-" + Date.now() + "@email.com";
|
|
320
|
-
var pwd = "pwd";
|
|
321
|
-
|
|
322
|
-
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
323
|
-
projectService.create("test-assets-create", savedUser._id).then(function (savedProject) {
|
|
324
|
-
|
|
325
|
-
chai.request(server)
|
|
326
|
-
.post('/images/users/')
|
|
327
|
-
.auth(email, pwd)
|
|
328
|
-
.set('Content-Type', 'image/jpeg')
|
|
329
|
-
.attach('file', fs.readFileSync('./test/fixtures/test-image.png'), 'test-image.png')
|
|
330
|
-
// .field('delimiter', ';')
|
|
331
|
-
.end((err, res) => {
|
|
332
|
-
|
|
333
|
-
if (err) { console.error("err: ", err); }
|
|
334
|
-
if (log) { console.log("res.body", res.body); }
|
|
335
|
-
|
|
336
|
-
res.should.have.status(201);
|
|
337
|
-
res.body.should.be.a('object');
|
|
338
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
|
339
|
-
expect(res.body.filename).to.not.equal(null);
|
|
340
|
-
expect(res.body.filename).to.containIgnoreSpaces('test-image.png');
|
|
341
|
-
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
|
342
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
|
343
|
-
|
|
344
|
-
let filepath = res.body.filename;
|
|
345
|
-
|
|
346
|
-
chai.request(server)
|
|
347
|
-
.get('/' + savedProject._id + '/files?path=' + filepath)
|
|
348
|
-
.auth(email, pwd)
|
|
349
|
-
.end((err, res) => {
|
|
350
|
-
|
|
351
|
-
if (err) { console.error("err: ", err); }
|
|
352
|
-
if (log) { console.log("res.body", res.body); }
|
|
353
|
-
|
|
354
|
-
res.should.have.status(200);
|
|
355
|
-
expect(res.body).to.be.instanceof(Buffer)
|
|
356
|
-
|
|
357
|
-
done();
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
})
|
|
361
|
-
})
|
|
362
|
-
});
|
|
363
|
-
|
|
364
318
|
});
|
|
365
319
|
|
|
366
320
|
describe('Security', () => {
|