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): Unserviced tag for indictment cases #17352

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

unakb
Copy link
Member

@unakb unakb commented Dec 23, 2024

Sjá stöðu/tagg á málalista hvort búið er að birta eða ekki

What

Added a new tag "Óbirt" to be displayed on certain case lists for indictment cases.

Why

So that users can easily see whether an indictment case has been serviced when looking over their case list page.

Screenshots / Gifs

image

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

    • Enhanced case listings to include subpoena information for each defendant.
    • Introduced a new case state "Óbirt" indicating cases not yet serviced.
    • Updated components to support additional props for better case state representation.
  • Bug Fixes

    • Improved logic for determining if all subpoenas have been serviced, affecting tag variants in case states.
  • Documentation

    • Updated GraphQL queries to include new fields for subpoena-related information within defendants.
  • Chores

    • Refactored components to integrate new data structures without altering existing functionality.

Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

Walkthrough

This pull request introduces enhancements to the judicial system's backend and web components, focusing on subpoena and case state management. The changes primarily involve updating data retrieval mechanisms, improving case state representation, and adding more detailed information about subpoenas and defendants across multiple files. The modifications aim to provide more comprehensive and context-aware case information throughout the application.

Changes

File Path Change Summary
apps/judicial-system/backend/src/app/modules/case/case.service.ts Added Subpoena model to caseListInclude with specific configuration for retrieving subpoena data
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts Added new message entry for notYetServiced case state
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx Updated component to include haveAllSubpoenasBeenServiced function and modified props to support defendants
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx Updated imports and component to pass additional case type and defendants information
apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql Added subpoenas field to defendants object in GraphQL query
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql Added subpoenas field to defendants object in GraphQL query
Multiple web route files Added Defendant type import and passed defendants prop to TagCaseState component

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • oddsson

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>, please review it.
    • 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 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 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 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. (Beta)
  • @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.

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 December 23, 2024 15:04
@unakb unakb requested a review from a team as a code owner December 23, 2024 15:04
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

🧹 Nitpick comments (2)
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1)

12-12: Consider importing only needed components.

Although this import is valid, you could import only the components used in the file to keep the overall bundle size smaller.

apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)

33-37: Consider adding field descriptions.

To improve maintainability, consider adding GraphQL descriptions for the new fields to document their purpose and possible values (especially for the serviceStatus field).

 subpoenas {
+  """
+  Unique identifier for the subpoena record
+  """
   id
+  """
+  Current service status of the subpoena
+  """
   serviceStatus
+  """
+  Reference to the original subpoena
+  """
   subpoenaId
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56493cc and d97d7ab.

📒 Files selected for processing (9)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
  • apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts (1 hunks)
  • apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (7 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (2 hunks)
  • apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (2 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (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/web/src/components/TagCaseState/TagCaseState.strings.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/web/src/routes/Shared/Cases/ActiveCases.tsx (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/web/src/routes/Shared/Cases/cases.graphql (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/web/src/routes/Shared/Cases/MobileCase.tsx (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."
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (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/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (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/web/src/components/TagCaseState/TagCaseState.tsx (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."
📓 Learnings (7)
apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (4)
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:126-131
Timestamp: 2024-11-19T21:47:09.093Z
Learning: The `CaseListEntry` interface in `@island.is/judicial-system-web/src/graphql/schema` includes the properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision`.
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:136-139
Timestamp: 2024-11-20T10:15:04.980Z
Learning: The properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision` are defined in the `CaseListEntry` interface used in the `PastCasesTable` component.
Learnt from: thorhildurt
PR: island-is/island.is#17285
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:223-225
Timestamp: 2024-12-18T17:15:59.181Z
Learning: The system currently only allows adding one defendant, so the punishment type logic in the table can default to the first defendant, with a plan to support multiple defendants in the future.
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx (1)
Learnt from: thorhildurt
PR: island-is/island.is#17285
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:223-225
Timestamp: 2024-12-18T17:15:59.181Z
Learning: The system currently only allows adding one defendant, so the punishment type logic in the table can default to the first defendant, with a plan to support multiple defendants in the future.
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-11-12T15:15:11.835Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (1)
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:126-131
Timestamp: 2024-11-19T21:47:09.093Z
Learning: The `CaseListEntry` interface in `@island.is/judicial-system-web/src/graphql/schema` includes the properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision`.
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
🔇 Additional comments (21)
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts (1)

86-90: Additions look good!
The new "Óbirt" tag entry is consistent with the existing map of case states. No issues found.

apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx (1)

89-89: Ensure defendants data validity
Passing "defendants" to TagCaseState is a solid extension. However, consider verifying that "theCase.defendants" is not null or undefined to avoid potential rendering errors.

apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (2)

20-23: Imports are correct
The addition of "Defendant" import is consistent with the usage in this file.


111-111: Prop usage is consistent
Providing "defendants" to TagCaseState aligns with the updated component signature.

apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (9)

8-8: Helper import alignment
"isSuccessfulServiceStatus" is a well-named helper that correctly conveys its purpose.


14-14: Defendant type import
The "Defendant" type import from graphQL schema looks correct and is used properly.


35-36: Optional defendants property
Marking "defendants" as optional helps avoid null reference issues if no defendants exist.


38-50: Good approach to check all subpoena statuses
The function "haveAllSubpoenasBeenServiced" correctly determines if each defendant has at least one successfully serviced subpoena. The logic is solid, and the naming is intuitive.


80-80: Extended mapCaseStateToTagVariant signature
Introducing "defendants" as a parameter broadens the contextual logic for tag display without breaking existing usage.


92-100: Óbirt (Unserviced) case state condition
Adding a condition for indictment cases with a scheduled date but unserviced subpoenas is appropriate. This ensures "Óbirt" is highlighted when needed, enhancing user clarity.


118-118: CaseState.ACCEPTED logic
The combined condition for indictment vs. investigation cases is consistent with existing logic.


160-160: Prop extraction
Destructuring "defendants" from props fosters readability.


174-174: Defendant data usage
Passing "defendants" to "mapCaseStateToTagVariant" is necessary for handling the new "Óbirt" scenario. This flow is coherent.

apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (4)

39-39: Import for Defendant looks good.

This import correctly aligns with the usage of defendant types in the file.


160-160: Prop caseType ensures consistent display logic.

Passing caseType to the TagCaseState component will help maintain correct labeling and styling for each case state.


164-164: Defendants prop enhances context for TagCaseState.

Providing the defendants array supports logic for displaying un/serviced statuses and ensures the UI has sufficient data to reflect indictment states.


14-14: Validate usage of isSuccessfulServiceStatus.

Please ensure that the function imported from @island.is/judicial-system/types is actually used or intended for future use.

apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (1)

28-31: Added import of Defendant type.

Importing Defendant alongside CaseListEntry is appropriate as you are now passing the defendants array into TagCaseState.

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

429-435: Subpoena retrieval in caseListInclude for defendants.

Including the Subpoena model within defendants allows the UI to display subpoena servicing statuses. This addition seems correctly structured.

apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)

26-30: New subpoenas field in defendants.

Extending the query to fetch subpoenas ensures defender views and other UI components can accurately display the subpoena status of each defendant.

apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)

33-37: LGTM! The subpoenas field structure aligns with requirements.

The new subpoenas field in the defendants object provides the necessary data structure to support the "Unserviced" tag feature. The inclusion of serviceStatus will enable proper tracking of subpoena service state.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 35.68%. Comparing base (2699012) to head (d06f326).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...m/web/src/components/TagCaseState/TagCaseState.tsx 37.50% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17352      +/-   ##
==========================================
- Coverage   35.68%   35.68%   -0.01%     
==========================================
  Files        6931     6931              
  Lines      148782   148791       +9     
  Branches    42509    42511       +2     
==========================================
+ Hits        53091    53092       +1     
- Misses      95691    95699       +8     
Flag Coverage Δ
air-discount-scheme-backend 48.24% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.99% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <ø> (ø)
api-domains-criminal-record 48.03% <ø> (ø)
api-domains-driving-license 44.86% <ø> (ø)
api-domains-education 31.27% <ø> (ø)
api-domains-health-insurance 35.47% <ø> (ø)
api-domains-mortgage-certificate 35.24% <ø> (+0.10%) ⬆️
api-domains-payment-schedule 42.12% <ø> (ø)
application-api-files 61.90% <ø> (ø)
application-core 75.72% <ø> (ø)
application-system-api 38.72% <ø> (-0.01%) ⬇️
application-template-api-modules 27.67% <ø> (-0.02%) ⬇️
application-templates-accident-notification 27.61% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.83% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.66% <ø> (ø)
application-templates-example-payment 24.69% <ø> (ø)
application-templates-financial-aid 14.45% <ø> (ø)
application-templates-general-petition 23.12% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.18% <ø> (ø)
application-templates-mortgage-certificate 43.68% <ø> (ø)
application-templates-parental-leave 29.95% <ø> (ø)
application-types 6.51% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
application-ui-shell 22.26% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.52% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.91% <ø> (ø)
clients-driving-license-book 43.92% <ø> (ø)
clients-financial-statements-inao 49.70% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 73.18% <ø> (+0.24%) ⬆️
clients-regulations 43.00% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.47% <ø> (ø)
clients-zendesk 50.58% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.75% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 4.71% <ø> (ø)
dokobit-signing 62.18% <ø> (ø)
email-service 60.15% <ø> (ø)
file-storage 45.97% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.33% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.42% <ø> (ø)
judicial-system-api 20.20% <ø> (ø)
judicial-system-audit-trail 69.02% <ø> (ø)
judicial-system-backend 55.98% <ø> (ø)
judicial-system-message 66.60% <ø> (ø)
judicial-system-message-handler 48.33% <ø> (ø)
judicial-system-scheduler 71.15% <ø> (ø)
judicial-system-web 27.73% <37.50%> (+<0.01%) ⬆️
license-api 42.94% <ø> (+0.07%) ⬆️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.05% <ø> (ø)
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.45% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 51.06% <ø> (ø)
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.52% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.58% <ø> (ø)
services-auth-admin-api 52.54% <ø> (+0.01%) ⬆️
services-auth-delegation-api 58.46% <ø> (-0.09%) ⬇️
services-auth-ids-api 52.55% <ø> (-0.01%) ⬇️
services-auth-public-api 49.42% <ø> (ø)
services-sessions 65.36% <ø> (+0.04%) ⬆️
services-university-gateway 49.43% <ø> (-0.09%) ⬇️
services-user-notification 46.54% <ø> (ø)
services-user-profile 56.97% <ø> (+0.08%) ⬆️
shared-components 29.49% <ø> (ø)
shared-form-fields 33.38% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.26% <ø> (ø)
web 2.40% <ø> (ø)

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

Files with missing lines Coverage Δ
...ystem/backend/src/app/modules/case/case.service.ts 89.51% <ø> (ø)
...rc/components/TagCaseState/TagCaseState.strings.ts 100.00% <ø> (ø)
...ents/CasesInProgressTable/CasesInProgressTable.tsx 56.86% <ø> (ø)
...s/Defender/Cases/components/DefenderCasesTable.tsx 0.00% <ø> (ø)
...system/web/src/routes/Shared/Cases/ActiveCases.tsx 84.21% <ø> (ø)
...-system/web/src/routes/Shared/Cases/MobileCase.tsx 9.52% <ø> (ø)
...m/web/src/components/TagCaseState/TagCaseState.tsx 77.41% <37.50%> (-6.22%) ⬇️

... and 1 file with indirect coverage changes


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 56493cc...d06f326. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 23, 2024

Datadog Report

All test runs 3fbb0d1 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 2 decreased, 2 increased, 196 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
air-discount-scheme-backend 0 0 0 63 0 21.99s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.56s N/A Link
api 0 0 0 4 0 2.41s N/A Link
api-catalogue-services 0 0 0 23 0 8.93s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.16s N/A Link
api-domains-assets 0 0 0 3 0 11.93s N/A Link
api-domains-auth-admin 0 0 0 18 0 12.83s N/A Link
api-domains-communications 0 0 0 5 0 31.74s N/A Link
api-domains-criminal-record 0 0 0 5 0 8.32s N/A Link
api-domains-driving-license 0 0 0 23 0 26.99s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 50.45% (-0.03%) - Details
  • services-university-gateway - jest 45.26% (-0.02%) - Details

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

🧹 Nitpick comments (2)
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (2)

38-44: Consider renaming function for clarity

The function name haveAllSubpoenasBeenServiced implies that all subpoenas must be serviced, but the actual logic checks if each defendant has at least one serviced subpoena. Consider renaming to hasEachDefendantAtLeastOneServicedSubpoena for better clarity.

-const haveAllSubpoenasBeenServiced = (defendants: Defendant[]): boolean => {
+const hasEachDefendantAtLeastOneServicedSubpoena = (defendants: Defendant[]): boolean => {
   return defendants.every((defendant) => {
-    // if at least one subpoena for each defendant was serviced, we return true
+    // Returns true if the defendant has at least one successfully serviced subpoena
     return defendant.subpoenas?.some((subpoena) =>
       isSuccessfulServiceStatus(subpoena.serviceStatus),
     )
   })
}

86-94: Consider simplifying nested conditions

The nested conditions could be simplified using early returns or combining conditions for better readability.

     case CaseState.RECEIVED: {
-      if (isIndictmentCase(caseType) && defendants) {
-        if (scheduledDate && !haveAllSubpoenasBeenServiced(defendants)) {
-          return {
-            color: 'red',
-            text: formatMessage(strings.notYetServiced),
-          }
-        }
+      if (
+        isIndictmentCase(caseType) &&
+        defendants?.length &&
+        scheduledDate &&
+        !hasEachDefendantAtLeastOneServicedSubpoena(defendants)
+      ) {
+        return {
+          color: 'red',
+          text: formatMessage(strings.notYetServiced),
+        }
       }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d97d7ab and d06f326.

📒 Files selected for processing (2)
  • apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (7 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (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 (3)
apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx (3)

8-8: LGTM: Type definitions and imports are well-structured

The new imports and interface changes are properly typed and follow TypeScript best practices with optional chaining support.

Also applies to: 14-14, 35-36


154-154: LGTM: Component changes are consistent

The new defendants prop is properly integrated into the component, maintaining consistency with the existing pattern.

Also applies to: 168-168


38-44: Verify handling of edge cases

Please ensure the code handles these edge cases correctly:

  1. Empty defendants array
  2. Null subpoenas array
  3. Missing serviceStatus

Also applies to: 86-94

✅ Verification successful

Edge cases are properly handled in the implementation

The code safely handles all the mentioned edge cases:

  1. Empty defendants array: The every() method returns true for empty arrays by design, which is the correct behavior as there are no defendants to check.

  2. Null subpoenas array: The optional chaining operator (?.) in defendant.subpoenas?.some() safely handles null/undefined subpoenas array by returning undefined, which gets coerced to false in the boolean context.

  3. Missing serviceStatus: The isSuccessfulServiceStatus function (from @island.is/judicial-system/types) handles undefined/null serviceStatus values, as seen in its implementation which uses a boolean check: Boolean(status && successfulServiceStatus.includes(status)).

The implementation also correctly uses TypeScript's type system with proper null checks and optional chaining, making it type-safe and runtime-safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for test coverage of edge cases in the component tests

# Look for test files
fd "TagCaseState.test" --type f

# Search for test cases handling edge scenarios
rg -A 5 "describe|it|test" --glob "*TagCaseState.test*"

Length of output: 238


Script:

#!/bin/bash
# Let's try a broader search for test files and implementation
# First, find the exact path of the component
fd "TagCaseState" --type f

# Then search for test patterns in the implementation
rg "haveAllSubpoenasBeenServiced" -A 5 -B 5

# Look for type definitions to understand the data structure
rg "interface.*Defendant" -A 5
rg "interface.*Subpoena" -A 5

Length of output: 6572


Script:

#!/bin/bash
# Let's check the test file we found and implementation of isSuccessfulServiceStatus
cat "apps/judicial-system/web/src/components/TagCaseState/TagCaseState.spec.ts"

# Look for the implementation of isSuccessfulServiceStatus
rg "isSuccessfulServiceStatus" -A 5 -B 5

# Check ServiceStatus type definition
rg "type.*ServiceStatus|enum.*ServiceStatus" -A 10

Length of output: 29324

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.

1 participant