Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Checking Pin Button Visibility #44

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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