Skip to content

Commit

Permalink
Merge pull request #44 from CMU-313/pin-restr-test
Browse files Browse the repository at this point in the history
Added test checking pin button visibility
  • Loading branch information
karengc27 authored Oct 10, 2024
2 parents 7e3e82e + 6dedcec commit 63a22e3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,26 @@ describe('Topic\'s', () => {
assert.strictEqual(pinned, 0);
});

// Tests whether users who aren't admin can pin button (testing admin only restriction)
// CHATGPT PRODUCED CODE LINES 705-721
it('should not display pin button for regular users', async () => {
const regularUserUid = await User.create({ username: 'regularUser' });
const topic = await topics.post({
uid: adminUid,
title: 'Topic for pin button test',
content: 'Checking pin button visibility',
cid: categoryObj.cid,
});
const { tid } = topic.topicData;
try {
await apiTopics.pin({ uid: regularUserUid }, { tids: [tid], cid: categoryObj.cid });
} catch (err) {
assert.equal(err.message, '[[error:no-privileges]]');
return;
}
assert(false, 'Regular user should not have access to the pin button');
});

it('should move all topics', (done) => {
socketTopics.moveAll({ uid: adminUid }, { cid: moveCid, currentCid: categoryObj.cid }, (err) => {
assert.ifError(err);
Expand Down

0 comments on commit 63a22e3

Please sign in to comment.