Skip to content

Conversation

@GideonBature
Copy link
Contributor

@GideonBature GideonBature commented Jun 28, 2025

🚀 Volunchain Pull Request

Mark with an x all the checkboxes that apply (like [x])


📌 Type of Change

  • Documentation (updates to README, docs, or comments)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

📝 Changes description

🏗️ Structural Reorganization

  • Moved controllers to module-based structure: Migrated all controllers from src/controllers/ to src/modules/{module-name}/presentation/controllers/
  • Updated import paths: Fixed all relative imports in controllers to reflect the new directory structure (e.g., ../services/../../../../services/)

🧪 Added Integration Tests

  • Created controller-level tests for all major modules:
    • AuthController - Tests registration validation
    • CertificateController - Tests certificate download authorization
    • NFTController - Tests NFT creation validation
    • OrganizationController - Tests organization creation validation
    • ProjectController - Tests project creation validation
    • UserController - Basic controller method verification
    • VolunteerController - Tests volunteer creation validation

📸 Evidence (A photo is required as evidence)


⏰ Time spent breakdown


🌌 Comments


Thank you for contributing to Volunchain, we are glad that you have chosen us as your project of choice and we hope that you continue to contribute to this great project, so that together we can make our mark at the top!

Summary by CodeRabbit

  • Tests

    • Added integration test suites for authentication, certificate, NFT, organization, project, user, and volunteer controllers to verify method existence and error handling for invalid or incomplete input.
  • Refactor

    • Updated import paths in multiple controller files to use deeper relative paths, improving module referencing consistency. No changes to application logic or user-facing functionality.
  • Chores

    • Improved formatting and version specification in the CI workflow configuration for better clarity and stability.

@coderabbitai
Copy link

coderabbitai bot commented Jun 28, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (4)
  • .DS_Store is excluded by !**/.DS_Store
  • src/.DS_Store is excluded by !**/.DS_Store
  • src/modules/.DS_Store is excluded by !**/.DS_Store
  • src/modules/volunteer/.DS_Store is excluded by !**/.DS_Store

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

"""

Walkthrough

This change updates import paths for controller files across multiple modules to reflect their relocation into src/modules/*/presentation/controllers as per a domain-driven design structure. It also introduces new integration test suites for each controller in their respective module test directories, verifying method existence and basic validation/error handling.

Changes

Files Change Summary
src/modules/auth/presentation/controllers/Auth.controller.ts
src/modules/certificate/presentation/controllers/certificate.controller.ts
src/modules/nft/presentation/controllers/NFTController.ts
src/modules/organization/presentation/controllers/OrganizationController.ts
src/modules/project/presentation/controllers/Project.controller.ts
src/modules/user/presentation/controllers/UserController.ts
src/modules/user/presentation/controllers/userVolunteer.controller.ts
src/modules/volunteer/presentation/controllers/VolunteerController.ts
Updated import paths for services, DTOs, and utilities to reflect new controller locations.
src/modules/auth/tests/controllers/AuthController.int.test.ts
src/modules/certificate/tests/controllers/certificate.controller.int.test.ts
src/modules/nft/tests/controllers/NFTController.int.test.ts
src/modules/organization/tests/controllers/OrganizationController.int.test.ts
src/modules/project/tests/controllers/ProjectController.int.test.ts
src/modules/user/tests/controllers/UserController.int.test.ts
src/modules/volunteer/tests/controllers/VolunteerController.int.test.ts
Added integration test suites for each controller, verifying method existence and basic error cases.

Sequence Diagram(s)

sequenceDiagram
    participant TestSuite
    participant Controller
    participant ExpressRequest
    participant ExpressResponse

    TestSuite->>Controller: Call method (e.g., createX) with mock Request/Response
    Controller->>ExpressRequest: Validate input
    alt Missing Required Fields
        Controller->>ExpressResponse: res.status(400).json({ error: ... })
    else Valid Input
        Controller->>ExpressResponse: res.status(200).json({ ... })
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Move each controller to its module folder (#125)
Update all route imports to use the new path (#125)
Add a controller-level integration test in module tests/controllers/ (#125)
Delete src/controllers folder after migration (#125) No evidence in this diff; cannot confirm deletion of legacy directory from provided summary.
Verify controller decorators and route paths remain functional post-move (#125) No explicit verification of decorators or route paths in the summary or test descriptions.

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

In burrows deep, controllers moved,
To module homes, their paths improved.
With tests that check each rabbit's hop,
No missing fields, no reason to stop!
🐇 Code now neat, in modules tight,
Integration tests ensure delight.
"""


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (2)
src/modules/certificate/presentation/controllers/certificate.controller.ts (2)

