mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 13:57:24 +02:00
test: fix unread deleted topic test (#14164)
instead of posting and immediately deleting, add a deleted param to topics.post which deletes the topic before sending notifications
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
648344a2c9
commit
15d65943fb
@@ -167,14 +167,15 @@ module.exports = function (Topics) {
|
|||||||
topicData.index = 0;
|
topicData.index = 0;
|
||||||
postData.index = 0;
|
postData.index = 0;
|
||||||
|
|
||||||
if (topicData.scheduled) {
|
if (data.deleted || topicData.scheduled) {
|
||||||
await Topics.delete(tid);
|
await Topics.delete(tid, uid);
|
||||||
|
topicData.deleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
analytics.increment(['topics', `topics:byCid:${topicData.cid}`]);
|
analytics.increment(['topics', `topics:byCid:${topicData.cid}`]);
|
||||||
plugins.hooks.fire('action:topic.post', { topic: topicData, post: postData, data: data });
|
plugins.hooks.fire('action:topic.post', { topic: topicData, post: postData, data: data });
|
||||||
|
|
||||||
if (!topicData.scheduled) {
|
if (!topicData.scheduled && !topicData.deleted) {
|
||||||
setImmediate(async () => {
|
setImmediate(async () => {
|
||||||
try {
|
try {
|
||||||
if (utils.isNumber(uid)) {
|
if (utils.isNumber(uid)) {
|
||||||
|
|||||||
@@ -1420,8 +1420,14 @@ describe('Topic\'s', () => {
|
|||||||
|
|
||||||
it('should not return topic as unread if topic is deleted', async () => {
|
it('should not return topic as unread if topic is deleted', async () => {
|
||||||
const uid = await User.create({ username: 'regularJoe' });
|
const uid = await User.create({ username: 'regularJoe' });
|
||||||
const result = await topics.post({ uid: adminUid, title: 'deleted unread', content: 'not unread', cid: categoryObj.cid });
|
const result = await topics.post({
|
||||||
await topics.delete(result.topicData.tid, adminUid);
|
uid: adminUid,
|
||||||
|
title: 'deleted unread',
|
||||||
|
content: 'not unread',
|
||||||
|
cid: categoryObj.cid,
|
||||||
|
deleted: 1,
|
||||||
|
});
|
||||||
|
|
||||||
const unreadTids = await topics.getUnreadTids({ cid: 0, uid: uid });
|
const unreadTids = await topics.getUnreadTids({ cid: 0, uid: uid });
|
||||||
|
|
||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
|
|||||||
Reference in New Issue
Block a user