mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #9383, don't show deleted topic titles in inf scroll
This commit is contained in:
@@ -74,7 +74,7 @@ SocketCategories.loadMore = async function (socket, data) {
|
|||||||
tag: data.query.tag,
|
tag: data.query.tag,
|
||||||
targetUid: targetUid,
|
targetUid: targetUid,
|
||||||
});
|
});
|
||||||
categories.modifyTopicsByPrivilege(data.topics, userPrivileges);
|
categories.modifyTopicsByPrivilege(result.topics, userPrivileges);
|
||||||
|
|
||||||
result.privileges = userPrivileges;
|
result.privileges = userPrivileges;
|
||||||
result.template = {
|
result.template = {
|
||||||
|
|||||||
@@ -203,14 +203,21 @@ describe('Categories', () => {
|
|||||||
describe('socket methods', () => {
|
describe('socket methods', () => {
|
||||||
const socketCategories = require('../src/socket.io/categories');
|
const socketCategories = require('../src/socket.io/categories');
|
||||||
|
|
||||||
before((done) => {
|
before(async () => {
|
||||||
Topics.post({
|
await Topics.post({
|
||||||
uid: posterUid,
|
uid: posterUid,
|
||||||
cid: categoryObj.cid,
|
cid: categoryObj.cid,
|
||||||
title: 'Test Topic Title',
|
title: 'Test Topic Title',
|
||||||
content: 'The content of test topic',
|
content: 'The content of test topic',
|
||||||
tags: ['nodebb'],
|
tags: ['nodebb'],
|
||||||
}, done);
|
});
|
||||||
|
const data = await Topics.post({
|
||||||
|
uid: posterUid,
|
||||||
|
cid: categoryObj.cid,
|
||||||
|
title: 'will delete',
|
||||||
|
content: 'The content of deleted topic',
|
||||||
|
});
|
||||||
|
await Topics.delete(data.topicData.tid, adminUid);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get recent replies in category', (done) => {
|
it('should get recent replies in category', (done) => {
|
||||||
@@ -255,10 +262,22 @@ describe('Categories', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not show deleted topic titles', async () => {
|
||||||
|
const data = await socketCategories.loadMore({ uid: 0 }, {
|
||||||
|
cid: categoryObj.cid,
|
||||||
|
after: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
data.topics.map(t => t.title),
|
||||||
|
['[[topic:topic_is_deleted]]', 'Test Topic Title', 'Test Topic Title'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should load topic count', (done) => {
|
it('should load topic count', (done) => {
|
||||||
socketCategories.getTopicCount({ uid: posterUid }, categoryObj.cid, (err, topicCount) => {
|
socketCategories.getTopicCount({ uid: posterUid }, categoryObj.cid, (err, topicCount) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(topicCount, 2);
|
assert.strictEqual(topicCount, 3);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user