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 Endorse Feature with Backend Functionality and Unit Tests #75

Open
wants to merge 32 commits into
base: f24
Choose a base branch
from

Conversation

rilical
Copy link

@rilical rilical commented Oct 10, 2024

Overview

This pull request introduces the Endorse feature, enabling users to endorse and unendorse posts within the application. To ensure the reliability and robustness of this feature, comprehensive unit tests have been implemented for both backend and client-side components.

Features

1. Endorse Feature Implementation

  • Backend Enhancements:

    • Posts Module (src/posts.js):
      • Added functions to handle endorsing and unendorsing posts.
      • Implemented logic to prevent users from endorsing their own posts.
      • Ensured endorsement counts are accurately tracked and updated.
    • Topics Module (src/topics.js):
      • Integrated endorsement functionality within the context of topics.
      • Updated topic data to reflect endorsement-related information.
    • API Routes (src/routes/api.js):
      • Created API endpoints for endorsing (PUT /posts/:pid/endorse) and unendorsing (DELETE /posts/:pid/endorse) posts.
      • Ensured proper authentication and authorization checks are in place for these endpoints.
  • Client-Side Enhancements:

    • Post Tools (public/src/client/topic/postTools.js):
      • Added endorse button functionality that interacts with the backend API.
      • Implemented UI updates to reflect the endorsement status of posts.

2. Unit Tests

  • Server-Side Tests (test/posts.js and test/topics.js):

    • Endorse Feature Tests:
      • test/posts.js:
        • Endorsing a Post: Verifies that a user can successfully endorse a post.
        • Unendorsing a Post: Ensures that a user can remove their endorsement.
        • Endorsement Count: Checks that endorsement counts are accurately incremented and decremented.
        • Endorsement Privileges: Confirms that only authorized users can endorse posts.
        • API Endpoints: Tests the /posts/:pid/endorse PUT and DELETE endpoints for correct behavior and error handling.
      • test/topics.js:
        • Endorsement in Topic Context: Validates that endorsements are correctly associated within topics.
        • Endorsed Posts in Listings: Ensures that endorsed posts appear appropriately in topic listings.
        • Endorsed Post Sorting: Verifies that endorsed posts are sorted correctly when sorting options are enabled.
  • Client-Side Tests (test/topic/endorse.js):

    • Endorse Button Functionality: Tests that clicking the endorse button triggers the correct API call.
    • UI Updates: Ensures that the UI reflects the endorsed state after an endorsement action.
    • API Call Handling: Checks that successful endorsements and errors are handled gracefully, providing appropriate user feedback.

Related Issues

  1. Issue refactor Flags.validate in src/flags.js #30
  2. Issue Imported all of the tpl files from the commit posted in Slack #18

github-classroom bot and others added 30 commits September 10, 2024 01:22
Merge individual changes made in Project 1
Add "Questions & Answers" category & corresponding subcategories
Added refactored code from previous assignment to current repository
Imported tpl files from the commit linked in Slack by Prof. Hilton and added names to the README
- Refactor categorySearch module for improved readability and maintainability
- Implement caching mechanism for category list
- Add support for local categories
- Optimize search performance with debounce
- Improve dropdown visibility handling
- Enhance error handling and user feedback
- Update DOM manipulation for better performance
- Add console logs for debugging purposes
Implemented "endorse" buttons for topics and replies on the front end
Refactored categorySearch.js
Reverting public/src/modules/categorySearch.js back to original
  3:1  error  'define' is not defined  no-undef
e_oghabayen added 2 commits October 10, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants