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

fix(j-s): Display correct verdict appeal info for defenders #16533

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

Conversation

unakb
Copy link
Member

@unakb unakb commented Oct 23, 2024

Ef ekki þarf að birta dóm á að standa birting dóms ekki þörf á info cardi hjá verjanda.

What

  • Move verdict appeal expiry calculation from front end to API transformer
  • Display correct verdict appeal information on info card for defenders

Why

  • They weren't getting the correct text in some cases

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

    • Added a new field isVerdictAppealDeadlineExpired to provide information on the status of verdict appeal deadlines for defendants.
    • Enhanced GraphQL queries to include additional fields related to indictment cases and defendants.
    • Introduced new transformation functions to better handle case types and improve data processing.
  • Bug Fixes

    • Simplified logic in the getAppealExpirationInfo function to improve clarity and efficiency.
  • Documentation

    • Updated test descriptions to better reflect changes in functionality and expected outputs.

@unakb unakb requested a review from a team as a code owner October 23, 2024 13:01
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The pull request introduces changes to the judicial system API and GraphQL queries, primarily focusing on renaming the function getDefendantsInfo to getIndictmentDefendantsInfo and enhancing its functionality to include a new property for tracking the verdict appeal deadline status. Additional fields related to defendants and their appeal statuses are added to the GraphQL schema. The transformation logic for limited access cases is updated, and the DefendantInfo component is modified to simplify the generation of appeal expiration messages.

Changes

File Change Summary
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts - Renamed method: getDefendantsInfogetIndictmentDefendantsInfo
- Added new variable isVerdictAppealDeadlineExpired to track appeal deadline status.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts - Updated tests for getIndictmentDefendantsInfo to reflect new naming and added expected output for isVerdictAppealDeadlineExpired.
apps/judicial-system/api/src/app/modules/case/interceptors/limitedAccessCase.transformer.ts - Added import isRequestCase
- Updated transformLimitedAccessCase to include case type checks and delegate to transformRequestCase.
- Added transformIndictmentCase.
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts - Added field: readonly isVerdictAppealDeadlineExpired?: boolean to the Defendant class.
apps/judicial-system/web/src/components/FormProvider/case.graphql - Added field: isVerdictAppealDeadlineExpired to the defendants object in the Case query.
apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql - Added fields: serviceRequirement, isVerdictAppealDeadlineExpired, indictmentVerdictViewedByAll, and indictmentVerdictAppealDeadlineExpired to the LimitedAccessCase query.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx - Updated getAppealExpirationInfo function to use isVerdictAppealDeadlineExpired parameter instead of date comparison.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts - Updated tests for getAppealExpirationInfo to include the new isVerdictAppealDeadlineExpired parameter and cover various scenarios.

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

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: 3

🧹 Outside diff range and nitpick comments (3)
apps/judicial-system/api/src/app/modules/case/interceptors/limitedAccessCase.transformer.ts (1)

47-54: Consider adding explicit return type for improved type safety

The implementation correctly handles the conditional exposure of case information based on defender permissions.

Consider adding an explicit return type for better type safety:

