allow liking their own message (#15117)

This commit is contained in:
negue
2024-02-05 21:55:46 +01:00
committed by GitHub
parent 2fa26db93f
commit 8b373b9283
3 changed files with 14 additions and 16 deletions

View File

@@ -39,17 +39,6 @@ describe('POST /chat/:chatId/like', () => {
});
});
it('Returns an error when user tries to like their own message', async () => {
const message = await user.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage });
await expect(user.post(`/groups/${groupWithChat._id}/chat/${message.message.id}/like`))
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageGroupChatLikeOwnMessage'),
});
});
it('Likes a chat', async () => {
const message = await anotherUser.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage });
@@ -63,6 +52,19 @@ describe('POST /chat/:chatId/like', () => {
expect(messageToCheck.likes[user._id]).to.equal(true);
});
it('Allows to likes their own chat message', async () => {
const message = await user.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage });
const likeResult = await user.post(`/groups/${groupWithChat._id}/chat/${message.message.id}/like`);
expect(likeResult.likes[user._id]).to.equal(true);
const groupWithChatLikes = await user.get(`/groups/${groupWithChat._id}`);
const messageToCheck = find(groupWithChatLikes.chat, { id: message.message.id });
expect(messageToCheck.likes[user._id]).to.equal(true);
});
it('Unlikes a chat', async () => {
const message = await anotherUser.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage });