@tiledesk/tiledesk-server 2.10.35 → 2.10.37

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/test/kbRoute.js CHANGED
@@ -661,12 +661,12 @@ describe('KbRoute', () => {
661
661
  chai.request(server)
662
662
  .post('/' + savedProject._id + '/kb/multi?namespace=' + namespace_id)
663
663
  .auth(email, pwd)
664
- .send({ list:["https://gethelp.tiledesk.com/article"], scrape_type: 3 })
664
+ .send({ list:["https://gethelp.tiledesk.com/article"], refresh_rate: 'daily', scrape_type: 3 })
665
665
  .end((err, res) => {
666
666
 
667
667
  if (err) { console.error("err: ", err); }
668
668
  if (log) { console.log("res.body: ", res.body) }
669
-
669
+ console.log("res.body: ", res.body)
670
670
  res.should.have.status(200);
671
671
  expect(res.body.length).to.equal(1)
672
672
  expect(res.body[0].scrape_type).to.equal(3)
@@ -1437,6 +1437,78 @@ describe('KbRoute', () => {
1437
1437
 
1438
1438
 
1439
1439
 
1440
+ });
1441
+ });
1442
+ }).timeout(10000)
1443
+
1444
+ it('webhook-reindex', (done) => {
1445
+
1446
+ var email = "test-signup-" + Date.now() + "@email.com";
1447
+ var pwd = "pwd";
1448
+
1449
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
1450
+ projectService.create("test-kb-webhook", savedUser._id).then(function (savedProject) {
1451
+
1452
+ chai.request(server)
1453
+ .get('/' + savedProject._id + '/kb/namespace/all')
1454
+ .auth(email, pwd)
1455
+ .end((err, res) => {
1456
+
1457
+ if (err) { console.log("error: ", err) };
1458
+ if (log) { console.log("res.body: ", res.body) };
1459
+
1460
+ res.should.have.status(200);
1461
+ res.body.should.be.a('array');
1462
+
1463
+ let namespace_id = res.body[0].id;
1464
+
1465
+ let kb = {
1466
+ name: "example_name6",
1467
+ type: "url",
1468
+ source: "https://www.exampleurl6.com",
1469
+ content: "",
1470
+ namespace: namespace_id
1471
+ }
1472
+
1473
+ chai.request(server)
1474
+ .post('/' + savedProject._id + '/kb/')
1475
+ .auth(email, pwd)
1476
+ .send(kb)
1477
+ .end((err, res) => {
1478
+
1479
+ if (err) { console.log("error: ", err) };
1480
+ if (log) { console.log("res.body: ", res.body) };
1481
+
1482
+ res.should.have.status(200);
1483
+ res.body.should.be.a('object');
1484
+
1485
+ let kb_id = res.body.value._id;
1486
+
1487
+ chai.request(server)
1488
+ .post('/webhook/kb/reindex')
1489
+ .set("x-auth-token", "testtoken")
1490
+ .send({ content_id: kb_id })
1491
+ .end((err, res) => {
1492
+
1493
+ if (err) { console.error("err: ", err) };
1494
+ if (log) { console.log("res.body: ", res.body) };
1495
+
1496
+ res.should.have.status(200);
1497
+ res.body.should.be.a('object');
1498
+ expect(res.body.success).to.equal(true);
1499
+ expect(res.body.message).to.equal("Content queued for reindexing");
1500
+
1501
+ done();
1502
+
1503
+ })
1504
+
1505
+
1506
+ })
1507
+ })
1508
+
1509
+
1510
+
1511
+
1440
1512
  });
1441
1513
  });
1442
1514
  }).timeout(10000)