From 230e653e46d31cdffb564e008f97adb095f69074 Mon Sep 17 00:00:00 2001 From: Matheus Barbosa Silva <36537004+matheusbsilva137@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:43:19 -0300 Subject: [PATCH] Remove new tests (to be added in new PR later) --- .../meteor/tests/end-to-end/api/24-methods.js | 281 +----------------- 1 file changed, 1 insertion(+), 280 deletions(-) diff --git a/apps/meteor/tests/end-to-end/api/24-methods.js b/apps/meteor/tests/end-to-end/api/24-methods.js index a13a2e390f28..899eb0db7d5f 100644 --- a/apps/meteor/tests/end-to-end/api/24-methods.js +++ b/apps/meteor/tests/end-to-end/api/24-methods.js @@ -1,11 +1,10 @@ import { expect } from 'chai'; import { after, before, beforeEach, describe, it } from 'mocha'; -import { api, credentials, getCredentials, methodCall, request } from '../../data/api-data.js'; +import { getCredentials, request, methodCall, api, credentials } from '../../data/api-data.js'; import { CI_MAX_ROOMS_PER_GUEST as maxRoomsPerGuest } from '../../data/constants'; import { updatePermission, updateSetting } from '../../data/permissions.helper'; import { createRoom } from '../../data/rooms.helper'; -import { password } from '../../data/user'; import { createUser, deleteUser, login } from '../../data/users.helper.js'; describe('Meteor.methods', function () { @@ -124,284 +123,6 @@ describe('Meteor.methods', function () { }); }); - describe('[@getReadReceipts]', () => { - let firstMessage = false; - let firstThreadMessage = false; - - let user; - let userCredentials; - let room; - - const roomName = `methods-test-channel-${Date.now()}`; - before(async () => { - user = await createUser(); - userCredentials = await login(user.username, password); - room = (await createRoom({ type: 'p', name: roomName, members: [user.username] })).body.group; - }); - - before(async () => { - await updateSetting('Message_Read_Receipt_Enabled', true); - await updateSetting('Message_Read_Receipt_Store_Users', true); - }); - - after(async () => { - deleteUser(user); - }); - - before('send sample message', (done) => { - request - .post(api('chat.sendMessage')) - .set(credentials) - .send({ - message: { - text: 'Sample message', - rid: room._id, - }, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - firstMessage = res.body.message; - }) - .end(done); - }); - - before('send sample message into thread', (done) => { - request - .post(api('chat.sendMessage')) - .set(credentials) - .send({ - message: { - text: 'Second Sample message', - rid: room._id, - tmid: firstMessage._id, - }, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - firstThreadMessage = res.body.message; - }) - .end(done); - }); - - it('should fail if not logged in', (done) => { - request - .post(methodCall('getReadReceipts')) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(401) - .expect((res) => { - expect(res.body).to.have.property('status', 'error'); - expect(res.body).to.have.property('message'); - }) - .end(done); - }); - - it("should return the sender's read receipt for a message sent in the main room", (done) => { - request - .post(methodCall('getReadReceipts')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [{ messageId: firstMessage._id }], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(1); - expect(data.result[0]).to.have.property('userId', credentials['X-User-Id']); - }) - .end(done); - }); - - it("should return the sender's read receipt for a message sent in a thread", (done) => { - request - .post(methodCall('getReadReceipts')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [{ messageId: firstThreadMessage._id }], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(1); - expect(data.result[0]).to.have.property('userId', credentials['X-User-Id']); - }) - .end(done); - }); - - it("should read all main room's messages with the invited user", (done) => { - request - .post(api('subscriptions.read')) - .set(credentials) - .send({ - rid: room._id, - readThreads: true, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - // expect(res.body).to.have.a.property('message').that.is.a('string'); - }) - .end(done); - }); - - it("should return the invited user's read receipt for a message sent in the main room", (done) => { - request - .post(methodCall('getReadReceipts')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [{ messageId: firstMessage._id }], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(2); - - const receiptsUserIds = [data.result[0].userId, data.result[1].userId]; - expect(receiptsUserIds).to.have.members([credentials['X-User-Id'], user._id]); - }) - .end(done); - }); - - it("should return only the sender's read receipt for a message sent in a thread after the main room is read", (done) => { - request - .post(methodCall('getReadReceipts')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [{ messageId: firstThreadMessage._id }], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(1); - expect(data.result[0]).to.have.property('userId', credentials['X-User-Id']); - }) - .end(done); - }); - - it('should read thread messages with the invited user', (done) => { - request - .post(methodCall('getThreadMessages')) - .set(userCredentials) - .send({ - message: JSON.stringify({ - id: 'id', - msg: 'method', - method: 'getThreadMessages', - params: [ - { - tmid: firstMessage._id, - }, - ], - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(2); - }) - .end(done); - }); - - it("should return the invited user's read receipt for a message sent in a thread after it is read", (done) => { - request - .post(methodCall('getReadReceipts')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getReadReceipts', - params: [{ messageId: firstThreadMessage._id }], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - expect(data.result.length).to.equal(2); - - const receiptsUserIds = [data.result[0].userId, data.result[1].userId]; - expect(receiptsUserIds).to.have.members([credentials['X-User-Id'], user._id]); - }) - .end(done); - }); - - it('should mark the thread as read', (done) => { - request - .post(methodCall('readThreads')) - .set(userCredentials) - .send(firstThreadMessage._id) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - }) - .end(done); - }); - }); - describe('[@getMessages]', () => { let rid = false; let firstMessage = false;