diff --git a/.eslintrc b/.eslintrc index e928d6d88ee..b759b74b56e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,7 @@ { "parserOptions": { - "sourceType": "module" + "sourceType": "module", + "ecmaVersion": 2017 }, "env": { "browser": true, diff --git a/tests/end-to-end/api/00-miscellaneous.js b/tests/end-to-end/api/00-miscellaneous.js index de417c2a1a5..9616af0f487 100644 --- a/tests/end-to-end/api/00-miscellaneous.js +++ b/tests/end-to-end/api/00-miscellaneous.js @@ -6,7 +6,9 @@ import {getCredentials, api, login, request, credentials} from '../../data/api-d import {adminEmail} from '../../data/user.js'; import supertest from 'supertest'; -describe('miscellaneous', () => { +describe('miscellaneous', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) @@ -60,4 +62,4 @@ describe('miscellaneous', () => { }) .end(done); }); -}); \ No newline at end of file +}); diff --git a/tests/end-to-end/api/01-users.js b/tests/end-to-end/api/01-users.js index f004a476795..423800592e5 100644 --- a/tests/end-to-end/api/01-users.js +++ b/tests/end-to-end/api/01-users.js @@ -7,7 +7,9 @@ import {adminEmail, password} from '../../data/user.js'; import {imgURL} from '../../data/interactions.js'; import supertest from 'supertest'; -describe('Users', () => { +describe('Users', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) @@ -151,4 +153,4 @@ describe('Users', () => { }) .end(done); }); -}); \ No newline at end of file +}); diff --git a/tests/end-to-end/api/02-channels.js b/tests/end-to-end/api/02-channels.js index c53165ab668..db2e30d5460 100644 --- a/tests/end-to-end/api/02-channels.js +++ b/tests/end-to-end/api/02-channels.js @@ -6,7 +6,22 @@ import {getCredentials, api, login, request, credentials, apiEmail, apiUsername, import {adminEmail, password} from '../../data/user.js'; import supertest from 'supertest'; -describe('channels', () => { +function getRoomInfo(roomId) { + return new Promise((resolve/*, reject*/) => { + request.get(api('channels.info')) + .set(credentials) + .query({ + roomId: roomId + }) + .end((err, req) => { + resolve(req.body); + }); + }); +} + +describe('channels', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) @@ -19,7 +34,7 @@ describe('channels', () => { .end(done); }); - it('/channels.create', (done) => { + it('/channels.create', async (done) => { request.post(api('channels.create')) .set(credentials) .send({ @@ -38,7 +53,7 @@ describe('channels', () => { .end(done); }); - it('/channels.info', (done) => { + it('/channels.info', async (done) => { request.get(api('channels.info')) .set(credentials) .query({ @@ -56,7 +71,9 @@ describe('channels', () => { .end(done); }); - it('/channels.invite', (done) => { + it('/channels.invite', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.invite')) .set(credentials) .send({ @@ -70,7 +87,7 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); @@ -135,7 +152,9 @@ describe('channels', () => { .end(done); }); - it('/channels.kick', (done) => { + it('/channels.kick', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.kick')) .set(credentials) .send({ @@ -149,12 +168,14 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); - it('/channels.invite', (done) => { + it('/channels.invite', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.invite')) .set(credentials) .send({ @@ -168,7 +189,7 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); @@ -355,7 +376,9 @@ describe('channels', () => { .end(done); }); - it('/channels.rename', (done) => { + it('/channels.rename', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.rename')) .set(credentials) .send({ @@ -369,7 +392,7 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); @@ -390,7 +413,7 @@ describe('channels', () => { .end(done); }); - it('/channels.addAll', (done) => { + it('/channels.addAll', async (done) => { request.post(api('channels.addAll')) .set(credentials) .send({ @@ -403,12 +426,13 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); }) .end(done); }); - it('/channels.setJoinCode', (done) => { + it('/channels.setJoinCode', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.setJoinCode')) .set(credentials) .send({ @@ -422,12 +446,14 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs); }) .end(done); }); - it('/channels.setReadOnly', (done) => { + it('/channels.setReadOnly', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.setReadOnly')) .set(credentials) .send({ @@ -441,12 +467,14 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs); }) .end(done); }); - it('/channels.leave', (done) => { + it('/channels.leave', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.leave')) .set(credentials) .send({ @@ -459,12 +487,14 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'c'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); - it('/channels.setType', (done) => { + it('/channels.setType', async (done) => { + const roomInfo = await getRoomInfo(channel._id); + request.post(api('channels.setType')) .set(credentials) .send({ @@ -478,8 +508,8 @@ describe('channels', () => { expect(res.body).to.have.deep.property('channel._id'); expect(res.body).to.have.deep.property('channel.name', 'EDITED'+apiPublicChannelName); expect(res.body).to.have.deep.property('channel.t', 'p'); - expect(res.body).to.have.deep.property('channel.msgs', 0); + expect(res.body).to.have.deep.property('channel.msgs', roomInfo.channel.msgs + 1); }) .end(done); }); -}); \ No newline at end of file +}); diff --git a/tests/end-to-end/api/03-groups.js b/tests/end-to-end/api/03-groups.js index 34db73602ca..3685c3ec36d 100644 --- a/tests/end-to-end/api/03-groups.js +++ b/tests/end-to-end/api/03-groups.js @@ -6,7 +6,22 @@ import {getCredentials, api, login, request, credentials, group, log, apiPrivate import {adminEmail, password} from '../../data/user.js'; import supertest from 'supertest'; -describe('groups', () => { +function getRoomInfo(roomId) { + return new Promise((resolve/*, reject*/) => { + request.get(api('groups.info')) + .set(credentials) + .query({ + roomId: roomId + }) + .end((err, req) => { + resolve(req.body); + }); + }); +} + +describe('groups', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) @@ -19,7 +34,7 @@ describe('groups', () => { .end(done); }); - it('/groups.create', (done) => { + it('/groups.create', async (done) => { request.post(api('groups.create')) .set(credentials) .send({ @@ -38,7 +53,7 @@ describe('groups', () => { .end(done); }); - it('/groups.info', (done) => { + it('/groups.info', async (done) => { request.get(api('groups.info')) .set(credentials) .query({ @@ -56,7 +71,9 @@ describe('groups', () => { .end(done); }); - it('/groups.invite', (done) => { + it('/groups.invite', async (done) => { + const roomInfo = await getRoomInfo(group._id); + request.post(api('groups.invite')) .set(credentials) .send({ @@ -70,7 +87,7 @@ describe('groups', () => { expect(res.body).to.have.deep.property('group._id'); expect(res.body).to.have.deep.property('group.name', apiPrivateChannelName); expect(res.body).to.have.deep.property('group.t', 'p'); - expect(res.body).to.have.deep.property('group.msgs', 0); + expect(res.body).to.have.deep.property('group.msgs', roomInfo.group.msgs + 1); }) .end(done); }); @@ -150,7 +167,9 @@ describe('groups', () => { .end(done); }); - it('/groups.invite', (done) => { + it('/groups.invite', async (done) => { + const roomInfo = await getRoomInfo(group._id); + request.post(api('groups.invite')) .set(credentials) .send({ @@ -164,7 +183,7 @@ describe('groups', () => { expect(res.body).to.have.deep.property('group._id'); expect(res.body).to.have.deep.property('group.name', apiPrivateChannelName); expect(res.body).to.have.deep.property('group.t', 'p'); - expect(res.body).to.have.deep.property('group.msgs', 0); + expect(res.body).to.have.deep.property('group.msgs', roomInfo.group.msgs + 1); }) .end(done); }); @@ -319,7 +338,9 @@ describe('groups', () => { .end(done); }); - it('/groups.rename', (done) => { + it('/groups.rename', async (done) => { + const roomInfo = await getRoomInfo(group._id); + request.post(api('groups.rename')) .set(credentials) .send({ @@ -333,7 +354,7 @@ describe('groups', () => { expect(res.body).to.have.deep.property('group._id'); expect(res.body).to.have.deep.property('group.name', 'EDITED'+apiPrivateChannelName); expect(res.body).to.have.deep.property('group.t', 'p'); - expect(res.body).to.have.deep.property('group.msgs', 0); + expect(res.body).to.have.deep.property('group.msgs', roomInfo.group.msgs + 1); }) .end(done); }); @@ -397,4 +418,4 @@ describe('groups', () => { }) .end(done); }); -}); \ No newline at end of file +}); diff --git a/tests/end-to-end/api/04-direct-message.js b/tests/end-to-end/api/04-direct-message.js index 62d3203ee81..b75e678229b 100644 --- a/tests/end-to-end/api/04-direct-message.js +++ b/tests/end-to-end/api/04-direct-message.js @@ -6,7 +6,9 @@ import {getCredentials, api, login, request, credentials, directMessage, log } f import {adminEmail, password} from '../../data/user.js'; import supertest from 'supertest'; -describe('direct messages', () => { +describe('direct messages', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) @@ -122,4 +124,4 @@ describe('direct messages', () => { }) .end(done); }); -}); \ No newline at end of file +}); diff --git a/tests/end-to-end/api/05-chat.js b/tests/end-to-end/api/05-chat.js index db4e680794d..ee770e56e71 100644 --- a/tests/end-to-end/api/05-chat.js +++ b/tests/end-to-end/api/05-chat.js @@ -6,7 +6,9 @@ import {getCredentials, api, login, request, credentials, message, log, apiPriva import {adminEmail, password} from '../../data/user.js'; import supertest from 'supertest'; -describe('chat', () => { +describe('chat', function() { + this.retries(0); + before((done) => { request.post(api('login')) .send(login) diff --git a/tests/end-to-end/api/06-integrations.js b/tests/end-to-end/api/06-integrations.js index e6a590bdc59..3999ceea82d 100644 --- a/tests/end-to-end/api/06-integrations.js +++ b/tests/end-to-end/api/06-integrations.js @@ -6,7 +6,9 @@ import {getCredentials, api, login, request, credentials, integration, log } fro import {adminEmail, password} from '../../data/user.js'; import supertest from 'supertest'; -describe('integrations', () => { +describe('integrations', function() { + this.retries(0); + it('/integrations.create', (done) => { request.post(api('integrations.create')) .set(credentials) @@ -68,4 +70,4 @@ describe('integrations', () => { }) .end(done); }); -}); \ No newline at end of file +});