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

chore(driving-license): quality photo check for 65+ #16191

Merged
merged 2 commits into from
Sep 27, 2024
Merged

Conversation

stjanilofts
Copy link
Member

@stjanilofts stjanilofts commented Sep 27, 2024

Add photo check for 65+

image

https://app.asana.com/0/1204431115744096/1208330991700443

Summary by CodeRabbit

  • New Features

    • Enhanced visibility conditions for quality photo submission based on application types.
    • Updated application condition checks to support multiple input types for better flexibility.
  • Bug Fixes

    • Removed unused import to streamline the QualityPhoto component.
  • Refactor

    • Improved logic in the isApplicationForCondition function to handle single and array inputs effectively.

@stjanilofts stjanilofts requested a review from a team as a code owner September 27, 2024 12:51
Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes involve modifications to three files related to the handling of driving license applications. An unused import was removed from the QualityPhoto.tsx file. The isVisible function in subSectionQualityPhoto.ts was updated to change the condition for visibility checks from a boolean expression to an array format. Additionally, the isApplicationForCondition function in formUtils.ts was enhanced to accept either a single value or an array of values, altering its internal logic to accommodate this broader input.

Changes

File Path Change Summary
libs/application/templates/driving-license/src/fields/QualityPhoto/QualityPhoto.tsx Removed unused import statement for ContentBlock.
libs/application/templates/driving-license/src/forms/draft/subSectionQualityPhoto.ts Modified the isVisible function to change the condition for isApplicationForCondition from a boolean expression to an array format.
libs/application/templates/driving-license/src/lib/utils/formUtils.ts Updated isApplicationForCondition to accept a single value or an array of values, with adjusted internal logic to handle the new input type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Application
    participant Utils

    User->>Application: Submit application
    Application->>Utils: Check visibility (isVisible)
    Utils-->>Application: Return visibility status
    Application->>Utils: Check application condition (isApplicationForCondition)
    Utils-->>Application: Return condition status
    Application-->>User: Display application result
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>, 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: 0

🧹 Outside diff range and nitpick comments (1)
libs/application/templates/driving-license/src/lib/utils/formUtils.ts (1)

39-45: Approved: Good improvement in flexibility and type safety.

The changes to isApplicationForCondition function enhance its flexibility by allowing both single and multiple condition checks. The use of TypeScript for input typing is commendable.

Consider a minor refactoring for improved readability:

 export const isApplicationForCondition =
   (result: DrivingLicenseApplicationFor | DrivingLicenseApplicationFor[]) =>
   (answers: FormValue) => {
-    const strings = Array.isArray(result) ? result : [result]
+    const conditions = Array.isArray(result) ? result : [result]
 
-    return strings.some(
+    return conditions.some(
       (x) => x === getValueViaPath(answers, 'applicationFor') ?? B_FULL,
     )
   }

This change makes the variable name more descriptive of its purpose.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a8b2817 and 5a474e9.

📒 Files selected for processing (3)
  • libs/application/templates/driving-license/src/fields/QualityPhoto/QualityPhoto.tsx (0 hunks)
  • libs/application/templates/driving-license/src/forms/draft/subSectionQualityPhoto.ts (1 hunks)
  • libs/application/templates/driving-license/src/lib/utils/formUtils.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (1)
  • libs/application/templates/driving-license/src/fields/QualityPhoto/QualityPhoto.tsx
🧰 Additional context used
📓 Path-based instructions (2)
libs/application/templates/driving-license/src/forms/draft/subSectionQualityPhoto.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/lib/utils/formUtils.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 (2)
libs/application/templates/driving-license/src/lib/utils/formUtils.ts (1)

39-45: Adherence to coding guidelines confirmed.

The changes in this file comply with the coding guidelines for libs/**/*:

  1. The isApplicationForCondition function remains exportable and reusable across different NextJS apps.
  2. TypeScript is effectively used for defining the function parameter types.
  3. The changes don't introduce any issues with tree-shaking or bundling practices.
libs/application/templates/driving-license/src/forms/draft/subSectionQualityPhoto.ts (1)

23-23: Approve the change with a suggestion for verification.

The modification to use an array [B_FULL, B_FULL_RENEWAL_65] instead of a boolean OR condition is a good improvement. It enhances the flexibility of the code and aligns with TypeScript best practices.

However, to ensure the change functions as intended, please verify the implementation of the isApplicationForCondition function to confirm it correctly handles an array of conditions.

To verify the implementation, please run the following script:

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.70%. Comparing base (8fb3ddf) to head (1b2c224).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16191   +/-   ##
=======================================
  Coverage   36.70%   36.70%           
=======================================
  Files        6776     6776           
  Lines      139609   139604    -5     
  Branches    39694    39689    -5     
=======================================
+ Hits        51242    51243    +1     
+ Misses      88367    88361    -6     
Flag Coverage Δ
api 3.39% <ø> (ø)
api-domains-auth-admin 48.77% <ø> (ø)
api-domains-communications 39.96% <ø> (ø)
application-system-api 41.62% <ø> (ø)
application-template-api-modules 23.67% <ø> (-0.04%) ⬇️
application-templates-driving-license 18.70% <100.00%> (+0.07%) ⬆️
application-ui-shell 21.29% <ø> (ø)
cms 0.43% <ø> (ø)
cms-translations 39.08% <ø> (ø)
content-search-toolkit 8.50% <ø> (ø)
judicial-system-api 18.46% <ø> (ø)
judicial-system-backend 54.82% <ø> (ø)
services-user-notification 47.12% <ø> (ø)

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

Files with missing lines Coverage Δ
...g-license/src/fields/QualityPhoto/QualityPhoto.tsx 0.00% <ø> (ø)
...-license/src/forms/draft/subSectionQualityPhoto.ts 0.00% <ø> (ø)
...mplates/driving-license/src/lib/utils/formUtils.ts 70.58% <100.00%> (+0.89%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

@datadog-island-is
Copy link

Datadog Report

All test runs 9a536b0 🔗

70 Total Test Services: 0 Failed, 68 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.05%), 2 increased, 197 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 33.74s N/A Link
air-discount-scheme-web 0 0 0 2 0 8.89s N/A Link
api 0 0 0 4 0 2.58s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 17.19s N/A Link
api-domains-assets 0 0 0 3 0 11.31s N/A Link
api-domains-auth-admin 0 0 0 18 0 12.4s N/A Link
api-domains-communications 0 0 0 5 0 26.74s N/A Link
api-domains-criminal-record 0 0 0 5 0 8.58s 1 no change Link
api-domains-driving-license 0 0 0 23 0 32.64s N/A Link
api-domains-education 0 0 0 8 0 22.37s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-auth-personal-representative-public - jest 40.67% (-0.05%) - Details

@stjanilofts stjanilofts added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Sep 27, 2024
@kodiakhq kodiakhq bot merged commit eac1952 into main Sep 27, 2024
58 checks passed
@kodiakhq kodiakhq bot deleted the chore/dl-add_step branch September 27, 2024 16:39
thoreyjona pushed a commit that referenced this pull request Oct 2, 2024
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
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.

2 participants