From c6d09396208a10c244d7b3d22ffd2d7dd1274d3a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 24 Jul 2020 13:41:32 -0400 Subject: [PATCH] fix: more tests --- src/flags.js | 6 +++--- test/flags.js | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/flags.js b/src/flags.js index 6cf8c421e5..ddea5bf08c 100644 --- a/src/flags.js +++ b/src/flags.js @@ -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, }); diff --git a/test/flags.js b/test/flags.js index 2ecb189e49..41a7c6864c 100644 --- a/test/flags.js +++ b/test/flags.js @@ -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)); }); });