Revert "Performance: Inbox Paging / loading (#11157)"

This reverts commit 5630e8cc8e.
This commit is contained in:
Sabe Jones
2019-06-14 12:34:38 +00:00
parent 1db0cda6b1
commit 5a5f1d6895
12 changed files with 115 additions and 355 deletions
@@ -6,7 +6,7 @@ describe('GET /inbox/messages', () => {
let user;
let otherUser;
beforeEach(async () => {
before(async () => {
[user, otherUser] = await Promise.all([generateUser(), generateUser()]);
await otherUser.post('/members/send-private-message', {
@@ -7,7 +7,7 @@ describe('GET /inbox/conversations', () => {
let otherUser;
let thirdUser;
beforeEach(async () => {
before(async () => {
[user, otherUser, thirdUser] = await Promise.all([generateUser(), generateUser(), generateUser()]);
await otherUser.post('/members/send-private-message', {
@@ -41,51 +41,4 @@ describe('GET /inbox/conversations', () => {
expect(result[0].user).to.be.equal(user.profile.name);
expect(result[0].username).to.be.equal(user.auth.local.username);
});
it('returns the user inbox messages as an array of ordered messages (from most to least recent)', async () => {
const messages = await user.get('/inbox/messages');
expect(messages.length).to.equal(5);
// message to yourself
expect(messages[0].text).to.equal('fifth');
expect(messages[0].sent).to.equal(false);
expect(messages[0].uuid).to.equal(user._id);
expect(messages[1].text).to.equal('fourth');
expect(messages[2].text).to.equal('third');
expect(messages[3].text).to.equal('second');
expect(messages[4].text).to.equal('first');
});
it('returns four messages when using page-query ', async () => {
const promises = [];
for (let i = 0; i < 10; i++) {
promises.push(user.post('/members/send-private-message', {
toUserId: user.id,
message: 'fourth',
}));
}
await Promise.all(promises);
const messages = await user.get('/inbox/messages?page=1');
expect(messages.length).to.equal(5);
});
it('returns only the messages of one conversation', async () => {
const messages = await user.get(`/inbox/messages?conversation=${otherUser.id}`);
expect(messages.length).to.equal(3);
});
it('returns the correct message format', async () => {
const messages = await otherUser.get(`/inbox/messages?conversation=${user.id}`);
expect(messages[0].toUUID).to.equal(user.id); // from user
expect(messages[1].toUUID).to.not.exist; // only filled if its from the chat partner
expect(messages[2].toUUID).to.equal(user.id); // from user
});
});
@@ -22,7 +22,7 @@ describe('POST /members/flag-private-message/:messageId', () => {
let senderMessages = await userToSendMessage.get('/inbox/messages');
let sendersMessageInSendersInbox = _.find(senderMessages, (message) => {
return message.toUUID === receiver._id && message.text === messageToSend;
return message.uuid === receiver._id && message.text === messageToSend;
});
expect(sendersMessageInSendersInbox).to.exist;