The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/tests/end-to-end/api/04-direct-message.js

119 lines
3.0 KiB

/* eslint-env mocha */
/* globals expect */
/* eslint no-unused-vars: 0 */
import {getCredentials, api, login, request, credentials, directMessage, log } from '../../data/api-data.js';
import {adminEmail, password} from '../../data/user.js';
import supertest from 'supertest';
describe('[Direct Messages]', function() {
9 years ago
this.retries(0);
before(done => getCredentials(done));
it('/chat.postMessage', (done) => {
request.post(api('chat.postMessage'))
.set(credentials)
.send({
channel: 'rocket.cat',
text: 'This message was sent using the API'
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('message.msg', 'This message was sent using the API');
expect(res.body).to.have.nested.property('message.rid');
directMessage._id = res.body.message.rid;
})
.end(done);
});
it('/im.setTopic', (done) => {
request.post(api('im.setTopic'))
.set(credentials)
.send({
roomId: directMessage._id,
topic: 'a direct message with rocket.cat'
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
it('/im.history', (done) => {
request.get(api('im.history'))
.set(credentials)
.query({
roomId: directMessage._id,
userId: 'rocket.cat'
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('messages');
})
.end(done);
});
it('/im.list', (done) => {
request.get(api('im.list'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('count');
expect(res.body).to.have.property('total');
})
.end(done);
});
it('/im.list.everyone', (done) => {
request.get(api('im.list.everyone'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('count');
expect(res.body).to.have.property('total');
})
.end(done);
});
8 years ago
it('/im.open', (done) => {
request.post(api('im.open'))
.set(credentials)
.send({
roomId: directMessage._id,
userId: 'rocket.cat'
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
8 years ago
it('/im.close', (done) => {
request.post(api('im.close'))
.set(credentials)
.send({
roomId: directMessage._id,
userId: 'rocket.cat'
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
9 years ago
});