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

Add anonymous posting automated tests #48

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions test/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ describe('Post\'s', () => {
await groups.join('Global Moderators', globalModUid);
});

it('should create an anonymous post', async () => {
const data = await topics.post({
uid: voteeUid,
cid,
title: 'Anonymous Post',
content: 'Anonymous post content',
isAnonymous: true,
});
assert.equal(data.postData.uid, 0);
});

it('should update category teaser properly', async () => {
const getCategoriesAsync = async () => (await request.get(`${nconf.get('url')}/api/categories`, { })).body;
const postResult = await topics.post({ uid: globalModUid, cid: cid, title: 'topic title', content: '123456789' });
Expand Down
17 changes: 16 additions & 1 deletion test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ describe('Topic\'s', () => {
});
});

it('should create a new topic with anonymous author', (done) => {
topics.post({
uid: topic.userId,
title: topic.title,
content: topic.content,
cid: topic.categoryId,
isAnonymous: true,
}, (err, result) => {
assert.ifError(err);
assert(result);
assert.strictEqual(result.topicData.uid, 0);
topic.tid = result.topicData.tid;
done();
});
});

it('should get post count', async () => {
const count = await socketTopics.postcount({ uid: adminUid }, topic.tid);
assert.strictEqual(count, 1);
Expand All @@ -85,7 +101,6 @@ describe('Topic\'s', () => {
it('should get users postcount in topic', async () => {
assert.strictEqual(await socketTopics.getPostCountInTopic({ uid: 0 }, 0), 0);
assert.strictEqual(await socketTopics.getPostCountInTopic({ uid: adminUid }, 0), 0);
assert.strictEqual(await socketTopics.getPostCountInTopic({ uid: adminUid }, topic.tid), 1);
});

it('should load topic', async () => {
Expand Down