Skip to content

Conversation

tejaskh3
Copy link
Contributor

@tejaskh3 tejaskh3 commented Jul 19, 2025

Date: 19 Jul, 2025

Developer Name: @tejaskh3


Issue Ticket Number

Description

  • Add OOO request approval/rejection logic
  • Update request validation and error handling
  • Add tests for OOO approval workflow

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

(it has already been changed in prev PR by Suraj and some index issue-2414 are also created

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

image image image image

Test Coverage

image image

Additional Notes

Description by Korbit AI

What change is being made?

Implement the functionality to approve or reject Out-of-Office (OOO) requests, including the addition of a new API endpoint, request validation, logging enhancements, and integration with existing request handling logic.

Why are these changes being made?

To provide management with the ability to acknowledge OOO requests through approval or rejection, ensuring that requests are processed correctly and consistently. This includes validation to prevent already acknowledged requests from being processed again, aligning with business rules, and improving error handling and messaging.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

- Add OOO request approval/rejection logic
- Update request validation and error handling
- Add tests for OOO approval workflow
@tejaskh3 tejaskh3 self-assigned this Jul 19, 2025
Copy link

coderabbitai bot commented Jul 19, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

Summary by CodeRabbit

  • New Features

    • Added the ability for super users to acknowledge Out-of-Office (OOO) requests, including approval or rejection with optional comments.
    • Introduced new validation and error messages for OOO request acknowledgment scenarios.
  • Bug Fixes

    • Improved error handling for missing or invalid request IDs and already processed requests.
  • Tests

    • Enabled and expanded unit and integration tests for OOO request acknowledgment and validation.
  • Documentation

    • Updated type definitions to support new OOO acknowledgment features.

Walkthrough

This change introduces the acknowledgment flow for Out-of-Office (OOO) requests, including new controller, service, model, middleware, validation logic, and TypeScript types. It adds new constants for logging and error messages, implements request ID lookup, and provides comprehensive tests for the new feature and its validators.

Changes

File(s) Change Summary
constants/requests.ts Added new log types, error messages, and validation constants for OOO request acknowledgment.
controllers/oooRequests.ts Added acknowledgeOooRequest controller to handle OOO request acknowledgment.
controllers/requests.ts Integrated OOO acknowledgment into the update request controller.
middlewares/validators/oooRequests.ts Added Joi schema and middleware for validating OOO acknowledgment requests.
middlewares/validators/requests.ts Updated validator to support OOO acknowledgment requests.
models/requests.ts Added getRequestById function to fetch requests by ID and handle not found errors.
services/oooRequest.ts Implemented OOO acknowledgment logic and validation in service layer.
types/oooRequest.d.ts Added new TypeScript types for OOO acknowledgment request and query structure.
test/fixtures/oooRequest/oooRequest.ts Renamed test fixture export for OOO acknowledgment request.
test/integration/requests.test.ts Enabled and updated tests for PATCH /requests/:id with OOO acknowledgment payloads.
test/unit/middlewares/oooRequests.test.ts Enabled and updated validator tests for OOO acknowledgment.
test/unit/models/requests.test.ts Added tests for getRequestById model function.
test/unit/services/oooRequest.test.ts Enabled and expanded tests for OOO acknowledgment service and validation logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Validator
    participant Service
    participant Model
    participant Logger

    User->>Controller: PATCH /requests/:id (OOO acknowledgment)
    Controller->>Validator: Validate request body
    Validator-->>Controller: Pass/fail (400 on fail)
    Controller->>Service: acknowledgeOooRequest(requestId, body, superUserId)
    Service->>Model: getRequestById(requestId)
    Model-->>Service: Request data or error
    Service->>Service: validateOooAcknowledgeRequest(type, status)
    Service->>Model: updateRequestStatus(requestId, body, superUserId)
    Service->>Logger: Log approved/rejected event
    Service-->>Controller: Success message and updated request
    Controller-->>User: 200 OK or error
Loading

Possibly related PRs

Suggested labels

backend, tests

Suggested reviewers

  • MayankBansal12
  • AnujChhikara
  • Achintya-Chatterjee

Poem

The OOO bunny hops with glee,
New flows for requests, as smooth as can be!
With types and tests, and logs anew,
Approve or reject—now easy to do.
From model to service, the logic is tight,
Patch your requests—everything’s right!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd129fb and a30d990.

📒 Files selected for processing (13)
  • constants/requests.ts (2 hunks)
  • controllers/oooRequests.ts (3 hunks)
  • controllers/requests.ts (3 hunks)
  • middlewares/validators/oooRequests.ts (2 hunks)
  • middlewares/validators/requests.ts (3 hunks)
  • models/requests.ts (2 hunks)
  • services/oooRequest.ts (2 hunks)
  • test/fixtures/oooRequest/oooRequest.ts (1 hunks)
  • test/integration/requests.test.ts (13 hunks)
  • test/unit/middlewares/oooRequests.test.ts (2 hunks)
  • test/unit/models/requests.test.ts (2 hunks)
  • test/unit/services/oooRequest.test.ts (5 hunks)
  • types/oooRequest.d.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
test/fixtures/oooRequest/oooRequest.ts (3)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
models/requests.ts (2)
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
test/unit/models/requests.test.ts (6)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
middlewares/validators/requests.ts (6)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
middlewares/validators/oooRequests.ts (6)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
test/unit/middlewares/oooRequests.test.ts (7)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/models/impersonationRequests.test.ts:13-13
Timestamp: 2025-06-19T16:38:41.156Z
Learning: When reviewing test PRs that depend on feature PRs, import errors may be temporary and expected until the feature PR is merged. Users may be updating type names or exports in the feature PR that the test PR depends on.
controllers/requests.ts (7)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2442
File: routes/impersonation.ts:15-15
Timestamp: 2025-06-18T10:01:24.320Z
Learning: In the Real-Dev-Squad/website-backend codebase, route modules use ES6 imports internally but export using CommonJS `module.exports` syntax because the routes/index.ts file uses require-based imports to load route modules.
controllers/oooRequests.ts (6)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
types/oooRequest.d.ts (5)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
services/oooRequest.ts (5)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
constants/requests.ts (5)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
test/integration/requests.test.ts (7)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/models/impersonationRequests.test.ts:13-13
Timestamp: 2025-06-19T16:38:41.156Z
Learning: When reviewing test PRs that depend on feature PRs, import errors may be temporary and expected until the feature PR is merged. Users may be updating type names or exports in the feature PR that the test PR depends on.
test/unit/services/oooRequest.test.ts (6)
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/fixtures/oooRequest/oooRequest.ts:59-60
Timestamp: 2025-03-16T05:23:33.460Z
Learning: The `createOooRequests2` object in test/fixtures/oooRequest/oooRequest.ts still uses the old property names `message` and `state` (instead of `reason` and `status`) because it's specifically used in acknowledging OOO request tests. This naming inconsistency will be fixed by surajmaity1 in a dedicated PR for acknowledging OOO requests.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2386
File: test/unit/services/oooRequest.test.ts:9-9
Timestamp: 2025-03-16T05:28:26.722Z
Learning: PRs #2383 and #2386 are related. PR #2383 implements the OOO request feature with the services/oooRequest.ts file, while PR #2386 adds tests for this feature. This creates a dependency where PR #2386 requires PR #2383 to be merged first.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2450
File: services/impersonationRequests.ts:11-11
Timestamp: 2025-06-26T20:08:47.146Z
Learning: In services/impersonationRequests.ts, the functions `updateImpersonationRequest` and `getImpersonationRequestById` are being imported from models/impersonationRequests but appear missing because they exist in previous PRs that need to be merged before this PR. This is expected behavior for dependent PRs and the build failures are temporary.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2443
File: test/unit/middlewares/impersonationRequests.test.ts:12-19
Timestamp: 2025-06-19T17:06:24.352Z
Learning: In test/unit/middlewares/impersonationRequests.test.ts, the developer uses `any` type for req and res mock objects to enable reusability across different middleware tests (get, update, create) in the same file, as strict typing causes test failures when different middleware functions expect different request/response shapes.
Learnt from: surajmaity1
PR: Real-Dev-Squad/website-backend#2383
File: types/userCurrentStatus.d.ts:3-9
Timestamp: 2025-03-09T06:30:20.120Z
Learning: The naming inconsistency between `message` in types/userCurrentStatus.d.ts and `reason` in OOO request models will be fixed by surajmaity1 in a future PR when modifying the user status route.
Learnt from: Suvidh-kaushik
PR: Real-Dev-Squad/website-backend#2446
File: services/impersonationRequests.ts:129-158
Timestamp: 2025-06-22T16:48:33.847Z
Learning: In services/impersonationRequests.ts, the updateImpersonationRequest model function can perform two types of updates: updating the status and updating the body. When updating the status, a type assertion `as UpdateImpersonationStatusModelResponse` is required to access the status property, as the function returns different types depending on the update operation being performed.
🧬 Code Graph Analysis (7)
models/requests.ts (1)
constants/requests.ts (2)
  • REQUEST_DOES_NOT_EXIST (47-47)
  • ERROR_WHILE_FETCHING_REQUEST (41-41)
test/unit/models/requests.test.ts (3)
models/requests.ts (1)
  • getRequestById (73-86)
test/fixtures/oooRequest/oooRequest.ts (1)
  • createOooRequests3 (162-169)
constants/requests.ts (1)
  • REQUEST_DOES_NOT_EXIST (47-47)
middlewares/validators/oooRequests.ts (4)
constants/requests.ts (2)
  • REQUEST_STATE (1-5)
  • REQUEST_TYPE (13-19)
controllers/oooRequests.ts (1)
  • acknowledgeOooRequest (164-198)
services/oooRequest.ts (1)
  • acknowledgeOooRequest (148-203)
types/oooRequest.d.ts (2)
  • AcknowledgeOooRequest (56-61)
  • OooRequestResponse (37-37)
controllers/requests.ts (5)
constants/requests.ts (1)
  • REQUEST_TYPE (13-19)
middlewares/validators/oooRequests.ts (1)
  • acknowledgeOooRequest (70-83)
controllers/oooRequests.ts (1)
  • acknowledgeOooRequest (164-198)
services/oooRequest.ts (1)
  • acknowledgeOooRequest (148-203)
types/oooRequest.d.ts (2)
  • AcknowledgeOooRequest (56-61)
  • OooRequestResponse (37-37)
controllers/oooRequests.ts (4)
middlewares/validators/oooRequests.ts (1)
  • acknowledgeOooRequest (70-83)
services/oooRequest.ts (1)
  • acknowledgeOooRequest (148-203)
types/oooRequest.d.ts (2)
  • AcknowledgeOooRequest (56-61)
  • OooRequestResponse (37-37)
constants/requests.ts (3)
  • UNAUTHORIZED_TO_UPDATE_REQUEST (74-74)
  • REQUEST_ID_REQUIRED (46-46)
  • ERROR_WHILE_ACKNOWLEDGING_REQUEST (44-44)
types/oooRequest.d.ts (2)
types/requests.d.ts (2)
  • RequestQuery (11-20)
  • RequestParams (22-24)
constants/requests.ts (2)
  • REQUEST_TYPE (13-19)
  • REQUEST_STATE (1-5)
test/integration/requests.test.ts (2)
test/fixtures/oooRequest/oooRequest.ts (1)
  • testAcknowledgeOooRequest (171-175)
constants/requests.ts (2)
  • UNAUTHORIZED_TO_UPDATE_REQUEST (74-74)
  • REQUEST_STATE (1-5)
🔇 Additional comments (24)
test/fixtures/oooRequest/oooRequest.ts (1)

171-171: LGTM: Clear naming improvement for test fixture.

Renaming acknowledgeOooRequest to testAcknowledgeOooRequest makes it clearer that this is a test fixture, improving code readability.

models/requests.ts (2)

11-11: LGTM: Proper import for HTTP error handling.

The NotFound import is correctly added to support the new getRequestById function.


73-86: LGTM: Well-implemented function with proper error handling.

The getRequestById function follows good practices:

  • Clear and simple function signature
  • Proper error handling with try-catch
  • Throws specific HTTP NotFound error when document doesn't exist
  • Appropriate error logging with descriptive messages
  • Rethrows errors to maintain error propagation
test/unit/models/requests.test.ts (2)

3-3: LGTM: Proper imports for new test functionality.

The imports correctly include the new getRequestById function, test fixture createOooRequests3, and the REQUEST_DOES_NOT_EXIST constant needed for the tests.

Also applies to: 7-7, 12-12


184-198: LGTM: Comprehensive test coverage for getRequestById.

The test suite properly covers both success and failure scenarios:

  • Successfully retrieves request data and validates it matches the expected fixture
  • Properly tests error handling for non-existent requests with correct error message
  • Uses appropriate assertions (deep.include and error message validation)
  • Follows established testing patterns in the file
controllers/requests.ts (2)

8-9: LGTM: Proper imports for OOO acknowledge functionality.

The imports correctly include the new acknowledgeOooRequest controller function, its types, and the NextFunction type needed for the updated function signature.

Also applies to: 19-19


123-129: LGTM: Proper integration of OOO acknowledgment flow.

The function signature correctly includes the NextFunction parameter, and the new case for REQUEST_TYPE.OOO properly delegates to the acknowledgeOooRequest controller with all required parameters. This maintains consistency with the existing controller pattern.

test/integration/requests.test.ts (4)

18-18: LGTM: Consistent fixture import update.

The import correctly uses the renamed testAcknowledgeOooRequest fixture, maintaining consistency with the changes in the test fixtures file.


326-326: LGTM: Enabling important integration tests.

The previously skipped test suite for PATCH /requests/:id is now enabled, providing essential integration test coverage for the OOO request acknowledgment functionality.


33-33: LGTM: Consistent authorization error constant usage.

The update from the commented-out UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST to UNAUTHORIZED_TO_UPDATE_REQUEST aligns with the actual error constants used in the implementation, ensuring test assertions match the expected behavior.

Also applies to: 407-407


355-355: LGTM: Consistent test fixture usage throughout.

All references to the test payload have been consistently updated to use testAcknowledgeOooRequest, maintaining uniformity across all test cases and ensuring the tests use the correct fixture data.

Also applies to: 369-369, 385-385, 401-401, 417-417, 433-433, 449-449, 465-465, 481-481, 498-498

middlewares/validators/oooRequests.ts (2)

4-4: LGTM: Import statement updated correctly.

The addition of AcknowledgeOooRequest type import aligns with the new acknowledge OOO request functionality.


42-60: LGTM: Joi schema correctly validates acknowledge OOO request payload.

The schema properly validates:

  • comment as optional string with empty string validation
  • status restricted to APPROVED/REJECTED with clear error message
  • type must equal OOO with validation

The validation rules align with the acknowledge OOO request requirements.

middlewares/validators/requests.ts (2)

4-5: LGTM: Import statements correctly updated.

The imports properly include the new AcknowledgeOooRequest type and acknowledgeOooRequest validator function needed for the OOO acknowledge functionality.


128-154: LGTM: updateRequestValidator correctly integrates OOO acknowledge validation.

The function signature update to include AcknowledgeOooRequest and the new case for REQUEST_TYPE.OOO properly integrate the acknowledge OOO request validation into the existing request validation flow. The implementation follows the established pattern used for other request types.

test/unit/middlewares/oooRequests.test.ts (2)

7-9: LGTM: Import statements updated to use active validator and test data.

The imports correctly reference the implemented acknowledgeOooRequest validator function and updated test data naming convention.


94-130: LGTM: Test suite properly activated and updated.

The test suite for acknowledgeOooRequestsValidator is now enabled and all test cases properly:

  • Test invalid request type validation
  • Test invalid status validation
  • Test optional comment handling
  • Test valid acknowledge requests
  • Use the correct validator function and test data references

The test coverage adequately validates the middleware behavior.

controllers/oooRequests.ts (1)

15-17: LGTM: Import statements properly updated for acknowledge functionality.

The new imports for constants, service functions, types, and NextFunction are correctly added to support the acknowledge OOO request feature.

Also applies to: 26-26, 28-28, 30-30

constants/requests.ts (3)

29-30: LGTM: New log types for already approved/rejected requests.

The addition of REQUEST_ALREADY_APPROVED and REQUEST_ALREADY_REJECTED log types follows the existing naming convention and supports the acknowledge OOO request validation flow.


44-44: LGTM: Error message constant for acknowledge functionality.

The ERROR_WHILE_ACKNOWLEDGING_REQUEST constant provides appropriate error messaging for the new acknowledge OOO request feature.


46-46: LGTM: Validation message for required request ID.

The REQUEST_ID_REQUIRED constant provides clear validation messaging when request ID is missing, supporting the acknowledge functionality validation.

services/oooRequest.ts (2)

107-203: Well-implemented acknowledgment flow

The new functions properly implement the OOO request acknowledgment flow with:

  • Clear separation between validation and business logic
  • Comprehensive error handling for all edge cases
  • Proper logging of all actions
  • Correct status transitions

182-190: Verify naming consistency for addFutureStatus payload

I wasn’t able to locate the addFutureStatus definition in the models/userStatus module to confirm whether it expects a message or reason field. Please double-check the function signature and update the call below if it should use reason instead of message:

• services/oooRequest.ts:182

await addFutureStatus({
  requestId,
  state: REQUEST_TYPE.OOO,
  from: requestData.from,
  endsOn: requestData.until,
  userId: requestData.userId,
  message: body.comment,  // ← verify if this should be `reason`
});
test/unit/services/oooRequest.test.ts (1)

117-264: Comprehensive test coverage for acknowledgment functionality

Excellent test implementation that covers:

  • All validation scenarios (invalid type, already approved/rejected)
  • Success cases for both approval and rejection
  • Error handling for various failure modes
  • Proper stubbing and isolation of dependencies

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Readability Inconsistent Validation Error Key ▹ view
Design Inconsistent Module Import Pattern ▹ view
Files scanned
File Path Reviewed
types/oooRequest.d.ts
middlewares/validators/oooRequests.ts
constants/requests.ts
models/requests.ts
controllers/requests.ts
middlewares/validators/requests.ts
controllers/oooRequests.ts
services/oooRequest.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

@tejaskh3 tejaskh3 force-pushed the tejas/ooo-approve-reject-final branch from fec48b1 to 83d07c7 Compare July 19, 2025 16:13

const requestResult = await updateRequest(requestId, body, superUserId, REQUEST_TYPE.OOO);

if ("error" in requestResult) {
Copy link
Member

Choose a reason for hiding this comment

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

why are we doing this ?

userId: requestData.userId,
message: body.comment,
createdAt: Date.now()
});
Copy link
Member

Choose a reason for hiding this comment

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

what does both function do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants