Skip to content

Commit

Permalink
Merge pull request #39 from CMU-313/savannahxunc/add-tests
Browse files Browse the repository at this point in the history
Added automated tests for quick anonymous reply feature
  • Loading branch information
joonhoswe authored Feb 27, 2025
2 parents fa32ab3 + bf24381 commit 458de1f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions UserGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# All Features
## Feature 1: Endorse By Staff Feature

## Feature 2: Quick Anonymous Reply
### How to use?
[**This video shows how to use this feature!**](https://github.com/user-attachments/assets/6fd3c1cb-006e-4dc0-a449-10fb6a254b44)

### How to test?
This feature is triggered by the UI when the user clicks on the "**Anonymous Reply**" button. We are not doing UI level automated testing, rather we are testing the backend. Next time, we use tools, like Puppeteer, that can implement UI automated tests.

To test backend:
**We added a test case in `test/topics.js` (line starting from 271)**

**Why we believe this works:**
Anonymous reply only required one extra backend parameter (**handle == 1**), and we tested exactly for that condition.
11 changes: 10 additions & 1 deletion test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Topic\'s', () => {
topic = {
userId: adminUid,
categoryId: categoryObj.cid,
title: 'Test Topic Title',
title: 'Test Topic Title2025',
content: 'The content of test topic',
};
});
Expand Down Expand Up @@ -268,6 +268,15 @@ describe('Topic\'s', () => {
});
});

it('should create a new anonymous reply with proper parameters', (done) => {
topics.reply({ uid: topic.userId, content: 'test post1234', tid: newTopic.tid, handle: 1 }, (err, result) => {
assert.equal(err, null, 'was created with error');
assert.ok(result);

done();
});
});

it('should handle direct replies', async () => {
const result = await topics.reply({ uid: topic.userId, content: 'test reply', tid: newTopic.tid, toPid: newPost.pid });
assert.ok(result);
Expand Down

0 comments on commit 458de1f

Please sign in to comment.