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(delegation-api): add legal guardian minor delegation type #15214

Merged
merged 20 commits into from
Oct 24, 2024

Conversation

Herdismaria
Copy link
Contributor

@Herdismaria Herdismaria commented Jun 13, 2024

What

Add a new delegation type for legal guardians of minors under 16.

Why

Certain scopes like Postholf should not be accessible by parents if child has turned 16.

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 delegation type, LegalGuardianMinor, for handling legal guardian delegations for minors under 16 years old.
  • Improvements

    • Added new message definitions for client delegation and API scope delegation types related to legal guardians and minors.
  • Bug Fixes

    • Enhanced delegation filtering logic for better handling of legal guardian cases for children under 16 and 18 years old.
  • Chores

    • Updated cache key generation logic for improved build configuration.

@Herdismaria Herdismaria requested review from a team as code owners June 13, 2024 07:49
Copy link
Contributor

coderabbitai bot commented Jun 13, 2024

Walkthrough

The recent changes introduce functionality to handle legal guardianship delegations for minors under 16 and 18 years old. This involves new test scenarios, additional utility functions for age calculations, updated type definitions, and new database migration scripts. The modification includes both backend logic to support the new delegation type and frontend message definitions for better client communication.

Changes

File Summary
.../test/delegation-index/delegation-index-test-cases.ts New imports, constants for dates, modifying child data generation, updated expected delegations structure, and added test cases for various age scenarios.
.../delegation-index.controller.spec.ts Added new import and test case for LegalGuardianMinor delegation for a child under 16.
.../delegation-index.service.spec.ts Introduced testDate and updated assertions to check delegation records based on national ID and type.
.../delegation-index/delegation-index-types.ts Updated ITestCaseOptions and TestCase class to include delegation types in expectedFrom.
.../delegations-controller/delegations.controller.test-cases.ts Changed the national ID type of child1 to 'residentChild'.
.../auth/src/lib/models/delegation.model.ts Added LegalGuardianMinorDelegation class.
.../migrations/...add-legal-guardian-minor-delegation-type.js New migration logic to add LegalGuardianMinor delegation type.
...auth-api-lib/src/index.ts Export added for isUnderXAge utility function.
.../delegations/delegations-incoming-ward.service.ts Added filter logic for legal guardianship delegations based on age criteria.
.../delegations/delegations-index.service.ts Refactored functions for delegation validation and date calculation based on age.
.../delegations/utils/delegations.ts Added LegalGuardianMinor to delegationProviderTypeMap.
.../delegations/utils/getXBirthday.ts New getXBirthday function to calculate specific age birthdays.
.../delegations/utils/isUnderXAge.ts New isUnderXAge function to check if a person is under a specific age.
.../admin/ids-admin/src/lib/messages.ts Added new message definitions for LegalGuardianMinor client and API scope delegation types.
.../shared/types/src/lib/delegation.ts Added LegalGuardianMinor to AuthDelegationType enum.
scripts/ci/cache/__config.mjs Introduced GENERATED_FILES_FORCE constant and updated cache key generation.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 64061f0 and 6786bc3.

Files selected for processing (15)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index-test-cases.ts (7 hunks)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.controller.spec.ts (2 hunks)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.service.spec.ts (4 hunks)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegations-index-types.ts (3 hunks)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegations-controller/delegations.controller.test-cases.ts (1 hunks)
  • libs/api/domains/auth/src/lib/models/delegation.model.ts (2 hunks)
  • libs/auth-api-lib/migrations/20240607093733-add-legal-guardian-minor-delegation-type.js (1 hunks)
  • libs/auth-api-lib/src/index.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming-ward.service.ts (3 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (5 hunks)
  • libs/auth-api-lib/src/lib/delegations/utils/delegations.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/utils/getXBirthday.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/utils/isUnderXAge.ts (1 hunks)
  • libs/portals/admin/ids-admin/src/lib/messages.ts (2 hunks)
  • libs/shared/types/src/lib/delegation.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • libs/auth-api-lib/src/index.ts
  • libs/shared/types/src/lib/delegation.ts
Additional context used
Path-based instructions (13)
libs/auth-api-lib/src/lib/delegations/utils/isUnderXAge.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."
libs/auth-api-lib/migrations/20240607093733-add-legal-guardian-minor-delegation-type.js (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."
libs/auth-api-lib/src/lib/delegations/utils/getXBirthday.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."
libs/auth-api-lib/src/lib/delegations/utils/delegations.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."
libs/api/domains/auth/src/lib/models/delegation.model.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."
libs/auth-api-lib/src/lib/delegations/delegations-incoming-ward.service.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/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegations-index-types.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index-test-cases.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/services/auth/delegation-api/src/app/delegations/test/delegations-controller/delegations.controller.test-cases.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.controller.spec.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/auth-api-lib/src/lib/delegations/delegations-index.service.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/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.service.spec.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/portals/admin/ids-admin/src/lib/messages.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."
Biome
libs/auth-api-lib/migrations/20240607093733-add-legal-guardian-minor-delegation-type.js

[error] 1-1: Redundant use strict directive. (lint/suspicious/noRedundantUseStrict)

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

libs/auth-api-lib/src/lib/delegations/delegations-incoming-ward.service.ts

[error] 19-19: 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.

libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts

[error] 128-128: 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] 130-130: 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] 132-132: 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] 208-209: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 467-467: 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.

GitHub Check: linting (services-auth-admin-api,services-auth-delegation-api,services-auth-ids-api,services-auth...
apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.controller.spec.ts

[warning] 17-17:
'child2' is defined but never used. Allowed unused vars must match /^_[a-zA-Z0-9]*$/u


[warning] 447-447:
Found valid SSN: 2101188290

Additional comments not posted (21)
libs/auth-api-lib/src/lib/delegations/utils/isUnderXAge.ts (1)

4-18: The function isUnderXAge effectively calculates whether a person is under a specified age based on their national ID. This function uses the kennitala library to extract the birth date and then calculates if the current date is before the birthday after adding the specified number of years. The logic appears sound and well-implemented.

libs/auth-api-lib/migrations/20240607093733-add-legal-guardian-minor-delegation-type.js (1)

6-7: Ensure that the id field in the INSERT statement is unique and correctly references the intended delegation_type. Also, the field provider should be verified to ensure it matches the expected values in the database schema.

libs/auth-api-lib/src/lib/delegations/utils/getXBirthday.ts (1)

5-24: The function getXBirthday correctly calculates the birthday when a person turns a specific age. The use of startOfDay and isBefore from date-fns ensures that the time component is correctly handled. The logic to return null if the person has already passed this age is a good safeguard.
[APROVED]

libs/auth-api-lib/src/lib/delegations/utils/delegations.ts (1)

17-20: Adding AuthDelegationType.LegalGuardianMinor to the delegationProviderTypeMap for AuthDelegationProvider.NationalRegistry is a necessary update to support the new delegation type. Ensure that all systems using this map handle the new type correctly.

libs/api/domains/auth/src/lib/models/delegation.model.ts (2)

29-30: Correct implementation of the resolveType method for the new LegalGuardianMinor delegation type.


64-67: Proper definition of LegalGuardianMinorDelegation class with correct usage of the @ObjectType decorator.

libs/auth-api-lib/src/lib/delegations/delegations-incoming-ward.service.ts (2)

14-14: Correct import of isUnderXAge utility function, essential for the new delegation logic.


Line range hint 53-75: Well-implemented logic for filtering legal guardian delegations, both for minors under 18 and specifically under 16, using the isUnderXAge utility.

apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegations-index-types.ts (2)

11-11: Proper import of AuthDelegationType for use in test cases.


32-32: Correctly updated TestCase class to include delegation types in the expectedFrom field, aligning with the new functionality tests.

Also applies to: 46-46

apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index-test-cases.ts (2)

1-3: Correct import of necessary modules and definition of constants for generating dynamic test data.

Also applies to: 11-11


16-31: Well-structured test cases that correctly handle different age groups for testing various delegation types, ensuring comprehensive coverage.

Also applies to: 45-63, 76-97

apps/services/auth/delegation-api/src/app/delegations/test/delegations-controller/delegations.controller.test-cases.ts (1)

17-17: Confirm the updated national ID type for child1.

libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (2)

38-39: Confirm the addition of utility imports for handling age calculations.


263-278: Review the logic for handling legal guardian minor delegations. Ensure that the conditions and calculations for validTo dates are correct and optimized.

Verification successful

The logic for handling legal guardian minor delegations and the conditions and calculations for validTo dates are correct and optimized.

  • The getXBirthday function is appropriately used to set validTo dates based on age.
  • The isUnderXAge function is correctly used to check if a child is under a certain age.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct application of age-related utility functions in minor delegation handling.

# Test: Search for the usage of `getXBirthday` and `isUnderXAge` in the context of minor delegations. Expect: Correct and optimized usage.
rg --type typescript $'getXBirthday|isUnderXAge' ./libs/auth-api-lib/src/lib/delegations/

Length of output: 125



Script:

#!/bin/bash
# Description: Verify the correct application of age-related utility functions in minor delegation handling.

# Test: Search for the usage of `getXBirthday` and `isUnderXAge` in the context of minor delegations. Expect: Correct and optimized usage.
rg --type ts 'getXBirthday|isUnderXAge' ./libs/auth-api-lib/src/lib/delegations/

Length of output: 1686

apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.service.spec.ts (4)

27-31: Ensure that the new imports and constants are properly utilized in the tests.


211-216: Verify that the delegation records match the expected outputs in the test cases.


450-455: Confirm that the custom delegation indexing logic accurately reflects the expected delegation records.


487-493: Ensure that personal representative delegations are indexed correctly, especially with the new delegation type handling.

libs/portals/admin/ids-admin/src/lib/messages.ts (2)

900-907: The new message definitions for the client delegation type 'Legal Guardian Minor' are clear and align well with the application's context.


967-975: The message definitions for the API scope delegation type 'Legal Guardian Minor' are consistent and provide clear information on the scope of the delegation.

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 36.19%. Comparing base (1a30e6b) to head (ccd8a49).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...b/delegations/delegations-incoming-ward.service.ts 66.66% 3 Missing ⚠️
...b/src/lib/delegations/delegations-index.service.ts 84.21% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15214      +/-   ##
==========================================
- Coverage   36.76%   36.19%   -0.57%     
==========================================
  Files        6851     6836      -15     
  Lines      142129   144834    +2705     
  Branches    40546    42235    +1689     
==========================================
+ Hits        52251    52425     +174     
- Misses      89878    92409    +2531     
Flag Coverage Δ
air-discount-scheme-backend 54.08% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-air-discount-scheme 36.93% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.91% <100.00%> (+<0.01%) ⬆️
api-domains-criminal-record 48.00% <ø> (ø)
api-domains-driving-license 44.48% <ø> (ø)
api-domains-education 31.58% <ø> (ø)
api-domains-health-insurance 34.77% <ø> (ø)
api-domains-mortgage-certificate 34.98% <ø> (ø)
api-domains-payment-schedule 41.16% <ø> (ø)
application-api-files 56.76% <ø> (ø)
application-core 71.32% <ø> (-0.33%) ⬇️
application-template-api-modules 27.81% <100.00%> (-0.02%) ⬇️
application-templates-accident-notification 29.27% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.34% <ø> (ø)
application-templates-driving-license 18.34% <ø> (ø)
application-templates-estate 12.31% <ø> (ø)
application-templates-example-payment 25.14% <ø> (ø)
application-templates-financial-aid 15.49% <ø> (ø)
application-templates-general-petition 23.44% <ø> (ø)
application-templates-inheritance-report 6.49% <ø> (ø)
application-templates-marriage-conditions 15.17% <ø> (ø)
application-templates-mortgage-certificate 43.59% <100.00%> (+0.02%) ⬆️
application-templates-parental-leave 29.84% <ø> (-0.13%) ⬇️
application-types 6.63% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.36% <ø> (ø)
auth-nest-tools 30.02% <100.00%> (+0.18%) ⬆️
auth-react 22.81% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.67% <ø> (ø)
clients-driving-license-book 43.80% <ø> (ø)
clients-financial-statements-inao 49.32% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-middlewares 73.45% <100.00%> (+0.27%) ⬆️
clients-regulations 42.80% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-syslumenn 49.49% <ø> (ø)
cms 0.42% <ø> (ø)
cms-translations 39.04% <100.00%> (+<0.01%) ⬆️
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 5.44% <ø> (ø)
download-service 44.22% <ø> (ø)
financial-aid-backend 56.25% <ø> (ø)
financial-aid-shared 18.94% <ø> (ø)
icelandic-names-registry-backend 53.97% <ø> (ø)
island-ui-core 28.44% <ø> (ø)
judicial-system-api 18.38% <ø> (ø)
judicial-system-backend 55.16% <100.00%> (+<0.01%) ⬆️
judicial-system-web 27.80% <ø> (ø)
license-api 42.51% <ø> (ø)
localization 10.15% <ø> (ø)
nest-audit 68.20% <ø> (ø)
nest-aws ?
nest-core 43.54% <ø> (ø)
nest-feature-flags 51.52% <ø> (ø)
nest-problem 45.85% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 16.14% <ø> (ø)
reference-backend 49.79% <ø> (ø)
services-auth-admin-api 51.89% <30.23%> (-0.05%) ⬇️
services-auth-delegation-api 57.52% <96.22%> (+0.14%) ⬆️
services-auth-ids-api 51.45% <55.55%> (+0.04%) ⬆️
services-auth-personal-representative 45.12% <30.23%> (-0.03%) ⬇️
services-auth-personal-representative-public 41.22% <30.23%> (-0.02%) ⬇️
services-auth-public-api 48.95% <55.81%> (+0.04%) ⬆️
services-documents 60.58% <ø> (ø)
services-endorsements-api 53.59% <ø> (ø)
services-search-indexer ?
services-sessions 65.39% <100.00%> (+0.06%) ⬆️
services-university-gateway 48.42% <ø> (+0.02%) ⬆️
services-user-notification 46.93% <100.00%> (+<0.01%) ⬆️
services-user-profile 61.77% <ø> (-0.08%) ⬇️
shared-components 27.70% <ø> (ø)
shared-form-fields 31.57% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.18% <ø> (ø)
testing-e2e ?
web 1.80% <ø> (ø)

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

Files with missing lines Coverage Δ
...st/delegation-index/delegation-index-test-cases.ts 100.00% <100.00%> (ø)
...s/test/delegation-index/delegations-index-types.ts 100.00% <ø> (ø)
...ns-controller/delegations.controller.test-cases.ts 100.00% <100.00%> (ø)
...delegations/test/delegations-filters-test-cases.ts 100.00% <100.00%> (ø)
libs/auth-api-lib/src/index.ts 94.44% <100.00%> (-5.56%) ⬇️
...i-lib/src/lib/delegations/delegation-dto.mapper.ts 83.33% <100.00%> (-16.67%) ⬇️
...h-api-lib/src/lib/delegations/utils/delegations.ts 52.77% <ø> (-47.23%) ⬇️
...-api-lib/src/lib/delegations/utils/getXBirthday.ts 100.00% <100.00%> (ø)
...h-api-lib/src/lib/delegations/utils/isUnderXAge.ts 100.00% <100.00%> (ø)
libs/shared/types/src/lib/delegation.ts 100.00% <100.00%> (ø)
... and 2 more

... and 198 files 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 1a30e6b...ccd8a49. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 13, 2024

Datadog Report

All test runs 008a6e9 🔗

81 Total Test Services: 0 Failed, 79 Passed
🔻 Test Sessions change in coverage: 6 decreased, 8 increased, 186 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 81 0 42.63s N/A Link
air-discount-scheme-web 0 0 0 2 0 10.52s N/A Link
api 0 0 0 4 0 4.68s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 22.99s N/A Link
api-domains-assets 0 0 0 3 0 21.84s N/A Link
api-domains-auth-admin 0 0 0 18 0 22.66s N/A Link
api-domains-communications 0 0 0 5 0 47.29s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 14.36s N/A Link
api-domains-driving-license 0 0 0 23 0 27.61s N/A Link
api-domains-education 0 0 0 8 0 34.13s N/A Link

🔻 Code Coverage Decreases vs Default Branch (6)

This report shows up to 5 code coverage decreases.

  • application-templates-parental-leave - jest 33.21% (-0.1%) - Details
  • services-auth-personal-representative - jest 51.16% (-0.04%) - Details
  • services-auth-personal-representative-public - jest 46.98% (-0.04%) - Details
  • services-auth-admin-api - jest 51.99% (-0.04%) - Details
  • license-api - jest 34.43% (-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: 1

Outside diff range and nitpick comments (3)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (3)

38-39: ### Ensure proper encapsulation of utility functions
The utility functions getXBirthday and isUnderXAge are imported here. Given their potential reuse across various modules, consider encapsulating these functions within a more generic utility service or class, which could then be injected as needed. This would enhance modularity and maintainability.


Line range hint 326-355: ### Handle promise rejections properly in bulk operations
The use of Promise.allSettled is appropriate for handling multiple asynchronous operations concurrently. However, the error handling in lines 351-355 only logs the error. Consider enhancing the error handling strategy by possibly retrying failed operations or alerting through an external monitoring service. This would improve the robustness of the indexing process.

+ try {
+   // Retry logic or alerting mechanism
+ } catch (error) {
+   console.error('Failed operation:', error)
+ }

Line range hint 475-475: ### Optimize the use of the spread operator in accumulators
The use of the spread operator in the accumulator of the .reduce method can lead to performance issues due to its O(n^2) complexity. Consider using alternative methods like .push to accumulate items.

- acc.created.push(curr)
+ acc.created = [...acc.created, curr]
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6786bc3 and cc6c5be.

Files selected for processing (4)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.controller.spec.ts (1 hunks)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.service.spec.ts (6 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (8 hunks)
  • libs/auth-api-lib/src/lib/delegations/utils/getXBirthday.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.controller.spec.ts
  • apps/services/auth/delegation-api/src/app/delegations/test/delegation-index/delegation-index.service.spec.ts
  • libs/auth-api-lib/src/lib/delegations/utils/getXBirthday.ts
Additional context used
Path-based instructions (1)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.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."
Biome
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts

[error] 128-128: 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] 130-130: 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] 132-132: 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] 208-209: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 475-475: 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.

Additional comments not posted (1)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (1)

263-279: ### Review logic for handling LegalGuardian delegations
The conditional block handling LegalGuardian delegations seems to correctly implement the business logic as per the requirements. However, there's a potential improvement in how the validTo date is set. It's currently being recalculated every time, which could be optimized by caching the result if the calculation is expensive.

Additionally, ensure that the upsert operation in line 273 is correctly handling edge cases, such as concurrent updates that might lead to race conditions.

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 cc6c5be and e5e1e1c.

Files selected for processing (1)
  • libs/portals/admin/ids-admin/src/lib/messages.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • libs/portals/admin/ids-admin/src/lib/messages.ts

@lodmfjord lodmfjord requested a review from a team as a code owner June 13, 2024 10:01
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 e5e1e1c and fbd3367.

Files selected for processing (1)
  • scripts/ci/cache/__config.mjs (2 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/ci/cache/__config.mjs

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 (1)
apps/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts (1)

Line range hint 238-383: Eliminate duplicate setup and teardown hooks to streamline test execution.

The static analysis has flagged multiple instances where beforeAll and afterAll hooks are duplicated within the describe functions. This redundancy can lead to increased setup/teardown times and can make the tests harder to maintain. Consider refactoring these to eliminate duplication, potentially by moving shared setup and teardown logic to higher-level describe blocks or into helper functions.

Also applies to: 385-405, 584-602, 604-623, 736-881, 883-903, 1085-1106, 1108-1127

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fbd3367 and 5b829bb.

Files selected for processing (1)
  • apps/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts (1 hunks)
Files not summarized due to errors (1)
  • apps/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts: Error: Server error. Please try again later.
Additional context used
Path-based instructions (1)
apps/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts

[error] 238-383: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow beforeAll duplicacy inside the describe function.


[error] 385-405: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow afterAll duplicacy inside the describe function.


[error] 584-602: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow beforeAll duplicacy inside the describe function.


[error] 604-623: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow afterAll duplicacy inside the describe function.


[error] 736-881: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow beforeAll duplicacy inside the describe function.


[error] 883-903: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow afterAll duplicacy inside the describe function.


[error] 1085-1106: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow beforeAll duplicacy inside the describe function.


[error] 1108-1127: Disallow duplicate setup and teardown hooks. (lint/suspicious/noDuplicateTestHooks)

Disallow afterAll duplicacy inside the describe function.

Additional comments not posted (1)
apps/services/auth/ids-api/src/app/delegations/delegations.controller.spec.ts (1)

1260-1264: Ensure consistent delegation type claims.

The test checks for delegation types Custom and LegalGuardian, but given the PR's focus on introducing a new delegation type for legal guardians of minors, it's crucial to verify that LegalGuardianMinor is also considered where applicable. Please confirm if this new type should be included in the test assertions here.

@Herdismaria Herdismaria marked this pull request as draft June 18, 2024 09:44
@datadog-island-is
Copy link

datadog-island-is bot commented Oct 18, 2024

Datadog Report

All test runs 126673e 🔗

81 Total Test Services: 0 Failed, 78 Passed
🔻 Test Sessions change in coverage: 2 decreased, 6 increased, 189 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 81 0 28.77s 1 no change Link
air-discount-scheme-web 0 0 0 2 0 8.66s 1 no change Link
api 0 0 0 4 0 2.87s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 17.91s N/A Link
api-domains-assets 0 0 0 3 0 11.37s N/A Link
api-domains-auth-admin 0 0 0 18 0 12.22s N/A Link
api-domains-communications 0 0 0 5 0 27.79s N/A Link
api-domains-criminal-record 0 0 0 5 0 10.81s N/A Link
api-domains-driving-license 0 0 0 23 0 32.78s N/A Link
api-domains-education 0 0 0 8 0 20.22s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-admin-api - jest 47.57% (-0.02%) - Details
  • application-template-api-modules - jest 30.04% (-0.01%) - Details

@GunnlaugurG GunnlaugurG marked this pull request as ready for review October 23, 2024 10:09
Copy link
Member

@baering baering left a comment

Choose a reason for hiding this comment

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

LGTM

@GunnlaugurG GunnlaugurG added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Oct 24, 2024
@kodiakhq kodiakhq bot merged commit af6f6e9 into main Oct 24, 2024
210 of 211 checks passed
@kodiakhq kodiakhq bot deleted the feature/add-legal-guardian-minor-delegation-type branch October 24, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants