Skip to content

Commit

Permalink
test: more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
oplik0 committed Nov 4, 2023
1 parent f53aaf9 commit 2f00059
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion library.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ plugin.postQueue = async function ({ shouldQueue, uid, data }) {
} catch (err) {
winston.error(`[plugin/${plugin.id}] Error: ${err.message}`);
}
winston.info(`[plugin/${plugin.id}] Post data: ${JSON.stringify(data)} - privileges: ${await user.isPrivileged(uid)} - exempt: ${await groups.isMemberOfAny(uid, meta.config.groupsExemptFromPostQueue)}`);
winston.info(`[plugin/${plugin.id}] uid: ${uid} Post data: ${JSON.stringify(data)} - privileges: ${await user.isPrivileged(uid)} - exempt: ${await groups.isMemberOfAny(uid, meta.config.groupsExemptFromPostQueue)}`);
winston.info(`[plugin/${plugin.id}] Settings: ${JSON.stringify(plugin.settings)}`)
return { shouldQueue, uid, data };
};
Expand Down
78 changes: 39 additions & 39 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,47 +139,47 @@ describe('nodebb-plugin-category-queue', () => {
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'off');
});

// it('should not queue new topics by privileged users if enabled', async () => {
// await meta.settings.setOne('category-queue', `${cid}-enabled`, 'on');
// await meta.settings.setOne('category-queue', `${cid}-privileged`, 'on');
it('should not queue new topics by privileged users if enabled', async () => {
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'on');
await meta.settings.setOne('category-queue', `${cid}-privileged`, 'on');

// winston.info(`user.isPrivileged(${unprivilegedUid}) = ${await user.isPrivileged(unprivilegedUid)}`);
// winston.info(`user.isPrivileged(${exemptUid}) = ${await user.isPrivileged(exemptUid)}`);
// winston.info(`user.isPrivileged(${adminUid}) = ${await user.isPrivileged(adminUid)}`);
// // assert(
// // await posts.shouldQueue(unprivilegedUid, { cid, content: 'Just a test topic' }),
// // "Unprivileged user's topic was not queued",
// // );
// // assert(
// // await posts.shouldQueue(exemptUid, { cid, content: 'Just a test topic' }),
// // "Exempt user's topic was not queued",
// // );
// assert(
// !await posts.shouldQueue(adminUid, { cid, content: 'Just a test topic' }),
// "Administrator's topic was queued",
// );
// await meta.settings.setOne('category-queue', `${cid}-privileged`, 'off');
// await meta.settings.setOne('category-queue', `${cid}-enabled`, 'off');
// });
winston.info(`user.isPrivileged(${unprivilegedUid}) = ${await user.isPrivileged(unprivilegedUid)}`);
winston.info(`user.isPrivileged(${exemptUid}) = ${await user.isPrivileged(exemptUid)}`);
winston.info(`user.isPrivileged(${adminUid}) = ${await user.isPrivileged(adminUid)}`);
assert(
await posts.shouldQueue(unprivilegedUid, { cid, content: 'Just a test topic' }),
"Unprivileged user's topic was not queued",
);
assert(
await posts.shouldQueue(exemptUid, { cid, content: 'Just a test topic' }),
"Exempt user's topic was not queued",
);
assert(
!await posts.shouldQueue(adminUid, { cid, content: 'Just a test topic' }),
"Administrator's topic was queued",
);
await meta.settings.setOne('category-queue', `${cid}-privileged`, 'off');
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'off');
});

// it('should not queue new replies by privileged users if enabled', async () => {
// await meta.settings.setOne('category-queue', `${cid}-enabled`, 'on');
// await meta.settings.setOne('category-queue', `${cid}-privileged`, 'on');
// assert(
// await posts.shouldQueue(unprivilegedUid, { tid, content: 'Just a test reply' }),
// "Unprivileged user's reply was not queued",
// );
// assert(
// await posts.shouldQueue(exemptUid, { tid, content: 'Just a test reply' }),
// "Exempt user's reply was not queued",
// );
// assert(
// !await posts.shouldQueue(adminUid, { tid, content: 'Just a test reply' }),
// "Administrator's reply was queued",
// );
// await meta.settings.setOne('category-queue', `${cid}-privileged`, 'off');
// await meta.settings.setOne('category-queue', `${cid}-enabled`, 'off');
// });
it('should not queue new replies by privileged users if enabled', async () => {
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'on');
await meta.settings.setOne('category-queue', `${cid}-privileged`, 'on');
assert(
await posts.shouldQueue(unprivilegedUid, { tid, content: 'Just a test reply' }),
"Unprivileged user's reply was not queued",
);
assert(
await posts.shouldQueue(exemptUid, { tid, content: 'Just a test reply' }),
"Exempt user's reply was not queued",
);
assert(
!await posts.shouldQueue(adminUid, { tid, content: 'Just a test reply' }),
"Administrator's reply was queued",
);
await meta.settings.setOne('category-queue', `${cid}-privileged`, 'off');
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'off');
});

it('should not queue new topics by exempt groups if enabled', async () => {
await meta.settings.setOne('category-queue', `${cid}-enabled`, 'on');
Expand Down

0 comments on commit 2f00059

Please sign in to comment.