diff --git a/test/topics.js b/test/topics.js index 8a32e445f5..2b124c96f4 100644 --- a/test/topics.js +++ b/test/topics.js @@ -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);