@tiledesk/tiledesk-server 2.9.31 → 2.9.33
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/CHANGELOG.md +13 -0
- package/config/labels/widget.json +15 -0
- package/deploy.sh +1 -1
- package/models/kb_setting.js +53 -1
- package/package.json +3 -3
- package/routes/kb.js +205 -35
- package/routes/project.js +108 -1
- package/routes/request.js +85 -94
- package/services/openaiService.js +6 -2
- package/test/kbRoute.js +319 -37
- package/test/projectRoute.js +41 -0
package/test/kbRoute.js
CHANGED
|
@@ -58,7 +58,6 @@ describe('KbRoute', () => {
|
|
|
58
58
|
expect(res.body.length).to.equal(1);
|
|
59
59
|
|
|
60
60
|
let namespace_id = res.body[0].id;
|
|
61
|
-
console.log("namespace_id: ", namespace_id);
|
|
62
61
|
|
|
63
62
|
let kb = {
|
|
64
63
|
name: "example_name5",
|
|
@@ -93,6 +92,128 @@ describe('KbRoute', () => {
|
|
|
93
92
|
|
|
94
93
|
})
|
|
95
94
|
|
|
95
|
+
it('create-new-text-kb', (done) => {
|
|
96
|
+
|
|
97
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
98
|
+
var pwd = "pwd";
|
|
99
|
+
|
|
100
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
101
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
102
|
+
|
|
103
|
+
chai.request(server)
|
|
104
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
105
|
+
.auth(email, pwd)
|
|
106
|
+
.end((err, res) => {
|
|
107
|
+
|
|
108
|
+
if (err) { console.error("err: ", err); }
|
|
109
|
+
if (log) { console.log("get namespaces res.body: ", res.body); }
|
|
110
|
+
|
|
111
|
+
res.should.have.status(200);
|
|
112
|
+
expect(res.body.length).to.equal(1);
|
|
113
|
+
|
|
114
|
+
let namespace_id = res.body[0].id;
|
|
115
|
+
console.log("namespace_id: ", namespace_id);
|
|
116
|
+
|
|
117
|
+
let kb = {
|
|
118
|
+
name: "example_text1",
|
|
119
|
+
type: "text",
|
|
120
|
+
source: "example_text1",
|
|
121
|
+
content: "Example text",
|
|
122
|
+
namespace: namespace_id
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
chai.request(server)
|
|
126
|
+
.post('/' + savedProject._id + '/kb')
|
|
127
|
+
.auth(email, pwd)
|
|
128
|
+
.send(kb) // can be empty
|
|
129
|
+
.end((err, res) => {
|
|
130
|
+
|
|
131
|
+
if (err) { console.error("err: ", err); }
|
|
132
|
+
if (log) { console.log("create kb res.body: ", res.body); }
|
|
133
|
+
console.log("create kb res.body: ", res.body);
|
|
134
|
+
res.should.have.status(200);
|
|
135
|
+
res.body.should.be.a('object');
|
|
136
|
+
expect(res.body.value.id_project).to.equal(res.body.value.namespace)
|
|
137
|
+
expect(res.body.value.name).to.equal("example_text1")
|
|
138
|
+
expect(res.body.value.type).to.equal("text")
|
|
139
|
+
expect(res.body.value.source).to.equal("example_text1")
|
|
140
|
+
expect(res.body.value.status).to.equal(-1)
|
|
141
|
+
expect(typeof res.body.value.scrape_type === "undefined").to.be.true;
|
|
142
|
+
expect(typeof res.body.value.scrape_options === "undefined").to.be.true;
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
done();
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('get-kb-chunks', (done) => {
|
|
154
|
+
|
|
155
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
156
|
+
var pwd = "pwd";
|
|
157
|
+
|
|
158
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
159
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
160
|
+
|
|
161
|
+
chai.request(server)
|
|
162
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
163
|
+
.auth(email, pwd)
|
|
164
|
+
.end((err, res) => {
|
|
165
|
+
|
|
166
|
+
if (err) { console.error("err: ", err); }
|
|
167
|
+
if (log) { console.log("get namespaces res.body: ", res.body); }
|
|
168
|
+
|
|
169
|
+
res.should.have.status(200);
|
|
170
|
+
expect(res.body.length).to.equal(1);
|
|
171
|
+
|
|
172
|
+
let namespace_id = res.body[0].id;
|
|
173
|
+
|
|
174
|
+
let kb = {
|
|
175
|
+
name: "example_text1",
|
|
176
|
+
type: "text",
|
|
177
|
+
source: "example_text1",
|
|
178
|
+
content: "Example text",
|
|
179
|
+
namespace: namespace_id
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
chai.request(server)
|
|
183
|
+
.post('/' + savedProject._id + '/kb')
|
|
184
|
+
.auth(email, pwd)
|
|
185
|
+
.send(kb) // can be empty
|
|
186
|
+
.end((err, res) => {
|
|
187
|
+
|
|
188
|
+
if (err) { console.error("err: ", err); }
|
|
189
|
+
if (log) { console.log("create kb res.body: ", res.body); }
|
|
190
|
+
console.log("create kb res.body: ", res.body);
|
|
191
|
+
res.should.have.status(200);
|
|
192
|
+
res.body.should.be.a('object');
|
|
193
|
+
|
|
194
|
+
let content_id = res.body.value._id;
|
|
195
|
+
|
|
196
|
+
chai.request(server)
|
|
197
|
+
.get('/' + savedProject._id + '/kb/namespace/' + namespace_id + '/chunks/' + content_id)
|
|
198
|
+
.auth(email, pwd)
|
|
199
|
+
.end((err, res) => {
|
|
200
|
+
|
|
201
|
+
if (err) { console.error("err: ", err )};
|
|
202
|
+
if (log) { console.log("res.body: ", res.body )};
|
|
203
|
+
|
|
204
|
+
res.should.have.status(200);
|
|
205
|
+
//expect(res.body.length).to.equal(1);
|
|
206
|
+
|
|
207
|
+
done();
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
})
|
|
216
|
+
|
|
96
217
|
it('get-with-queries', (done) => {
|
|
97
218
|
|
|
98
219
|
var email = "test-signup-" + Date.now() + "@email.com";
|
|
@@ -172,14 +293,14 @@ describe('KbRoute', () => {
|
|
|
172
293
|
if (log) { console.log("create kb3 res.body: ", res.body); }
|
|
173
294
|
res.should.have.status(200);
|
|
174
295
|
|
|
175
|
-
let query = "?status
|
|
176
|
-
//let query = "";
|
|
177
|
-
console.log("query: ", query);
|
|
296
|
+
let query = "?status=-1&type=url&limit=5&page=0&direction=-1&sortField=updatedAt&search=example&namespace=" + namespace_id;
|
|
297
|
+
//let query = "?namespace=" + namespace_id;
|
|
178
298
|
|
|
179
299
|
chai.request(server)
|
|
180
300
|
.get('/' + savedProject._id + "/kb" + query)
|
|
181
301
|
.auth(email, pwd)
|
|
182
302
|
.end((err, res) => {
|
|
303
|
+
if (err) { console.error("err: ", err)}
|
|
183
304
|
if (log) { console.log("getall res.body: ", res.body); }
|
|
184
305
|
res.should.have.status(200);
|
|
185
306
|
res.body.should.be.a('object');
|
|
@@ -187,7 +308,7 @@ describe('KbRoute', () => {
|
|
|
187
308
|
expect(res.body.kbs.length).to.equal(2);
|
|
188
309
|
expect(res.body.count).to.equal(2);
|
|
189
310
|
res.body.query.should.be.a('object');
|
|
190
|
-
expect(res.body.query.status).to.equal(
|
|
311
|
+
expect(res.body.query.status).to.equal(-1);
|
|
191
312
|
expect(res.body.query.limit).to.equal(5);
|
|
192
313
|
expect(res.body.query.page).to.equal(0);
|
|
193
314
|
expect(res.body.query.direction).to.equal(-1);
|
|
@@ -255,7 +376,6 @@ describe('KbRoute', () => {
|
|
|
255
376
|
let namespace_id = "fakenamespaceid";
|
|
256
377
|
|
|
257
378
|
let query = "?status=100&type=url&limit=5&page=0&direction=-1&sortField=updatedAt&search=example&namespace=" + namespace_id;
|
|
258
|
-
console.log("query: ", query);
|
|
259
379
|
|
|
260
380
|
chai.request(server)
|
|
261
381
|
.get('/' + savedProject._id + "/kb" + query)
|
|
@@ -308,7 +428,6 @@ describe('KbRoute', () => {
|
|
|
308
428
|
|
|
309
429
|
if (err) { console.error("err: ", err); }
|
|
310
430
|
if (log) { console.log("res.body: ", res.body) }
|
|
311
|
-
console.log("res.body: ", res.body)
|
|
312
431
|
|
|
313
432
|
res.should.have.status(200);
|
|
314
433
|
|
|
@@ -357,6 +476,7 @@ describe('KbRoute', () => {
|
|
|
357
476
|
|
|
358
477
|
}).timeout(10000)
|
|
359
478
|
|
|
479
|
+
|
|
360
480
|
/**
|
|
361
481
|
* If you try to add content to a namespace that does not belong to the selected project and
|
|
362
482
|
* the project has at least one namesapce, it returns 403 forbidden.
|
|
@@ -435,6 +555,7 @@ describe('KbRoute', () => {
|
|
|
435
555
|
|
|
436
556
|
if (err) { console.error("err: ", err); }
|
|
437
557
|
if (log) { console.log("res.body: ", res.body) }
|
|
558
|
+
console.log("res.body: ", res.body)
|
|
438
559
|
|
|
439
560
|
res.should.have.status(200);
|
|
440
561
|
expect(res.body.length).to.equal(4)
|
|
@@ -448,6 +569,97 @@ describe('KbRoute', () => {
|
|
|
448
569
|
|
|
449
570
|
}).timeout(10000)
|
|
450
571
|
|
|
572
|
+
it('add-multiple-urls-with-scrape-option-success-type-4', (done) => {
|
|
573
|
+
|
|
574
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
575
|
+
var pwd = "pwd";
|
|
576
|
+
|
|
577
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
578
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
579
|
+
|
|
580
|
+
chai.request(server)
|
|
581
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
582
|
+
.auth(email, pwd)
|
|
583
|
+
.end((err, res) => {
|
|
584
|
+
|
|
585
|
+
if (err) { console.error("err: ", err); }
|
|
586
|
+
if (log) { console.log("res.body: ", res.body) }
|
|
587
|
+
|
|
588
|
+
res.should.have.status(200)
|
|
589
|
+
expect(res.body.length).to.equal(1);
|
|
590
|
+
|
|
591
|
+
let namespace_id = res.body[0].id;
|
|
592
|
+
|
|
593
|
+
chai.request(server)
|
|
594
|
+
.post('/' + savedProject._id + '/kb/multi?namespace=' + namespace_id)
|
|
595
|
+
.auth(email, pwd)
|
|
596
|
+
.send({ list:["https://gethelp.tiledesk.com/article"], scrape_type: 4, scrape_options: { tags_to_extract: ["article","p"], unwanted_tags:["script","style"], unwanted_classnames:["header","related-articles"]}})
|
|
597
|
+
.end((err, res) => {
|
|
598
|
+
|
|
599
|
+
if (err) { console.error("err: ", err); }
|
|
600
|
+
if (log) { console.log("res.body: ", res.body) }
|
|
601
|
+
console.log("res.body: ", res.body)
|
|
602
|
+
res.should.have.status(200);
|
|
603
|
+
expect(res.body.length).to.equal(1)
|
|
604
|
+
expect(res.body[0].scrape_type).to.equal(4)
|
|
605
|
+
expect(typeof res.body[0].scrape_options === "undefined").to.be.false;
|
|
606
|
+
expect(res.body[0].scrape_options.tags_to_extract.length).to.equal(2);
|
|
607
|
+
expect(res.body[0].scrape_options.unwanted_tags.length).to.equal(2);
|
|
608
|
+
expect(res.body[0].scrape_options.unwanted_classnames.length).to.equal(2);
|
|
609
|
+
|
|
610
|
+
done();
|
|
611
|
+
|
|
612
|
+
})
|
|
613
|
+
})
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
}).timeout(10000)
|
|
618
|
+
|
|
619
|
+
it('add-multiple-urls-with-scrape-option-success-type-3', (done) => {
|
|
620
|
+
|
|
621
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
622
|
+
var pwd = "pwd";
|
|
623
|
+
|
|
624
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
625
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
626
|
+
|
|
627
|
+
chai.request(server)
|
|
628
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
629
|
+
.auth(email, pwd)
|
|
630
|
+
.end((err, res) => {
|
|
631
|
+
|
|
632
|
+
if (err) { console.error("err: ", err); }
|
|
633
|
+
if (log) { console.log("res.body: ", res.body) }
|
|
634
|
+
|
|
635
|
+
res.should.have.status(200)
|
|
636
|
+
expect(res.body.length).to.equal(1);
|
|
637
|
+
|
|
638
|
+
let namespace_id = res.body[0].id;
|
|
639
|
+
|
|
640
|
+
chai.request(server)
|
|
641
|
+
.post('/' + savedProject._id + '/kb/multi?namespace=' + namespace_id)
|
|
642
|
+
.auth(email, pwd)
|
|
643
|
+
.send({ list:["https://gethelp.tiledesk.com/article"], scrape_type: 3 })
|
|
644
|
+
.end((err, res) => {
|
|
645
|
+
|
|
646
|
+
if (err) { console.error("err: ", err); }
|
|
647
|
+
if (log) { console.log("res.body: ", res.body) }
|
|
648
|
+
console.log("res.body: ", res.body)
|
|
649
|
+
res.should.have.status(200);
|
|
650
|
+
expect(res.body.length).to.equal(1)
|
|
651
|
+
expect(res.body[0].scrape_type).to.equal(3)
|
|
652
|
+
expect(typeof res.body[0].scrape_options === "undefined").to.be.true;
|
|
653
|
+
|
|
654
|
+
done();
|
|
655
|
+
|
|
656
|
+
})
|
|
657
|
+
})
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
}).timeout(10000)
|
|
662
|
+
|
|
451
663
|
it('expand-sitemap', (done) => {
|
|
452
664
|
|
|
453
665
|
var email = "test-signup-" + Date.now() + "@email.com";
|
|
@@ -1098,41 +1310,41 @@ describe('KbRoute', () => {
|
|
|
1098
1310
|
// }).timeout(10000)
|
|
1099
1311
|
|
|
1100
1312
|
// Ask KB
|
|
1101
|
-
|
|
1313
|
+
it('askkb-key-from-env', (done) => {
|
|
1102
1314
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1315
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
1316
|
+
var pwd = "pwd";
|
|
1105
1317
|
|
|
1106
|
-
|
|
1107
|
-
|
|
1318
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
|
1319
|
+
projectService.create("test-kb-qa", savedUser._id).then((savedProject) => {
|
|
1108
1320
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1321
|
+
chai.request(server)
|
|
1322
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
1323
|
+
.auth(email, pwd)
|
|
1324
|
+
.end((err, res) => {
|
|
1113
1325
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
// console.log("namespace created..")
|
|
1326
|
+
if (err) { console.error("err: ", err); }
|
|
1327
|
+
if (log) { console.log("get all namespaces res.body: ", res.body); }
|
|
1118
1328
|
|
|
1119
|
-
|
|
1120
|
-
// .post('/' + savedProject._id + "/kb/qa")
|
|
1121
|
-
// .auth(email, pwd)
|
|
1122
|
-
// .send({ model: "gpt-4o", namespace: savedProject._id, question: "sample question" })
|
|
1123
|
-
// .end((err, res) => {
|
|
1329
|
+
console.log("namespace created..")
|
|
1124
1330
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1331
|
+
chai.request(server)
|
|
1332
|
+
.post('/' + savedProject._id + "/kb/qa")
|
|
1333
|
+
.auth(email, pwd)
|
|
1334
|
+
.send({ model: "gpt-4o", namespace: savedProject._id, question: "sample question", advancedPrompt: true, system_context: "You are a robot coming from future" })
|
|
1335
|
+
.end((err, res) => {
|
|
1130
1336
|
|
|
1337
|
+
if (err) { console.error("err: ", err) };
|
|
1338
|
+
if (log) { console.log("res.body: ", res.body) };
|
|
1339
|
+
console.log("res.body: ", res.body)
|
|
1340
|
+
done();
|
|
1341
|
+
})
|
|
1131
1342
|
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1343
|
+
|
|
1344
|
+
})
|
|
1345
|
+
})
|
|
1346
|
+
})
|
|
1347
|
+
}).timeout(10000)
|
|
1136
1348
|
|
|
1137
1349
|
|
|
1138
1350
|
it('webhook', (done) => {
|
|
@@ -1215,7 +1427,7 @@ describe('KbRoute', () => {
|
|
|
1215
1427
|
* Get all namespaces of a project.
|
|
1216
1428
|
* If there isn't namespaces for a project_id, the default namespace is created and returned.
|
|
1217
1429
|
*/
|
|
1218
|
-
it('get-namespaces', (done) => {
|
|
1430
|
+
it('get-namespaces-1', (done) => {
|
|
1219
1431
|
|
|
1220
1432
|
var email = "test-signup-" + Date.now() + "@email.com";
|
|
1221
1433
|
var pwd = "pwd";
|
|
@@ -1238,6 +1450,8 @@ describe('KbRoute', () => {
|
|
|
1238
1450
|
//expect(res.body[0]._id).to.equal(undefined);
|
|
1239
1451
|
expect(res.body[0].id).to.equal(savedProject._id.toString());
|
|
1240
1452
|
expect(res.body[0].name).to.equal("Default");
|
|
1453
|
+
should.exist(res.body[0].engine)
|
|
1454
|
+
expect(res.body[0].engine.name).to.equal('pinecone')
|
|
1241
1455
|
|
|
1242
1456
|
done();
|
|
1243
1457
|
|
|
@@ -1318,6 +1532,76 @@ describe('KbRoute', () => {
|
|
|
1318
1532
|
});
|
|
1319
1533
|
})
|
|
1320
1534
|
|
|
1535
|
+
it('create-namespaces-with-engine', (done) => {
|
|
1536
|
+
|
|
1537
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
1538
|
+
var pwd = "pwd";
|
|
1539
|
+
|
|
1540
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
1541
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
1542
|
+
|
|
1543
|
+
// Get all namespaces. Create default namespace and return.
|
|
1544
|
+
chai.request(server)
|
|
1545
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
1546
|
+
.auth(email, pwd)
|
|
1547
|
+
.end((err, res) => {
|
|
1548
|
+
|
|
1549
|
+
if (err) { console.error("err: ", err); }
|
|
1550
|
+
if (log) { console.log("get all namespaces res.body: ", res.body); }
|
|
1551
|
+
|
|
1552
|
+
res.should.have.status(200);
|
|
1553
|
+
res.body.should.be.a('array');
|
|
1554
|
+
expect(res.body.length).to.equal(1);
|
|
1555
|
+
should.not.exist(res.body[0]._id);
|
|
1556
|
+
expect(res.body[0].id).to.equal(savedProject._id.toString());
|
|
1557
|
+
expect(res.body[0].name).to.equal("Default");
|
|
1558
|
+
should.exist(res.body[0].engine)
|
|
1559
|
+
expect(res.body[0].engine.name).to.equal('pinecone');
|
|
1560
|
+
expect(res.body[0].engine.type).to.equal('pod');
|
|
1561
|
+
|
|
1562
|
+
// Create another namespace
|
|
1563
|
+
chai.request(server)
|
|
1564
|
+
.post('/' + savedProject._id + '/kb/namespace')
|
|
1565
|
+
.auth(email, pwd)
|
|
1566
|
+
.send({ name: "MyCustomNamespace" })
|
|
1567
|
+
.end((err, res) => {
|
|
1568
|
+
|
|
1569
|
+
if (err) { console.error("err: ", err) }
|
|
1570
|
+
if (log) { console.log("create new namespace res.body: ", res.body) }
|
|
1571
|
+
|
|
1572
|
+
res.should.have.status(200);
|
|
1573
|
+
res.body.should.be.a('object');
|
|
1574
|
+
should.not.exist(res.body._id)
|
|
1575
|
+
should.exist(res.body.id)
|
|
1576
|
+
expect(res.body.name).to.equal('MyCustomNamespace');
|
|
1577
|
+
should.exist(res.body.engine)
|
|
1578
|
+
expect(res.body.engine.name).to.equal('pinecone');
|
|
1579
|
+
expect(res.body.engine.type).to.equal('pod');
|
|
1580
|
+
|
|
1581
|
+
// Get again all namespace. A new default namespace should not be created.
|
|
1582
|
+
chai.request(server)
|
|
1583
|
+
.get('/' + savedProject._id + '/kb/namespace/all')
|
|
1584
|
+
.auth(email, pwd)
|
|
1585
|
+
.end((err, res) => {
|
|
1586
|
+
|
|
1587
|
+
if (err) { console.error("err: ", err); }
|
|
1588
|
+
if (log) { console.log("get all namespaces res.body: ", res.body); }
|
|
1589
|
+
|
|
1590
|
+
res.should.have.status(200);
|
|
1591
|
+
res.body.should.be.a('array');
|
|
1592
|
+
expect(res.body.length).to.equal(2);
|
|
1593
|
+
should.not.exist(res.body[0]._id);
|
|
1594
|
+
should.not.exist(res.body[1]._id);
|
|
1595
|
+
should.exist(res.body[0].id);
|
|
1596
|
+
should.exist(res.body[1].id);
|
|
1597
|
+
|
|
1598
|
+
done();
|
|
1599
|
+
})
|
|
1600
|
+
})
|
|
1601
|
+
})
|
|
1602
|
+
});
|
|
1603
|
+
});
|
|
1604
|
+
})
|
|
1321
1605
|
|
|
1322
1606
|
/**
|
|
1323
1607
|
* Update namespaces
|
|
@@ -1346,7 +1630,6 @@ describe('KbRoute', () => {
|
|
|
1346
1630
|
expect(res.body[0].name).to.equal("Default");
|
|
1347
1631
|
|
|
1348
1632
|
let namespace_id = res.body[0].id;
|
|
1349
|
-
console.log("namespace_id: ", namespace_id);
|
|
1350
1633
|
|
|
1351
1634
|
let new_settings = {
|
|
1352
1635
|
model: 'gpt-4o',
|
|
@@ -1411,7 +1694,6 @@ describe('KbRoute', () => {
|
|
|
1411
1694
|
expect(res.body[0].name).to.equal("Default");
|
|
1412
1695
|
|
|
1413
1696
|
let namespace_id = res.body[0].id;
|
|
1414
|
-
console.log("namespace_id: ", namespace_id);
|
|
1415
1697
|
|
|
1416
1698
|
// Update namespace
|
|
1417
1699
|
chai.request(server)
|
package/test/projectRoute.js
CHANGED
|
@@ -50,6 +50,47 @@ describe('ProjectRoute', () => {
|
|
|
50
50
|
|
|
51
51
|
describe('/create', () => {
|
|
52
52
|
|
|
53
|
+
it('getAllProjectsWithSuperAdminCredential', (done) => {
|
|
54
|
+
|
|
55
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
56
|
+
var pwd = "pwd";
|
|
57
|
+
|
|
58
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
|
59
|
+
projectService.create("test-project-create-1", savedUser._id).then(() => {
|
|
60
|
+
projectService.create("test-project-create-2", savedUser._id).then((savedProject2) => {
|
|
61
|
+
|
|
62
|
+
chai.request(server)
|
|
63
|
+
.post('/auth/signin')
|
|
64
|
+
.send({ email: "admin@tiledesk.com", password: "adminadmin" })
|
|
65
|
+
// .send({ email: email, password: pwd }) // con queste credenziali non si può fare la richiesta /projects/all
|
|
66
|
+
.end((err, res) => {
|
|
67
|
+
|
|
68
|
+
if (log) { console.log("login with superadmin res.body: ", res.body) };
|
|
69
|
+
res.should.have.status(200);
|
|
70
|
+
res.body.should.be.a('object');
|
|
71
|
+
expect(res.body.success).to.equal(true);
|
|
72
|
+
expect(res.body.token).not.equal(null);
|
|
73
|
+
|
|
74
|
+
let superadmin_token = res.body.token;
|
|
75
|
+
|
|
76
|
+
chai.request(server)
|
|
77
|
+
.get('/projects/all')
|
|
78
|
+
.set('Authorization', superadmin_token)
|
|
79
|
+
.end((err, res) => {
|
|
80
|
+
|
|
81
|
+
console.log("res.body: ", res.body.length);
|
|
82
|
+
console.log("example: ", res.body[0]);
|
|
83
|
+
res.should.have.status(200);
|
|
84
|
+
res.body.should.be.a('array');
|
|
85
|
+
|
|
86
|
+
done()
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}).timeout(10000)
|
|
93
|
+
|
|
53
94
|
it('updateProjectProfileWithSuperAdminCredential', (done) => {
|
|
54
95
|
|
|
55
96
|
var email = "test-signup-" + Date.now() + "@email.com";
|