|
|
|
|
@ -1442,6 +1442,240 @@ describe('[Chat]', function() { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('[/chat.getMentionedMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the mentioned messages', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getStarredMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the starred messages', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getSnippetedMessageById]', () => { |
|
|
|
|
it('should return an error when the snippeted messages is disabled', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', false).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById?messageId=invalid-id')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should return an error when the required "messageId" parameter is not sent', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', true).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getSnippetedMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the snippeted messages is disabled', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', false).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the snippeted messages', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', true).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the messageId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById?messageId=invalid-id')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('invalid-message'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getDiscussions]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getDiscussions')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getDiscussions?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the discussions of a room', (done) => { |
|
|
|
|
request.get(api('chat.getDiscussions?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the messageId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById?messageId=invalid-id')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('invalid-message'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('Threads', () => { |
|
|
|
|
@ -2110,184 +2344,4 @@ describe('Threads', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getMentionedMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the mentioned messages', (done) => { |
|
|
|
|
request.get(api('chat.getMentionedMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getStarredMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the starred messages', (done) => { |
|
|
|
|
request.get(api('chat.getStarredMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getSnippetedMessageById]', () => { |
|
|
|
|
it('should return an error when the snippeted messages is disabled', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', false).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById?messageId=invalid-id')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should return an error when the required "messageId" parameter is not sent', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', true).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/chat.getSnippetedMessages]', () => { |
|
|
|
|
it('should return an error when the required "roomId" parameter is not sent', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.errorType).to.be.equal('error-invalid-params'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the roomId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the snippeted messages is disabled', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', false).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=invalid-room')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('error-not-allowed'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return the snippeted messages', (done) => { |
|
|
|
|
updateSetting('Message_AllowSnippeting', true).then(() => { |
|
|
|
|
request.get(api('chat.getSnippetedMessages?roomId=GENERAL')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body.messages).to.be.an('array'); |
|
|
|
|
expect(res.body).to.have.property('offset'); |
|
|
|
|
expect(res.body).to.have.property('total'); |
|
|
|
|
expect(res.body).to.have.property('count'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return an error when the messageId is invalid', (done) => { |
|
|
|
|
request.get(api('chat.getSnippetedMessageById?messageId=invalid-id')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body.error).to.be.equal('invalid-message'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|