-const transformRequestCase = (theCase: Case): Case => {
+const transformRequestCase = (theCase: Case): Readonly<Case> => {
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1)

75-77: Add JSDoc documentation for the new field.

The implementation looks good and aligns with the PR objective of moving verdict appeal expiry calculation to the API. However, consider adding JSDoc documentation to explain the field's purpose and when it might be null.

+  /**
+   * Indicates whether the verdict appeal deadline has expired.
+   * Null when verdict hasn't been viewed or appeal deadline hasn't been set.
+   */
   @Field(() => Boolean, { nullable: true })
   readonly isVerdictAppealDeadlineExpired?: boolean
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (1)

688-709: Consider adding test cases for edge scenarios.

The test suite effectively covers the basic scenarios for verdict appeal deadline handling. However, consider adding test cases for:

  • Invalid verdict view dates
  • Empty defendants array
  • Null/undefined defendants
  • Edge cases around the deadline calculation (e.g., date rollovers)

Example test cases:

it('should handle invalid verdict view dates gracefully', () => {
  const defendants = [
    { verdictViewDate: 'invalid-date' } as Defendant,
  ]
  const defendantsInfo = getIndictmentDefendantsInfo(defendants)
  expect(defendantsInfo[0].verdictAppealDeadline).toBeUndefined()
})

it('should handle empty defendants array', () => {
  const defendants: Defendant[] = []
  const defendantsInfo = getIndictmentDefendantsInfo(defendants)
  expect(defendantsInfo).toEqual([])
})

it('should handle null/undefined defendants', () => {
  const defendants = [null, undefined] as unknown as Defendant[]
  const defendantsInfo = getIndictmentDefendantsInfo(defendants)
  expect(defendantsInfo).toEqual([{}, {}])
})
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3547589 and c45a61e.

📒 Files selected for processing (7)
  • apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/case/interceptors/limitedAccessCase.transformer.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (2 hunks)
  • apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.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/api/src/app/modules/case/interceptors/case.transformer.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/api/src/app/modules/case/interceptors/limitedAccessCase.transformer.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/api/src/app/modules/defendant/models/defendant.model.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/components/FormProvider/case.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/FormProvider/limitedAccessCase.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/InfoCard/DefendantInfo/DefendantInfo.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 (1)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (4)
Learnt from: unakb
PR: island-is/island.is#14922
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
Learnt from: oddsson
PR: island-is/island.is#15461
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:36-62
Timestamp: 2024-07-08T13:30:58.001Z
Learning: The user prefers readability over optimization in the `getAppealExpirationInfo` function within `DefendantInfo.tsx`.
Learnt from: oddsson
PR: island-is/island.is#15461
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:36-62
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The user prefers readability over optimization in the `getAppealExpirationInfo` function within `DefendantInfo.tsx`.
Learnt from: unakb
PR: island-is/island.is#14922
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49
Timestamp: 2024-05-27T10:53:40.687Z
Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
🔇 Additional comments (12)
apps/judicial-system/api/src/app/modules/case/interceptors/limitedAccessCase.transformer.ts (2)

4-4: LGTM: Import changes enhance type safety and support new functionality

The addition of the type guard and indictment-related imports aligns well with the PR's objective of improving verdict appeal information handling.

Also applies to: 9-12


56-69: 🛠️ Refactor suggestion

Add validation for required properties

While the implementation correctly transforms indictment cases, it might be vulnerable to runtime errors if required properties are missing.

Consider adding validation:

 const transformIndictmentCase = (theCase: Case): Case => {
+  if (!theCase.defendants) {
+    throw new Error('Defendants array is required for indictment case transformation')
+  }
   const { indictmentRulingDecision, rulingDate, defendants, eventLogs } =
     theCase
   return {

Let's verify the usage of these properties across the codebase:

apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (2)

37-40: LGTM! New defendant fields are well-structured.

The addition of serviceRequirement and isVerdictAppealDeadlineExpired fields to the defendants object is well-placed and aligns with the PR objective of moving verdict appeal calculations to the API side.


164-165: Verify the relationship between case-level and defendant-level appeal fields.

The new case-level fields look good, but let's verify their implementation:

  1. How does indictmentVerdictViewedByAll relate to individual defendant's verdictViewDate?
  2. How does indictmentVerdictAppealDeadlineExpired relate to individual defendant's isVerdictAppealDeadlineExpired?

Let's check for the resolver implementation:

apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (3)

41-41: LGTM! Well-structured parameter addition.

The new parameter isVerdictAppealDeadlineExpired follows TypeScript best practices and maintains backward compatibility.


54-56: Clean and readable implementation.

The simplified logic using the boolean flag improves maintainability while preserving the existing message structure. This aligns well with the team's preference for readability, as noted in previous feedback.


73-73: Verify GraphQL schema includes the new property.

The code assumes isVerdictAppealDeadlineExpired is available in the Defendant type. Let's verify this assumption.

✅ Verification successful

Let me try a different approach to locate the GraphQL schema and query definitions.

This should help us locate:

  1. GraphQL schema files if they exist
  2. TypeScript interface definition for Defendant
  3. Usage of the property in question

Based on the search results, I can now provide a conclusive response about the GraphQL schema compatibility.

Property is correctly defined and used in the GraphQL schema

The isVerdictAppealDeadlineExpired property is:

  1. Defined in the GraphQL schema as shown in both case.graphql and limitedAccessCase.graphql files
  2. Properly modeled in the backend as a nullable boolean field in defendant.model.ts
  3. Correctly computed in the backend transformer (case.transformer.ts)
  4. Used consistently in the frontend components

The property exists in the GraphQL schema and is properly integrated throughout the codebase, making its usage in DefendantInfo.tsx safe and correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that isVerdictAppealDeadlineExpired is defined in the GraphQL schema
# and that all queries fetching Defendant include this field

# Check schema definition
rg -A 5 "type Defendant" 

# Check GraphQL queries
rg -A 10 "fragment.*Defendant|query.*Defendant"

Length of output: 1505


Script:

#!/bin/bash
# Search for GraphQL schema files
echo "=== Searching for GraphQL schema files ==="
fd "\.(graphql|gql)$"

# Search for type definitions in TypeScript files
echo -e "\n=== Searching for Defendant type definitions ==="
ast-grep --pattern 'interface Defendant {
  $$$
}'

# Search for isVerdictAppealDeadlineExpired in TypeScript files
echo -e "\n=== Searching for isVerdictAppealDeadlineExpired usage ==="
rg "isVerdictAppealDeadlineExpired" -B 2 -A 2

Length of output: 27794

apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

31-31: LGTM! Field placement and naming follow GraphQL conventions.

The new field isVerdictAppealDeadlineExpired is logically placed near other verdict-related fields and follows boolean field naming conventions.

Please update the documentation to reflect this new field, as noted in the PR checklist.

Let's verify the frontend usage of this new field:

✅ Verification successful

Let me try a different search strategy to find the frontend usage.


Let me check the actual implementation in the DefendantInfo component to verify proper usage.


The new field is properly integrated and used in the frontend

The verification shows that:

  • The field is correctly used in DefendantInfo.tsx component
  • It's properly typed as boolean | null
  • It's used in the getAppealExpirationInfo function to determine the correct message to display
  • The field is also present in both GraphQL queries (case.graphql and limitedAccessCase.graphql)

The implementation aligns perfectly with the PR's objective of moving verdict appeal expiry calculation from frontend to API.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find components using the new isVerdictAppealDeadlineExpired field
# Expected: DefendantInfo component should use this field

rg "isVerdictAppealDeadlineExpired" apps/judicial-system/web/src/components/ -t tsx

Length of output: 111


Script:

#!/bin/bash
# Search for the field usage without file type restriction since the extension might be .ts or .tsx
rg "isVerdictAppealDeadlineExpired" apps/judicial-system/web/src/components/

# Also search in the entire web directory to catch any usage
rg "isVerdictAppealDeadlineExpired" apps/judicial-system/web/src/

Length of output: 1358


Script:

#!/bin/bash
# Get the full context of how the field is used in DefendantInfo
cat apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx

Length of output: 4714

apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)

172-174: LGTM: Clear and type-safe function signature.

The function rename to getIndictmentDefendantsInfo better reflects its specific purpose in handling indictment defendants, improving code clarity.


189-189: LGTM: Property addition matches PR requirements.

The addition of isVerdictAppealDeadlineExpired to the defendant info aligns with the PR objective of providing correct verdict appeal information.


203-203: Verify all usages of the renamed function.

The function usage here is correct, but let's verify that all other occurrences of the old function name have been updated.

✅ Verification successful

Let me try to search for both the old and new function names to get a better understanding.


All usages of the renamed function have been properly updated

The search results show that:

  • No instances of the old function name getDefendantsInfo exist in the codebase
  • The new function name getIndictmentDefendantsInfo is consistently used across all relevant files:
    • Defined and exported in case.transformer.ts
    • Used in case.transformer.ts and limitedAccessCase.transformer.ts
    • Properly tested in case.transformer.spec.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of the old function name
rg "getDefendantsInfo" --type ts

Length of output: 32


Script:

#!/bin/bash
# Search for both old and new function names
echo "Searching for old function name (getDefendantsInfo):"
rg "getDefendantsInfo" -A 2 --type ts

echo -e "\nSearching for new function name (getIndictmentDefendantsInfo):"
rg "getIndictmentDefendantsInfo" -A 2 --type ts

# Also search for function declaration
ast-grep --pattern 'function getIndictmentDefendantsInfo($_) {
  $$$
}'

Length of output: 2875

apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (1)

17-17: LGTM! Clear and descriptive function rename.

The rename from getDefendantsInfo to getIndictmentDefendantsInfo better reflects the function's purpose and aligns with the PR's objective.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 42.10526% with 11 lines in your changes missing coverage. Please review.

Project coverage is 36.76%. Comparing base (a84ba44) to head (83a5f5a).

Files with missing lines Patch % Lines
...case/interceptors/limitedAccessCase.transformer.ts 0.00% 9 Missing ⚠️
...rc/app/modules/defendant/models/defendant.model.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16533      +/-   ##
==========================================
- Coverage   36.76%   36.76%   -0.01%     
==========================================
  Files        6851     6851              
  Lines      142120   142133      +13     
  Branches    40542    40545       +3     
==========================================
+ Hits        52250    52253       +3     
- Misses      89870    89880      +10     
Flag Coverage Δ
judicial-system-api 18.40% <31.25%> (+0.04%) ⬆️
judicial-system-web 27.81% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
.../app/modules/case/interceptors/case.transformer.ts 100.00% <100.00%> (ø)
...omponents/InfoCard/DefendantInfo/DefendantInfo.tsx 83.78% <100.00%> (-0.43%) ⬇️
...rc/app/modules/defendant/models/defendant.model.ts 0.00% <0.00%> (ø)
...case/interceptors/limitedAccessCase.transformer.ts 0.00% <0.00%> (ø)

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 a84ba44...83a5f5a. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 23, 2024

Datadog Report

All test runs 4681594 🔗

2 Total Test Services: 0 Failed, 2 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.04%), 1 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-api 0 0 0 57 0 6.91s 1 decreased (-0.04%) Link
judicial-system-web 0 0 0 338 0 1m 15s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-api - jest 19.57% (-0.04%) - 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

🧹 Outside diff range and nitpick comments (2)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (2)

67-73: Consider using dynamic dates in tests

While the test logic is correct, using hardcoded future dates ('2024-08-05') might cause the tests to fail when these dates pass. Consider using dynamic date calculation relative to the mocked system time.

Example refactor:

- const verdictAppealDeadline = '2024-08-05'
+ const futureDate = new Date('2024-07-08')  // Using mocked system time
+ futureDate.setDate(futureDate.getDate() + 28)  // 28 days in future
+ const verdictAppealDeadline = futureDate.toISOString().split('T')[0]

Also applies to: 84-90


Line range hint 1-133: Consider enhancing type safety in tests

While the tests are well-structured, consider adding TypeScript type annotations for the test parameters and return values. This would make the tests more maintainable and catch potential type-related issues early.

Example:

interface AppealExpirationInfo {
  message: { id: string };
  date?: string;
}

// Use in test cases:
const dataSections: AppealExpirationInfo = getAppealExpirationInfo(...)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c45a61e and 3ef5987.

📒 Files selected for processing (3)
  • apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts
  • apps/judicial-system/web/src/components/FormProvider/case.graphql
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.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."
📓 Learnings (1)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (1)
Learnt from: unakb
PR: island-is/island.is#14922
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
🔇 Additional comments (2)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (2)

18-24: LGTM! Test correctly handles undefined deadline scenario

The test case properly sets isVerdictAppealDeadlineExpired to false when no deadline is provided, maintaining the expected behavior while adapting to the new API-driven expiration calculation.


101-107: Consider adding edge case test for same-day expiration

The tests cover past and future dates well, but there's no test case for when verdictAppealDeadline is exactly the same as the current date ('2024-07-08'). This edge case should be tested to ensure correct behavior.

Also applies to: 118-124

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

Successfully merging this pull request may close these issues.

2 participants