fix: more tests

This commit is contained in:
Julian Lam
2020-07-24 13:41:32 -04:00
parent 32f9af2a87
commit c6d0939620
2 changed files with 8 additions and 9 deletions

View File

@@ -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,
});

View File

@@ -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));
});
});