@tiledesk/tiledesk-server 2.10.66 → 2.10.68

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
@@ -666,7 +666,7 @@ describe('KbRoute', () => {
666
666
 
667
667
  if (err) { console.error("err: ", err); }
668
668
  if (log) { console.log("res.body: ", res.body) }
669
- console.log("res.body: ", res.body)
669
+
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)
@@ -1562,71 +1562,73 @@ describe('KbRoute', () => {
1562
1562
  /**
1563
1563
  * Get all namespaces of a project.
1564
1564
  * If there isn't namespaces for a project_id, the default namespace is created and returned.
1565
+ * WARNING: not working due to namspace creation limit (on trial plan)
1565
1566
  */
1566
- it('create-and-get-namespaces', (done) => {
1567
-
1568
- var email = "test-signup-" + Date.now() + "@email.com";
1569
- var pwd = "pwd";
1567
+ // it('create-and-get-namespaces', (done) => {
1570
1568
 
1571
- userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
1572
- projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
1573
-
1574
- // Get all namespaces. Create default namespace and return.
1575
- chai.request(server)
1576
- .get('/' + savedProject._id + '/kb/namespace/all')
1577
- .auth(email, pwd)
1578
- .end((err, res) => {
1569
+ // var email = "test-signup-" + Date.now() + "@email.com";
1570
+ // var pwd = "pwd";
1579
1571
 
1580
- if (err) { console.error("err: ", err); }
1581
- if (log) { console.log("get all namespaces res.body: ", res.body); }
1572
+ // userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
1573
+ // projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
1582
1574
 
1583
- res.should.have.status(200);
1584
- res.body.should.be.a('array');
1585
- expect(res.body.length).to.equal(1);
1586
- should.not.exist(res.body[0]._id);
1587
- expect(res.body[0].id).to.equal(savedProject._id.toString());
1588
- expect(res.body[0].name).to.equal("Default");
1575
+ // // Get all namespaces. Create default namespace and return.
1576
+ // chai.request(server)
1577
+ // .get('/' + savedProject._id + '/kb/namespace/all')
1578
+ // .auth(email, pwd)
1579
+ // .end((err, res) => {
1589
1580
 
1590
- // Create another namespace
1591
- chai.request(server)
1592
- .post('/' + savedProject._id + '/kb/namespace')
1593
- .auth(email, pwd)
1594
- .send({ name: "MyCustomNamespace" })
1595
- .end((err, res) => {
1581
+ // if (err) { console.error("err: ", err); }
1582
+ // if (log) { console.log("get all namespaces res.body: ", res.body); }
1583
+ // console.log("get all namespaces res.body: ", res.body);
1584
+ // res.should.have.status(200);
1585
+ // res.body.should.be.a('array');
1586
+ // expect(res.body.length).to.equal(1);
1587
+ // should.not.exist(res.body[0]._id);
1588
+ // expect(res.body[0].id).to.equal(savedProject._id.toString());
1589
+ // expect(res.body[0].name).to.equal("Default");
1596
1590
 
1597
- if (err) { console.error("err: ", err) }
1598
- if (log) { console.log("create new namespace res.body: ", res.body) }
1591
+ // // Create another namespace
1592
+ // chai.request(server)
1593
+ // .post('/' + savedProject._id + '/kb/namespace')
1594
+ // .auth(email, pwd)
1595
+ // .send({ name: "MyCustomNamespace" })
1596
+ // .end((err, res) => {
1599
1597
 
1600
- res.should.have.status(200);
1601
- res.body.should.be.a('object');
1602
- should.not.exist(res.body._id)
1603
- should.exist(res.body.id)
1604
- expect(res.body.name).to.equal('MyCustomNamespace');
1598
+ // if (err) { console.error("err: ", err) }
1599
+ // if (log) { console.log("create new namespace res.body: ", res.body) }
1600
+ // console.log("create new namespace res.body: ", res.body)
1601
+ // res.should.have.status(200);
1602
+ // res.body.should.be.a('object');
1603
+ // should.not.exist(res.body._id)
1604
+ // should.exist(res.body.id)
1605
+ // expect(res.body.name).to.equal('MyCustomNamespace');
1605
1606
 
1606
- // Get again all namespace. A new default namespace should not be created.
1607
- chai.request(server)
1608
- .get('/' + savedProject._id + '/kb/namespace/all')
1609
- .auth(email, pwd)
1610
- .end((err, res) => {
1607
+ // // Get again all namespace. A new default namespace should not be created.
1608
+ // chai.request(server)
1609
+ // .get('/' + savedProject._id + '/kb/namespace/all')
1610
+ // .auth(email, pwd)
1611
+ // .end((err, res) => {
1611
1612
 
1612
- if (err) { console.error("err: ", err); }
1613
- if (log) { console.log("get all namespaces res.body: ", res.body); }
1613
+ // if (err) { console.error("err: ", err); }
1614
+ // if (log) { console.log("get all namespaces res.body: ", res.body); }
1615
+ // console.log("get all namespaces res.body: ", res.body);
1614
1616
 
1615
- res.should.have.status(200);
1616
- res.body.should.be.a('array');
1617
- expect(res.body.length).to.equal(2);
1618
- should.not.exist(res.body[0]._id);
1619
- should.not.exist(res.body[1]._id);
1620
- should.exist(res.body[0].id);
1621
- should.exist(res.body[1].id);
1617
+ // res.should.have.status(200);
1618
+ // res.body.should.be.a('array');
1619
+ // expect(res.body.length).to.equal(2);
1620
+ // should.not.exist(res.body[0]._id);
1621
+ // should.not.exist(res.body[1]._id);
1622
+ // should.exist(res.body[0].id);
1623
+ // should.exist(res.body[1].id);
1622
1624
 
1623
- done();
1624
- })
1625
- })
1626
- })
1627
- });
1628
- });
1629
- })
1625
+ // done();
1626
+ // })
1627
+ // })
1628
+ // })
1629
+ // });
1630
+ // });
1631
+ // })
1630
1632
 
1631
1633
  it('create-namespaces-with-engine', (done) => {
1632
1634
 
@@ -1636,65 +1638,42 @@ describe('KbRoute', () => {
1636
1638
  userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
1637
1639
  projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
1638
1640
 
1639
- // Get all namespaces. Create default namespace and return.
1640
1641
  chai.request(server)
1641
- .get('/' + savedProject._id + '/kb/namespace/all')
1642
- .auth(email, pwd)
1643
- .end((err, res) => {
1644
-
1645
- if (err) { console.error("err: ", err); }
1646
- if (log) { console.log("get all namespaces res.body: ", res.body); }
1647
-
1648
- res.should.have.status(200);
1649
- res.body.should.be.a('array');
1650
- expect(res.body.length).to.equal(1);
1651
- should.not.exist(res.body[0]._id);
1652
- expect(res.body[0].id).to.equal(savedProject._id.toString());
1653
- expect(res.body[0].name).to.equal("Default");
1654
- should.exist(res.body[0].engine)
1655
- expect(res.body[0].engine.name).to.equal('pinecone');
1656
- expect(res.body[0].engine.type).to.equal('pod');
1657
-
1658
- // Create another namespace
1659
- chai.request(server)
1660
- .post('/' + savedProject._id + '/kb/namespace')
1661
- .auth(email, pwd)
1662
- .send({ name: "MyCustomNamespace" })
1663
- .end((err, res) => {
1664
-
1665
- if (err) { console.error("err: ", err) }
1666
- if (log) { console.log("create new namespace res.body: ", res.body) }
1667
-
1668
- res.should.have.status(200);
1669
- res.body.should.be.a('object');
1670
- should.not.exist(res.body._id)
1671
- should.exist(res.body.id)
1672
- expect(res.body.name).to.equal('MyCustomNamespace');
1673
- should.exist(res.body.engine)
1674
- expect(res.body.engine.name).to.equal('pinecone');
1675
- expect(res.body.engine.type).to.equal('pod');
1676
-
1677
- // Get again all namespace. A new default namespace should not be created.
1678
- chai.request(server)
1679
- .get('/' + savedProject._id + '/kb/namespace/all')
1680
- .auth(email, pwd)
1681
- .end((err, res) => {
1682
-
1683
- if (err) { console.error("err: ", err); }
1684
- if (log) { console.log("get all namespaces res.body: ", res.body); }
1685
-
1686
- res.should.have.status(200);
1687
- res.body.should.be.a('array');
1688
- expect(res.body.length).to.equal(2);
1689
- should.not.exist(res.body[0]._id);
1690
- should.not.exist(res.body[1]._id);
1691
- should.exist(res.body[0].id);
1692
- should.exist(res.body[1].id);
1693
-
1694
- done();
1695
- })
1696
- })
1697
- })
1642
+ .post('/' + savedProject._id + '/kb/namespace')
1643
+ .auth(email, pwd)
1644
+ .send({ name: "MyCustomNamespace" })
1645
+ .end((err, res) => {
1646
+
1647
+ if (err) { console.error("err: ", err) }
1648
+ if (log) { console.log("create new namespace res.body: ", res.body) }
1649
+
1650
+ res.should.have.status(200);
1651
+ res.body.should.be.a('object');
1652
+ should.not.exist(res.body._id)
1653
+ should.exist(res.body.id)
1654
+ expect(res.body.name).to.equal('MyCustomNamespace');
1655
+ should.exist(res.body.engine)
1656
+ expect(res.body.engine.name).to.equal('pinecone');
1657
+ expect(res.body.engine.type).to.equal('pod');
1658
+
1659
+ // Get again all namespace. A new default namespace should not be created.
1660
+ chai.request(server)
1661
+ .get('/' + savedProject._id + '/kb/namespace/all')
1662
+ .auth(email, pwd)
1663
+ .end((err, res) => {
1664
+
1665
+ if (err) { console.error("err: ", err); }
1666
+ if (log) { console.log("get all namespaces res.body: ", res.body); }
1667
+
1668
+ res.should.have.status(200);
1669
+ res.body.should.be.a('array');
1670
+ expect(res.body.length).to.equal(1);
1671
+ should.not.exist(res.body[0]._id);
1672
+ should.exist(res.body[0].id);
1673
+
1674
+ done();
1675
+ })
1676
+ })
1698
1677
  });
1699
1678
  });
1700
1679
  })
@@ -30,8 +30,9 @@ let log = false;
30
30
  // CONNECT REDIS - CHECK IT
31
31
  const { TdCache } = require('../utils/TdCache');
32
32
  let tdCache = new TdCache({
33
- host: '127.0.0.1',
34
- port: '6379'
33
+ host: process.env.CACHE_REDIS_HOST || '127.0.0.1',
34
+ port: process.env.CACHE_REDIS_PORT || '6379',
35
+ password: process.env.CACHE_REDIS_PASSWORD || undefined
35
36
  });
36
37
 
37
38
  tdCache.connect();
@@ -191,6 +192,7 @@ describe('QuoteManager', function () {
191
192
  }).timeout(10000)
192
193
 
193
194
  it('incrementRequestsCount', async function () {
195
+
194
196
  let mockProject = projectMock.mockProjectBasicPlan;
195
197
  let mockRequest = requestMock.requestMock;
196
198
 
@@ -42,9 +42,10 @@ const projectMock = require('./mock/projectMock');
42
42
  // CONNECT REDIS - CHECK IT
43
43
  const { TdCache } = require('../utils/TdCache');
44
44
  let tdCache = new TdCache({
45
- host: '127.0.0.1',
46
- port: '6379'
47
- });
45
+ host: process.env.CACHE_REDIS_HOST || '127.0.0.1',
46
+ port: process.env.CACHE_REDIS_PORT || '6379',
47
+ password: process.env.CACHE_REDIS_PASSWORD || undefined
48
+ });
48
49
 
49
50
  tdCache.connect();
50
51
 
@@ -33,6 +33,7 @@ var Bot = require("../models/faq_kb");
33
33
 
34
34
  var jwt = require('jsonwebtoken');
35
35
  const uuidv4 = require('uuid/v4');
36
+ const chatbotTypes = require('../models/chatbotTypes');
36
37
 
37
38
 
38
39
  describe('UserService()', function () {
@@ -48,7 +49,7 @@ describe('UserService()', function () {
48
49
  projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser.id).then(function (savedProjectAndPU) {
49
50
  var savedProject = savedProjectAndPU.project;
50
51
 
51
- faqService.create("testbot", null, savedProject._id, savedUser._id, "tilebot", null, null, null, "en", "blank").then(async function (savedFaq_kb) {
52
+ faqService.create("testbot", null, savedProject._id, savedUser._id, "tilebot", chatbotTypes.CHATBOT, null, null, null, "en", "blank").then(async function (savedFaq_kb) {
52
53
 
53
54
  var signOptions = {
54
55
  issuer: 'https://tiledesk.com',