105-105: Avoid exposing internal error details.

The error response includes the raw error object which might expose sensitive internal information.

-    res.status(500).json({ error: "Failed to create certificate", err });
+    res.status(500).json({ error: "Failed to create certificate" });

35-35: Guard against missing certificate before logging download

The first prisma.certificate.findUnique result isn’t null-checked before using cert!.id, which can crash at runtime. Add a guard like in the second branch:

• File: src/modules/certificate/presentation/controllers/certificate.controller.ts
• Lines: around 29–35

Suggested diff:

-      const cert = await prisma.certificate.findUnique({ where: { id: volunteerId } });
-      await certificateService.logDownload(cert!.id, userId);
+      const cert = await prisma.certificate.findUnique({ where: { id: volunteerId } });
+      if (!cert) {
+        return res.status(404).json({ error: "Certificate not found" });
+      }
+      await certificateService.logDownload(cert.id, userId);
🧹 Nitpick comments (8)
src/modules/nft/presentation/controllers/NFTController.ts (3)

5-5: Clean up comment formatting.

The comment uses underscores instead of spaces, which is inconsistent with standard commenting practices.

-  // Creates_a_new_NFT_and_returns_the_created_NFT_data_OKK!!
+  // Creates a new NFT and returns the created NFT data

41-41: Fix method naming inconsistency.

The method name DeleteNFT doesn't follow camelCase convention used by other methods in this controller.

-      await NFTService.DeleteNFT(req.params.id);
+      await NFTService.deleteNFT(req.params.id);

42-42: Fix typo in response message.

There's a spelling error in the success message.

-      res.json(`succefully delete NFT ${req.params.id}`);
+      res.json(`Successfully deleted NFT ${req.params.id}`);
src/modules/nft/__tests__/controllers/NFTController.int.test.ts (1)

1-23: Basic test structure is good but could be more comprehensive.

The integration test correctly verifies method existence and basic error handling. However, consider expanding the test coverage to include more scenarios and edge cases.

Consider adding tests for:

  • Valid NFT creation scenarios
  • Different types of validation errors
  • Authorization scenarios
  • Edge cases for getNFTById and other methods
+  test("should create NFT successfully with valid data", async () => {
+    const validNFTData = { name: "Test NFT", description: "Test" };
+    const req = { body: validNFTData } as Partial<Request>;
+    const res = {
+      status: jest.fn().mockReturnThis(),
+      json: jest.fn(),
+    } as Partial<Response>;
+    
+    await NFTController.createNFT(req as Request, res as Response);
+    expect(res.status).toHaveBeenCalledWith(201);
+  });
src/modules/volunteer/__tests__/controllers/VolunteerController.int.test.ts (1)

8-12: Remove unnecessary method existence test.

Testing for method existence is redundant since TypeScript compilation would catch missing methods. This test doesn't add meaningful value to the test suite.

-  it("should have a createVolunteer method", () => {
-    expect(typeof VolunteerController.prototype.createVolunteer).toBe(
-      "function"
-    );
-  });
src/modules/certificate/__tests__/controllers/certificate.controller.int.test.ts (1)

6-8: Remove unnecessary function existence test.

Testing for function existence adds no value since TypeScript compilation ensures the function exists.

-  it("should have a downloadCertificate function", () => {
-    expect(typeof CertificateController.downloadCertificate).toBe("function");
-  });
src/modules/project/__tests__/controllers/ProjectController.int.test.ts (2)

6-9: Inconsistent test pattern: mixing instance and prototype.

The test creates a controller instance but then checks the prototype method. Consider using a consistent approach - either test all methods on the prototype or test instance methods consistently.

-  const controller = new ProjectController();
-  
-  it("should have a createProject method", () => {
-    expect(typeof ProjectController.prototype.createProject).toBe("function");
+  it("should have a createProject method", () => {
+    expect(typeof new ProjectController().createProject).toBe("function");

20-22: Inconsistent error property expectation.

This test expects an error property while other similar tests in the codebase expect a message property. Consider standardizing the error response format across all controllers.

-    expect(res.json).toHaveBeenCalledWith(
-      expect.objectContaining({ error: expect.any(String) })
-    );
+    expect(res.json).toHaveBeenCalledWith(
+      expect.objectContaining({ message: expect.any(String) })
+    );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8444abe and b44c4f4.

📒 Files selected for processing (15)
  • src/modules/auth/__tests__/controllers/AuthController.int.test.ts (1 hunks)
  • src/modules/auth/presentation/controllers/Auth.controller.ts (6 hunks)
  • src/modules/certificate/__tests__/controllers/certificate.controller.int.test.ts (1 hunks)
  • src/modules/certificate/presentation/controllers/certificate.controller.ts (1 hunks)
  • src/modules/nft/__tests__/controllers/NFTController.int.test.ts (1 hunks)
  • src/modules/nft/presentation/controllers/NFTController.ts (1 hunks)
  • src/modules/organization/__tests__/controllers/OrganizationController.int.test.ts (1 hunks)
  • src/modules/organization/presentation/controllers/OrganizationController.ts (1 hunks)
  • src/modules/project/__tests__/controllers/ProjectController.int.test.ts (1 hunks)
  • src/modules/project/presentation/controllers/Project.controller.ts (1 hunks)
  • src/modules/user/__tests__/controllers/UserController.int.test.ts (1 hunks)
  • src/modules/user/presentation/controllers/UserController.ts (1 hunks)
  • src/modules/user/presentation/controllers/userVolunteer.controller.ts (1 hunks)
  • src/modules/volunteer/__tests__/controllers/VolunteerController.int.test.ts (1 hunks)
  • src/modules/volunteer/presentation/controllers/VolunteerController.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/modules/organization/__tests__/controllers/OrganizationController.int.test.ts (1)
src/modules/organization/presentation/controllers/organization.controller.ts (1)
  • OrganizationController (12-132)
src/modules/volunteer/__tests__/controllers/VolunteerController.int.test.ts (1)
src/modules/volunteer/presentation/controllers/VolunteerController.ts (1)
  • VolunteerController (5-52)
🔇 Additional comments (12)
src/modules/nft/presentation/controllers/NFTController.ts (1)

2-2: Import path update looks correct.

The import path change aligns with the module restructuring objective and correctly navigates from the new controller location to the services directory.

src/modules/volunteer/presentation/controllers/VolunteerController.ts (1)

2-3: Import path updates are correct.

Both import paths have been appropriately updated to reflect the new module structure, correctly navigating from the controller's new location to the services and DTO directories.

src/modules/user/presentation/controllers/UserController.ts (1)

1-5: All import path updates are correct.

The import paths have been systematically updated to reflect the new module structure, properly navigating from the controller's new location to the respective modules, services, and types directories.

src/modules/certificate/presentation/controllers/certificate.controller.ts (1)

1-5: Import path updates are correct.

All import paths have been appropriately updated to reflect the new module structure. The reordering of the Response import is a minor change that doesn't affect functionality.

src/modules/certificate/__tests__/controllers/certificate.controller.int.test.ts (1)

10-33: Verified status code for non-existent volunteer

The downloadCertificate controller indeed returns a 403 when the volunteer isn’t found (lines 21–24), so the test’s expectation of 403 is correct. If you’d rather treat “volunteer not found” as a 404, update both the controller (to res.status(404)) and the corresponding test assertion; otherwise, no change is needed.

src/modules/project/presentation/controllers/Project.controller.ts (1)

2-2: Import path is correct

The ProjectService file exists at src/services/ProjectService.ts, and the four-level relative import from
src/modules/project/presentation/controllers/Project.controller.ts correctly resolves to it. No further updates are needed.

src/modules/user/presentation/controllers/userVolunteer.controller.ts (1)

2-3: Import paths verified and correct

Both imports (UserVolunteerService and prisma) correctly resolve to src/services/userVolunteer.service.ts and src/config/prisma.ts from src/modules/user/presentation/controllers/userVolunteer.controller.ts. No changes needed.

src/modules/organization/presentation/controllers/OrganizationController.ts (1)

2-3: Import paths correctly updated for new module structure.

The import paths have been properly adjusted to reflect the controller's new location in the domain-driven module structure. The deep relative paths correctly traverse from src/modules/organization/presentation/controllers/ to the root-level services and utils directories.

src/modules/auth/presentation/controllers/Auth.controller.ts (2)

2-3: Import paths correctly updated for new module structure.

The import paths have been properly adjusted to traverse from the new controller location to the services and types directories.


25-27: Good refactor: Consolidated error handling responses.

The consolidation of res.status().json() calls into single chained statements improves readability and follows Express.js best practices. The error handling logic remains intact with proper instanceof Error checks and fallback messages.

Also applies to: 48-50, 69-72, 83-85, 104-109

src/modules/auth/__tests__/controllers/AuthController.int.test.ts (1)

1-22: Well-structured integration test with proper mocking.

The test correctly verifies method existence and error handling behavior using appropriate Express request/response mocks. The async/await handling is proper, and the assertions check for expected HTTP status codes and error message structure.

src/modules/organization/__tests__/controllers/OrganizationController.int.test.ts (1)

10-26: I’d like to confirm which OrganizationController the test is importing to ensure it matches the intended implementation. Can you show the import statement(s) at the top of src/modules/organization/__tests__/controllers/OrganizationController.int.test.ts? Specifically, the lines where OrganizationController is brought in.

Move controllers to module structure and add controller-level tests
@GideonBature
Copy link
Contributor Author

GideonBature commented Jun 29, 2025

The Test CI/test is failing because I observed that on line 33 in the .github/workflows/test.yml file 3 was omitted in the actions/setup-node@v, so I have corrected it to actions/setup-node@v4. Used 4 because the CI was complaining of v3 being outdated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/modules/user/__tests__/controllers/UserController.int.test.ts (2)

11-24: Enhance DTO mocks to reflect real validation behavior.

The current DTO mocks return empty objects, which may not accurately simulate the validation and transformation logic of the actual DTOs. Consider mocking them to return more realistic data or validation results.

-jest.mock("../../../../modules/user/dto/CreateUserDto", () => {
-  return {
-    CreateUserDto: function () {
-      return {};
-    },
-  };
-});
+jest.mock("../../../../modules/user/dto/CreateUserDto", () => {
+  return {
+    CreateUserDto: function (data: any) {
+      // Mock validation logic
+      if (!data.email) throw new Error("Email is required");
+      return { email: data.email, ...data };
+    },
+  };
+});

48-60: Consider extracting mock setup to reduce duplication.

The UserService mock setup is repeated across multiple tests. Consider extracting this to a helper function or using beforeEach for cleaner test organization.

+  const mockUserService = (methods: Partial<any>) => {
+    (UserService as jest.Mock).mockImplementation(() => methods);
+  };
+
   describe("POST /users", () => {
     it("should create a user and return 201", async () => {
       const mockUser = { id: "1", email: "[email protected]" };
-      (UserService as jest.Mock).mockImplementation(() => ({
-        createUser: jest.fn().mockResolvedValue(mockUser),
-      }));
+      mockUserService({
+        createUser: jest.fn().mockResolvedValue(mockUser),
+      });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b44c4f4 and 96c8b3c.

⛔ Files ignored due to path filters (1)
  • src/.DS_Store is excluded by !**/.DS_Store
📒 Files selected for processing (16)
  • .github/workflows/test.yml (3 hunks)
  • src/modules/auth/__tests__/controllers/AuthController.int.test.ts (1 hunks)
  • src/modules/auth/presentation/controllers/Auth.controller.ts (6 hunks)
  • src/modules/certificate/__tests__/controllers/certificate.controller.int.test.ts (1 hunks)
  • src/modules/certificate/presentation/controllers/certificate.controller.ts (1 hunks)
  • src/modules/nft/__tests__/controllers/NFTController.int.test.ts (1 hunks)
  • src/modules/nft/presentation/controllers/NFTController.ts (1 hunks)
  • src/modules/organization/__tests__/controllers/OrganizationController.int.test.ts (1 hunks)
  • src/modules/organization/presentation/controllers/OrganizationController.ts (1 hunks)
  • src/modules/project/__tests__/controllers/ProjectController.int.test.ts (1 hunks)
  • src/modules/project/presentation/controllers/Project.controller.ts (1 hunks)
  • src/modules/user/__tests__/controllers/UserController.int.test.ts (1 hunks)
  • src/modules/user/presentation/controllers/UserController.ts (1 hunks)
  • src/modules/user/presentation/controllers/userVolunteer.controller.ts (1 hunks)
  • src/modules/volunteer/__tests__/controllers/VolunteerController.int.test.ts (1 hunks)
  • src/modules/volunteer/presentation/controllers/VolunteerController.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/modules/project/tests/controllers/ProjectController.int.test.ts
  • src/modules/nft/tests/controllers/NFTController.int.test.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/modules/project/presentation/controllers/Project.controller.ts
  • src/modules/organization/presentation/controllers/OrganizationController.ts
  • src/modules/nft/presentation/controllers/NFTController.ts
  • src/modules/user/presentation/controllers/userVolunteer.controller.ts
  • src/modules/volunteer/presentation/controllers/VolunteerController.ts
  • src/modules/user/presentation/controllers/UserController.ts
  • src/modules/auth/presentation/controllers/Auth.controller.ts
  • src/modules/auth/tests/controllers/AuthController.int.test.ts
  • src/modules/certificate/presentation/controllers/certificate.controller.ts
  • src/modules/certificate/tests/controllers/certificate.controller.int.test.ts
  • src/modules/organization/tests/controllers/OrganizationController.int.test.ts
  • src/modules/volunteer/tests/controllers/VolunteerController.int.test.ts
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/test.yml

33-33: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
src/modules/user/__tests__/controllers/UserController.int.test.ts (1)

45-155: Excellent comprehensive test coverage!

This integration test suite significantly improves upon the previous minimal implementation by providing thorough coverage of all UserController endpoints with both success and error scenarios. The test structure is well-organized and covers:

  • POST /users: Creation with success/error cases
  • GET /users/:id: Retrieval by ID with success/not found/error cases
  • GET /users?email=: Retrieval by email with validation and error handling
  • PUT /users/:id: Update operations with proper error handling

The HTTP status codes and response assertions are appropriate for each scenario.

@GideonBature GideonBature force-pushed the move branch 2 times, most recently from 6eae6fc to 1396b71 Compare June 29, 2025 04:53
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/modules/user/__tests__/controllers/UserController.int.test.ts (3)

22-25: Improve UpdateUserDto mock to be more realistic.

The current mock returns an empty object, which doesn't reflect realistic DTO behavior and may not catch potential validation issues in the controller.

 jest.mock("../../dto/UpdateUserDto", () => {
   return {
-    UpdateUserDto: function () {
-      return {};
+    UpdateUserDto: function (data: Record<string, unknown>) {
+      // Mock basic validation similar to CreateUserDto
+      return { ...data };
     },
   };
 });

39-41: Consider renaming for clarity.

The function name mockUserService could be more descriptive to indicate it's setting up the mock implementation.

-const mockUserService = (methods: Partial<Record<string, unknown>>) => {
+const setupMockUserService = (methods: Partial<Record<string, unknown>>) => {
   (UserService as jest.Mock).mockImplementation(() => methods);
 };

Don't forget to update the function calls in the test cases accordingly.


64-74: Consider adding more specific error scenarios.

While the current error handling tests are good, consider adding tests for more specific error types that might occur in production, such as validation errors, database connection issues, or business logic violations.

Example addition for more specific error testing:

it("should handle validation errors with specific status codes", async () => {
  (UserService as jest.Mock).mockImplementation(() => ({
    createUser: jest.fn().mockRejectedValue(new ValidationError("Invalid email format")),
  }));
  const res = await request(app)
    .post("/users")
    .send({ email: "invalid-email" });
  expect(res.status).toBe(422); // Unprocessable Entity for validation errors
  expect(res.body.error).toContain("Invalid email format");
});

Also applies to: 96-104, 132-140, 152-160

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6eae6fc and 1396b71.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (3 hunks)
  • src/modules/user/__tests__/controllers/UserController.int.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/test.yml
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/modules/user/__tests__/controllers/UserController.int.test.ts (1)
src/services/UserService.ts (1)
  • UserService (12-45)
🔇 Additional comments (1)
src/modules/user/__tests__/controllers/UserController.int.test.ts (1)

43-161: Excellent improvement in test coverage!

This comprehensive integration test suite successfully addresses the previous review comment concerns by providing meaningful tests that cover:

  • All CRUD operations (Create, Read by ID/email, Update)
  • Success and error scenarios for each endpoint
  • Proper HTTP status codes and response validation
  • Input validation testing
  • Service layer error handling

The tests now provide real value by verifying controller behavior rather than just checking method existence.

Copy link
Member

@Villarley Villarley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Villarley Villarley merged commit 97628c1 into VolunChain:main Jul 8, 2025
1 of 2 checks passed
@GideonBature
Copy link
Contributor Author

Thank you ser!

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.

Move All Top-Level Controllers Into src/modules/*/presentation/controllers

2 participants