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(j-s): Deliver assigned court roles for indictments to court #15205

Merged
merged 10 commits into from
Jun 18, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Jun 12, 2024

Roboti - ákærur - úthlutun

What

Robot notification sent when an indictment case is assigned to a judge or registrar

Checklist:

  • I have performed a self-review of my own code
  • 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
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a new method to deliver assigned roles in indictment cases to the court.
    • Added logic to send messages for court role assignments in indictment cases.
  • Tests

    • Added tests to verify the delivery of assigned roles for indictment cases to the court.
    • Implemented tests for guards ensuring proper role assignment delivery in indictment cases.
  • Enhancements

    • Updated message library to support new message type for delivering court roles in indictment cases.

@unakb unakb changed the title J s/deliver indictment assigned roles feat(j-s): Deliver assigned court roles for indictmets to court Jun 12, 2024
@unakb unakb changed the title feat(j-s): Deliver assigned court roles for indictmets to court feat(j-s): Deliver assigned court roles for indictments to court Jun 12, 2024
Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

Walkthrough

The recent changes introduce the ability for the judicial system to handle the delivery of assigned roles in indictment cases to the court. This includes adding new methods for handling role assignments, updating indictment cases with these roles, and verifying these functionalities through new test cases. The changes also encompass additions to message types and endpoints to facilitate these features.

Changes

File Path Change Summary
apps/judicial-system/backend/src/app/modules/case/case.service.ts Added a private method to send messages for indictment court role assignment and logic to trigger it.
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts Added a new method to handle delivering assigned roles in an indictment case to court.
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts Introduced a method for assigning roles for judges and registrars in a case and updating indictment cases with these roles.
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictment...ts Introduced a test for delivering assigned roles for an indictment case to court, including mocks and verification steps.
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictment...ts Added a test verifying the guards for the new method in InternalCaseController.
apps/judicial-system/backend/src/app/modules/court/court.service.ts Updated to include UserRole, added INDICTMENT_CASE_ASSIGNED_ROLES in RobotEmailType, and introduced a method to update indictment cases.
libs/judicial-system/message/src/lib/message.ts Added a new message type and endpoint for delivering court roles related to an indictment.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@unakb unakb marked this pull request as ready for review June 12, 2024 15:18
@unakb unakb requested a review from a team as a code owner June 12, 2024 15:18
Copy link
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e7b9c5a and 7f6af3d.

Files selected for processing (7)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourt.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/court/court.service.ts (3 hunks)
  • libs/judicial-system/message/src/lib/message.ts (2 hunks)
Additional context used
Path-based instructions (7)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourt.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/judicial-system/message/src/lib/message.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/court/court.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (5)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.spec.ts (1)

9-50: The test suite for the guards on the deliverIndictmentAssignedRoleToCourt method is well-structured and covers the necessary guards (CaseExistsGuard and CaseTypeGuard). The tests ensure that both guards are applied correctly, which is crucial for the security and correctness of the endpoint.

apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourt.spec.ts (1)

22-85: The test setup and execution in deliverIndictmentAssignedRolesToCourt.spec.ts are comprehensive and well-structured. The use of mock services and the detailed assertions ensure that the functionality is thoroughly tested. However, ensure that the mockUpdateIndictmentCaseWithAssignedRoles mock is correctly reset or cleared between tests to avoid potential side effects impacting other tests.

#!/bin/bash
# Description: Verify that the mock is reset or cleared between tests.

# Test: Search for mock reset or clear commands. Expect: At least one occurrence.
rg --type typescript $'mockUpdateIndictmentCaseWithAssignedRoles.mockReset()|mockUpdateIndictmentCaseWithAssignedRoles.mockClear()' apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourt.spec.ts
libs/judicial-system/message/src/lib/message.ts (1)

8-8: The additions to the MessageType enum and the messageEndpoint constant in message.ts are correctly implemented. These changes are essential for supporting the new functionality of delivering assigned roles in indictment cases to the court. Ensure that these new message types are integrated into the system's message handling logic where appropriate.

#!/bin/bash
# Description: Verify integration of new message types into the system's message handling logic.

# Test: Search for usage of new message types. Expect: At least one occurrence.
rg --type typescript $'DELIVERY_TO_COURT_INDICTMENT_COURT_ROLES' libs/judicial-system/message/src/lib/message.ts

Also applies to: 36-37

apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts (1)

197-222: The implementation of the deliverIndictmentAssignedRoleToCourt method in internalCase.controller.ts is robust, with appropriate guards ensuring that only valid and authorized requests are processed. The method's logging and error handling appear to be well-implemented. However, ensure that the CaseTypeGuard is correctly configured to allow only indictment cases, as this is critical for maintaining the integrity of the operation.

#!/bin/bash
# Description: Verify the configuration of `CaseTypeGuard` for the `deliverIndictmentAssignedRoleToCourt` method.

