[MM-45802] Clear CRT notification on deleted reply (#23568)

* reduce the counter on post deletion

* add test

* change translations

* fix collecting mentions for DMs

* add translation texts

* extract logic for getting mentions

* send WS event

* add e2e tests

* tidy mod

* WIP

* Deleting notification async

* Fixed a unit test

* Added more tests

* Updated i18n

* CI

* mattermost-server -> mattermost

* mattermost-server -> mattermost

---------

Co-authored-by: Konstantinos Pittas <konstantinos.pittas@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Harshil Sharma
2023-06-05 16:02:40 +05:30
коммит произвёл GitHub
родитель b6b561a8f1
Коммит 412109b02e
7 изменённых файлов: 438 добавлений и 58 удалений

Просмотреть файл

@@ -93,6 +93,9 @@ describe('CRT Desktop notifications', () => {
expect(args.body, `Notification body: "${args.body}" should match: "${message}"`).to.equal(`@${sender.username}: ${message}`);
return true;
});
// # Cleanup
cy.apiDeletePost(postId);
});
});
@@ -147,6 +150,85 @@ describe('CRT Desktop notifications', () => {
expect(args.body, `Notification body: "${args.body}" should match: "${message}"`).to.equal(`@${sender.username}: ${message}`);
return true;
});
// # Cleanup
cy.apiDeletePost(postId);
});
});
it('When a reply is deleted in open channel, the notification should be cleared', () => {
// # Visit channel
cy.visit(testChannelUrl);
// # Post a root message as other user
cy.postMessageAs({sender, message: 'a thread', channelId: testChannelId, rootId: ''});
// # Get post id of message
cy.getLastPostId().then((postId) => {
// # Post a reply to the thread, which will trigger a follow
cy.postMessageAs({sender: receiver, message: 'following the thread', channelId: testChannelId, rootId: postId});
// # Post a reply to the thread
cy.postMessageAs({sender, message: 'a reply', channelId: testChannelId, rootId: postId}).as('reply');
// # Post a mention reply to the thread
cy.postMessageAs({sender, message: `@${receiver.username} mention reply`, channelId: testChannelId, rootId: postId}).
as('replyMention');
// * Verify there is a notification
cy.get('#sidebarItem_threads #unreadMentions').should('exist').and('have.text', '1');
// # Delete the replies
cy.wrap(['@reply', '@replyMention']).each((reply) => {
cy.get(reply).then(({id}) => {
cy.apiDeletePost(id);
});
});
// * Verify there is no notification
cy.get('#sidebarItem_threads #unreadMentions').should('not.exist');
// # Cleanup
cy.apiDeletePost(postId);
});
});
it('When a reply is deleted in DM channel, the notification should be cleared', () => {
cy.apiCreateDirectChannel([receiver.id, sender.id]).then(({channel: dmChannel}) => {
// # Visit channel
cy.visit(`/${testTeam.name}/messages/@${sender.username}`);
// # Post a root message as other user
cy.postMessageAs({sender, message: 'a thread', channelId: dmChannel.id, rootId: ''}).as('rootPost');
// # Get post id of message
cy.get('@rootPost').then(({id: rootId}) => {
// # Post a reply to the thread, which will trigger a follow
cy.postMessageAs({sender: receiver, message: 'following the thread', channelId: dmChannel.id, rootId});
// # Post a reply to the thread
cy.postMessageAs({sender, message: 'a reply', channelId: dmChannel.id, rootId}).as('reply');
// # Post a mention reply to the thread
cy.postMessageAs({sender, message: `@${receiver.username} mention reply`, channelId: dmChannel.id, rootId}).
as('replyMention');
// * Verify there is a notification
cy.get('#sidebarItem_threads #unreadMentions').should('exist');
// # Delete the replies
cy.wrap(['@reply', '@replyMention']).each((reply) => {
cy.get(reply).then(({id}) => {
cy.apiDeletePost(id);
});
});
// * Verify there is no notification
cy.get('#sidebarItem_threads #unreadMentions').should('not.exist');
// # Cleanup
cy.apiDeletePost(rootId);
});
});
});
});