mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 00:21:16 +01:00
fix: more tests
This commit is contained in:
@@ -504,7 +504,7 @@ Flags.update = async function (flagId, uid, changeset) {
|
||||
tasks.push(db.sortedSetAdd('flags:byState:' + changeset[prop], now, flagId));
|
||||
tasks.push(db.sortedSetRemove('flags:byState:' + current[prop], flagId));
|
||||
if (changeset[prop] === 'resolved' || changeset[prop] === 'rejected') {
|
||||
tasks.push(notifications.rescind('flag:' + current.type + ':' + current.targetId + ':uid:' + current.uid));
|
||||
tasks.push(notifications.rescind('flag:' + current.type + ':' + current.targetId));
|
||||
}
|
||||
}
|
||||
} else if (prop === 'assignee') {
|
||||
@@ -610,7 +610,7 @@ Flags.notify = async function (flagObj, uid) {
|
||||
bodyLong: flagObj.description,
|
||||
pid: flagObj.targetId,
|
||||
path: '/flags/' + flagObj.flagId,
|
||||
nid: 'flag:post:' + flagObj.targetId + ':uid:' + uid,
|
||||
nid: 'flag:post:' + flagObj.targetId,
|
||||
from: uid,
|
||||
mergeId: 'notifications:user_flagged_post_in|' + flagObj.targetId,
|
||||
topicTitle: title,
|
||||
@@ -622,7 +622,7 @@ Flags.notify = async function (flagObj, uid) {
|
||||
bodyShort: '[[notifications:user_flagged_user, ' + flagObj.reports[flagObj.reports.length - 1].reporter.username + ', ' + flagObj.target.username + ']]',
|
||||
bodyLong: flagObj.description,
|
||||
path: '/flags/' + flagObj.flagId,
|
||||
nid: 'flag:user:' + flagObj.targetId + ':uid:' + uid,
|
||||
nid: 'flag:user:' + flagObj.targetId,
|
||||
from: uid,
|
||||
mergeId: 'notifications:user_flagged_user|' + flagObj.targetId,
|
||||
});
|
||||
|
||||
@@ -48,10 +48,10 @@ describe('Flags', function () {
|
||||
assert.ifError(err);
|
||||
var compare = {
|
||||
flagId: 1,
|
||||
uid: 1,
|
||||
targetId: 1,
|
||||
type: 'post',
|
||||
description: 'Test flag',
|
||||
state: 'open',
|
||||
target_readable: 'Post 1',
|
||||
};
|
||||
assert(flagData);
|
||||
for (var key in compare) {
|
||||
@@ -124,11 +124,10 @@ describe('Flags', function () {
|
||||
assert.ifError(err);
|
||||
var compare = {
|
||||
flagId: 1,
|
||||
uid: 1,
|
||||
targetId: 1,
|
||||
type: 'post',
|
||||
description: 'Test flag',
|
||||
state: 'open',
|
||||
target_readable: 'Post 1',
|
||||
};
|
||||
assert(flagData);
|
||||
for (var key in compare) {
|
||||
@@ -378,14 +377,14 @@ describe('Flags', function () {
|
||||
await sleep(2000);
|
||||
|
||||
let userNotifs = await User.notifications.getAll(adminUid);
|
||||
assert(userNotifs.includes('flag:post:' + result.postData.pid + ':uid:' + uid1));
|
||||
assert(userNotifs.includes('flag:post:' + result.postData.pid));
|
||||
|
||||
await Flags.update(flagId, adminUid, {
|
||||
state: 'resolved',
|
||||
});
|
||||
|
||||
userNotifs = await User.notifications.getAll(adminUid);
|
||||
assert(!userNotifs.includes('flag:post:' + result.postData.pid + ':uid:' + uid1));
|
||||
assert(!userNotifs.includes('flag:post:' + result.postData.pid));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user