# Test: Search for the configuration of `CaseTypeGuard`. Expect: Specific configuration for indictment cases.
rg --type typescript $'new CaseTypeGuard(indictmentCases)' apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts
apps/judicial-system/backend/src/app/modules/court/court.service.ts (1)

15-15: The addition of UserRole in the import statement is appropriate for its usage in the new method related to handling roles in indictment cases.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 53.65854% with 19 lines in your changes missing coverage. Please review.

Project coverage is 37.12%. Comparing base (17a146e) to head (e8b7876).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #15205   +/-   ##
=======================================
  Coverage   37.11%   37.12%           
=======================================
  Files        6448     6448           
  Lines      131413   131454   +41     
  Branches    37569    37588   +19     
=======================================
+ Hits        48774    48796   +22     
- Misses      82639    82658   +19     
Flag Coverage Δ
api 3.51% <ø> (ø)
api-catalogue-services 77.85% <ø> (ø)
api-domains-mortgage-certificate 34.87% <ø> (+0.06%) ⬆️
application-template-api-modules 24.40% <ø> (+0.01%) ⬆️
application-templates-accident-notification 19.92% <ø> (ø)
judicial-system-backend 55.78% <53.65%> (-0.01%) ⬇️
judicial-system-formatters 81.40% <ø> (ø)
judicial-system-message 65.99% <100.00%> (+0.06%) ⬆️
judicial-system-message-handler 66.42% <100.00%> (+0.03%) ⬆️
judicial-system-scheduler 57.71% <ø> (ø)
judicial-system-types 49.06% <ø> (ø)
message-queue 68.39% <ø> (ø)
nest-problem 46.08% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
portals-admin-regulations-admin 2.04% <ø> (ø)
portals-core 16.29% <ø> (ø)
reference-backend 50.31% <ø> (ø)
services-documents 60.81% <ø> (ø)
services-endorsements-api 55.11% <ø> (+0.02%) ⬆️
shared-components 27.92% <ø> (ø)
shared-form-fields 31.92% <ø> (ø)
shared-mocking 64.62% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...nd/src/app/modules/case/internalCase.controller.ts 97.59% <100.00%> (+0.10%) ⬆️
libs/judicial-system/message/src/lib/message.ts 100.00% <100.00%> (ø)
...ystem/backend/src/app/modules/case/case.service.ts 92.57% <58.33%> (-0.87%) ⬇️
...ckend/src/app/modules/case/internalCase.service.ts 84.77% <46.15%> (-1.32%) ⬇️
...tem/backend/src/app/modules/court/court.service.ts 39.25% <12.50%> (-1.04%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17a146e...e8b7876. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 12, 2024

Datadog Report

All test runs 316f680 🔗

100 Total Test Services: 1 Failed, 97 Passed
🔻 Test Sessions change in coverage: 2 decreased, 6 increased, 192 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
services-auth-admin-api 1 0 0 105 0 3m 16.26s 1 no change Link
air-discount-scheme-backend 0 0 0 81 0 31.09s N/A Link
air-discount-scheme-web 0 0 0 2 0 8.76s N/A Link
api 0 0 0 4 0 4.05s N/A Link
api-catalogue-services 0 0 0 23 0 15.65s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 33.89s N/A Link
api-domains-assets 0 0 0 3 0 22.4s N/A Link
api-domains-auth-admin 0 0 0 18 0 11.13s N/A Link
api-domains-communications 0 0 0 5 0 39.27s N/A Link
api-domains-criminal-record 0 0 0 5 0 15.53s N/A Link

❌ Failed Tests (1)

  • ProverController getDelegationProviders should return all delegation providers and their delegation types - apps/services/auth/admin-api/src/app/v2/providers/test/provider-controller.spec.ts - Details

    Expand for error
     expect(received).toBe(expected) // Object.is equality
     
     Expected: 2
     Received: 1
    

🔻 Code Coverage Decreases vs Default Branch (2)

  • application-templates-parental-leave - jest 33.21% (-0.1%) - Details
  • judicial-system-backend - jest 59.3% (-0.01%) - Details

Copy link
Member

@gudjong gudjong left a comment

Choose a reason for hiding this comment

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

One comment

Copy link
Contributor

@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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7f6af3d and a68f883.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.spec.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.spec.ts

Copy link
Contributor

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a68f883 and cc09370.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts

[error] 141-141: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 142-142: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 143-143: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 145-145: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 147-147: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 149-149: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 151-151: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 153-153: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 155-155: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 157-157: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 159-159: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 161-161: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 163-163: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 165-165: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 167-167: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 169-169: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 885-885: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 867-867: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Jun 18, 2024
@kodiakhq kodiakhq bot merged commit ec6c19e into main Jun 18, 2024
241 checks passed
@kodiakhq kodiakhq bot deleted the j-s/deliver-indictment-assigned-roles branch June 18, 2024 16:06
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants