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(driving-license): Prevent temp license holders from applying for BE license #15278

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

juni-haukur
Copy link
Member

@juni-haukur juni-haukur commented Jun 19, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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 license application process to handle different types of licenses (temp, full, BE).
    • Added support for submitting additional information (instructor SSN, primary phone number, student email) when applying for a BE license.
  • Improvements

    • Updated terminology for trailer license application from 'Kerruréttindi BE' to 'Eftirvagn BE'.
  • Refactor

    • Streamlined code to include additional parameters in various methods related to BE license application.

@juni-haukur juni-haukur requested a review from a team as a code owner June 19, 2024 10:39
Copy link
Contributor

coderabbitai bot commented Jun 19, 2024

Walkthrough

The recent updates enhance the functionality related to different types of driving licenses, specifically handling categories and associated validity codes for temporary, full, and BE (trailer) licenses. Additionally, messages and service methods have been updated to include new parameters like instructorSSN, studentEmail, and primaryPhoneNumber, improving the overall application processing and communication capabilities.

Changes

Files Change Summary
libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts Updated license categories and validity codes handling, added conditions for excluding temporary licenses from certain checks.
libs/application/templates/driving-license/src/lib/messages.ts Changed the default message for BE license application from 'Kerruréttindi BE' to 'Eftirvagn BE'.
libs/api/domains/driving-license/src/lib/drivingLicense.service.ts Updated applyForBELicense method to accept NewBEDrivingLicenseInput, including instructorSSN, studentEmail, and primaryPhoneNumber.
libs/api/domains/driving-license/src/lib/drivingLicense.type.ts Added NewBEDrivingLicenseInput interface with jurisdiction, instructorSSN, primaryPhoneNumber, and studentEmail fields.
libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts Modified applyForBELicense method to accept object with instructorSSN, primaryPhoneNumber, and studentEmail when applicationFor is 'BE'.
libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts Added instructorSSN, phoneNumber, and email to applyForBE method parameters.
libs/clients/driving-license/src/v5/clientConfig.json Added new fields instructorSSN, primaryPhoneNumber, and studentEmail with corresponding descriptions, and specified format: "int32" for districtId.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ApplicationForm
    participant ApplicationService
    participant DrivingLicenseApi

    User->>ApplicationForm: Fill license application form
    ApplicationForm->>ApplicationService: Submit form (includes instructorSSN, studentEmail, primaryPhoneNumber)
    ApplicationService->>DrivingLicenseApi: applyForBELicense(input)
    DrivingLicenseApi->>ApplicationService: API response
    ApplicationService->>ApplicationForm: Success/Failure response
    ApplicationForm->>User: Display confirmation message
Loading

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

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 19, 2024

Datadog Report

All test runs ce6afb5 🔗

9 Total Test Services: 0 Failed, 8 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 14 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 4.81s 1 no change Link
api-domains-driving-license 0 0 0 23 0 34.93s 1 no change Link
api-domains-license-service 0 0 0 0 0 744.38ms 1 no change Link
application-system-api 0 0 0 111 2 3m 1.8s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 22.73s 1 decreased (-0.01%) Link
application-templates-driving-license 0 0 0 13 0 43.09s 1 no change Link
application-ui-shell 0 0 0 74 0 1m 14.55s 1 no change Link
clients-driving-license 0 0 0 9 0 29.03s 1 no change Link
license-api 0 0 0 80 0 21.61s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 26.02% (-0.01%) - 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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0ece477 and ca0923b.

Files selected for processing (2)
  • libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts (2 hunks)
  • libs/application/templates/driving-license/src/lib/types.ts (1 hunks)
Additional context used
Path-based instructions (2)
libs/application/templates/driving-license/src/lib/types.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/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.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."
Additional comments not posted (2)
libs/application/templates/driving-license/src/lib/types.ts (1)

13-13: The addition of validToCode to DrivingLicenseCategory aligns well with the PR objectives and appears to be correctly implemented.

libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts (1)

Line range hint 50-91: The logic to exclude temporary licenses from applying for a BE license is correctly implemented and aligns with the PR objectives. Ensure that all conditions, especially the complex conditional at lines 88-91, are thoroughly tested to prevent any unintended behavior.

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 37.24%. Comparing base (62fa054) to head (9b8b83c).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15278      +/-   ##
==========================================
+ Coverage   37.13%   37.24%   +0.10%     
==========================================
  Files        6504     6489      -15     
  Lines      132230   131860     -370     
  Branches    37804    37632     -172     
==========================================
+ Hits        49101    49106       +5     
+ Misses      83129    82754     -375     
Flag Coverage Δ
air-discount-scheme-backend 53.78% <ø> (ø)
api 3.47% <ø> (ø)
api-domains-payment-schedule 40.62% <ø> (ø)
application-types 7.30% <ø> (ø)
clients-license-client 1.84% <ø> (ø)
clients-middlewares 72.61% <ø> (-0.08%) ⬇️
financial-aid-backend 56.52% <ø> (ø)
island-ui-core 28.92% <ø> (ø)
judicial-system-api 17.95% <ø> (ø)
judicial-system-audit-trail 67.84% <ø> (ø)
judicial-system-formatters 81.40% <ø> (ø)
localization 10.15% <ø> (ø)
nest-config 77.61% <ø> (+0.06%) ⬆️
nest-swagger 51.71% <ø> (ø)
nova-sms 63.41% <ø> (ø)
portals-admin-regulations-admin 2.04% <ø> (ø)
portals-core 16.34% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-documents 60.96% <ø> (+0.07%) ⬆️
services-endorsements-api 55.24% <ø> (+0.04%) ⬆️
services-user-profile 62.25% <ø> (ø)

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

Files Coverage Δ
...ins/driving-license/src/lib/drivingLicense.type.ts 100.00% <ø> (ø)
...tion/templates/driving-license/src/lib/messages.ts 100.00% <ø> (ø)
...iving-license/src/lib/drivingLicenseApi.service.ts 54.40% <ø> (ø)
.../driving-license/src/lib/drivingLicense.service.ts 57.97% <0.00%> (ø)
...e-submission/driving-license-submission.service.ts 43.13% <0.00%> (-2.70%) ⬇️
...e/src/forms/prerequisites/sectionApplicationFor.ts 0.00% <0.00%> (ø)

... and 120 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 92ff090...9b8b83c. Read the comment docs.

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 (5)
libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts (2)

Line range hint 40-40: ISSUE: Incorrect use of decorators.

The use of decorators here is flagged as invalid. Ensure that decorators are used in the correct context and configuration settings are adjusted if necessary.

Tools
Biome

[error] 199-216: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


Line range hint 183-216: REFACTOR SUGGESTION: Remove unnecessary else clauses.

The else clauses in lines 183-216, 199-216, and 243-247 are unnecessary as the previous branches in the conditional statements break early. Removing these will simplify the control flow and improve readability.

- else {
-   throw new Error('application for unknown type of license')
- }

Also applies to: 199-216, 243-247

Tools
Biome

[error] 199-216: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

libs/api/domains/driving-license/src/lib/drivingLicense.service.ts (3)

Line range hint 53-53: ISSUE: Incorrect use of decorators.

The use of decorators here is flagged as invalid. Ensure that decorators are used in the correct context and configuration settings are adjusted if necessary.


Line range hint 238-238: REFACTOR SUGGESTION: Use optional chaining.

Consider using optional chaining to simplify null checks and improve code readability.

- if ((e as { status: number })?.status === 404) {
+ if (e?.status === 404) {

Line range hint 362-373: REFACTOR SUGGESTION: Remove unnecessary else clauses.

The else clauses in lines 362-373, 367-373, and 371-373 are unnecessary as the previous branches in the conditional statements break early. Removing these will simplify the control flow and improve readability.

- else {
-   throw new Error('unhandled license type')
- }

Also applies to: 367-373, 371-373

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ca0923b and 50b6d16.

Files selected for processing (6)
  • libs/api/domains/driving-license/src/lib/drivingLicense.service.ts (2 hunks)
  • libs/api/domains/driving-license/src/lib/drivingLicense.type.ts (1 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts (1 hunks)
  • libs/application/templates/driving-license/src/lib/messages.ts (1 hunks)
  • libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts (2 hunks)
  • libs/clients/driving-license/src/v5/clientConfig.json (3 hunks)
Files not reviewed due to errors (1)
  • libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts (no review received)
Files skipped from review due to trivial changes (1)
  • libs/application/templates/driving-license/src/lib/messages.ts
Additional context used
Path-based instructions (5)
libs/api/domains/driving-license/src/lib/drivingLicense.type.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/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.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."
libs/api/domains/driving-license/src/lib/drivingLicense.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."
libs/clients/driving-license/src/lib/drivingLicenseApi.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."
libs/clients/driving-license/src/v5/clientConfig.json (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/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts

[error] 40-40: 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] 183-216: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 199-216: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 243-247: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

libs/api/domains/driving-license/src/lib/drivingLicense.service.ts

[error] 53-53: 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] 238-238: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 362-373: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 367-373: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 371-373: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts

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

Unsafe fix: Change to an optional chain.

Gitleaks
libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts

603-603: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (4)
libs/api/domains/driving-license/src/lib/drivingLicense.type.ts (1)

28-33: APPROVED: New interface NewBEDrivingLicenseInput added successfully.

The new interface NewBEDrivingLicenseInput has been added to define the structure of the input for BE license applications, which aligns with the PR objectives to enhance input handling for BE License applications.

libs/clients/driving-license/src/v5/clientConfig.json (3)

2991-2994: Added configuration for 'districtId' in JSON schema

The addition of the districtId with a description and type specification is a good practice, ensuring clarity and type safety in the API's data contracts. However, consider adding whether this field is required or not to align with other fields in your schema.


3414-3428: Added new fields to 'PostApplicationForBEModel' schema

The addition of instructorSSN, primaryPhoneNumber, and studentEmail fields, all marked as nullable, aligns with the PR's objective to enhance handling for BE license applications. This is a positive change, enhancing the detail and functionality of the API. Ensure that the nullable nature of these fields is intended and aligns with business logic.


3874-3877: Configuration added for 'districtId' in 'TemporaryLicenseStatisticsDetailedDto'

The addition of districtId to the statistics DTO schema is appropriate for detailed tracking and reporting. The explicit type and format declaration enhances the robustness of the API. Ensure consistency in how this field is used or required across different parts of the application.

@juni-haukur juni-haukur added the automerge Merge this PR as soon as all checks pass label Jun 24, 2024
@kodiakhq kodiakhq bot merged commit bc4b637 into main Jun 24, 2024
245 checks passed
@kodiakhq kodiakhq bot deleted the dl-be-temp-license branch June 24, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants