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

feat(comment Service): add delete comment functionality with authoriz… #1353

Merged
merged 2 commits into from
Mar 1, 2025

Conversation

Tempahh
Copy link
Contributor

@Tempahh Tempahh commented Mar 1, 2025

Pull Request

Description

This PR introduces the functionality to delete comments in the comments module. It includes a new endpoint in CommentsController, implements the delete logic in CommentsService, and updates unit tests to ensure comprehensive coverage.

Changes to CommentsController

Added the Delete decorator to import statements in src/modules/comments/comments.controller.ts.

Introduced the deleteAComment method with API documentation and proper response handling.

Changes to CommentsService

Implemented deleteAComment to handle comment deletion, including authorization checks.

Changes to unit tests

Updated the mock repository to include findOne and delete methods in src/modules/comments/tests/comments.service.spec.ts.

Added tests for deleteAComment to cover cases where the comment is not found, the user is not authorized, and successful deletion.

Related Issue

#1241

Fixes #(1241)

Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation updates
  • style: Code style/formatting changes
  • refactor: Code refactoring
  • perf: Performance improvements
  • test: Test additions/updates
  • chore: Build process or tooling changes
  • ci: CI configuration changes
  • other:

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual tests

Test Evidence

Screenshots

Screenshot 2025-03-01 at 22 43 32 Screenshot 2025-03-01 at 23 01 49 Screenshot 2025-03-01 at 23 02 16 Screenshot 2025-03-01 at 23 02 35

Checklist

  • [ x] My code follows the project's coding style
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have included a screenshot showing all tests passing
  • I have included documentation screenshots (if applicable)

@TheCodeGhinux TheCodeGhinux merged commit 16a572b into hngprojects:dev Mar 1, 2025
1 check passed
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.

2 participants