Skip to content

[OSDEV-2085] Refactored new claim form to store select labels directly and extract shared utility for the StyledSelect component#782

Merged
vlad-shapik merged 3 commits intomainfrom
OSDEV-2085-refactor-select-option-conversion
Oct 29, 2025
Merged

[OSDEV-2085] Refactored new claim form to store select labels directly and extract shared utility for the StyledSelect component#782
vlad-shapik merged 3 commits intomainfrom
OSDEV-2085-refactor-select-option-conversion

Conversation

@vlad-shapik
Copy link
Contributor

@vlad-shapik vlad-shapik commented Oct 28, 2025

[OSDEV-2085]

  • Refactored claim form to store user-selected labels directly instead of enum values, making form data POST-ready without transformation
  • Added reusable findSelectedOption utility for StyledSelect components, reducing code duplication across form steps

@vlad-shapik vlad-shapik self-assigned this Oct 28, 2025
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:32 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik changed the title [OSDEV-2085] Extract shared utility for StyledSelect option conversion [OSDEV-2085] Refactored new claim form to store select labels directly and extract shared utility Oct 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

📝 Walkthrough

Walkthrough

Replaces object-based relationship handling with string-based storage: adds findSelectedOption utility, updates StyledSelect onChange to accept a value object and store labels for non-eligible choices, and changes the validation schema to require relationship as a string.

Changes

Cohort / File(s) Summary
Component updates
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/EligibilityStep.jsx
Import findSelectedOption; derive selectedRelationship via findSelectedOption(RELATIONSHIP_OPTIONS, formData.relationship); simplify relationship error check to touched?.relationship && errors?.relationship; update StyledSelect onChange handler to accept valueObject and reference valueObject.value/valueObject.label; store non-eligible selection using handleChange('relationship', valueObject.label).
New utility function
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/utils.js
Add default export findSelectedOption(options, selectedLabel) returning the option whose label equals selectedLabel, or null if not found or if selectedLabel is falsy.
Validation schema update
src/react/src/components/InitialClaimFlow/ClaimForm/validationSchemas.js
Change eligibilityStepSchema's relationship field from Yup.object() to Yup.string() while keeping required() and the same message.
Tests
src/react/src/__tests__/components/EligibilityStep.test.js
Update expectations: mock handleChange now asserted to receive a string label instead of an object for certain selections.

Sequence Diagram(s)

sequenceDiagram
    participant UI as EligibilityStep (UI)
    participant Util as findSelectedOption
    participant Form as Formik (handleChange / setFieldValue)

    rect rgb(235, 245, 255)
    UI->>UI: User selects option (Select emits valueObject)
    end

    UI->>Util: findSelectedOption(RELATIONSHIP_OPTIONS, formData.relationship)
    Util-->>UI: option | null

    alt valueObject.value === "ELIGIBLE"
        UI->>Form: setFieldValue('relationship', selectedOption) 
    else non-eligible selection
        UI->>Form: handleChange('relationship', valueObject.label)
    end

    Note right of Form: validation expects relationship as string
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify onChange branches use valueObject.value and valueObject.label consistently.
  • Confirm findSelectedOption matches labels exactly and handles falsy input.
  • Check schema change impact where relationship is consumed/stored elsewhere and update tests accordingly.

Possibly related PRs

Suggested reviewers

  • roman-stolar
  • VadimKovalenkoSNF
  • vladsha-dev

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "OSDEV-2085 Refactored new claim form to store select labels directly and extract shared utility for the StyledSelect component" directly and accurately reflects the main changes in the changeset. The title clearly identifies the two primary objectives: refactoring the claim form to store user-selected labels instead of enum values (as evidenced by the validation schema change from object to string and the EligibilityStep modifications), and extracting a reusable utility function for StyledSelect components (the new findSelectedOption function in utils.js). The title is specific and descriptive, avoiding vague terminology while remaining concise and scannable.
Description Check ✅ Passed The pull request description is clearly related to the changeset. It accurately describes the two main changes: refactoring the claim form to store selected labels directly instead of enum values (making form data POST-ready), and adding the reusable findSelectedOption utility function to reduce code duplication. Both of these aspects are well-represented in the file modifications across EligibilityStep.jsx, utils.js, validationSchemas.js, and the test file. The description provides sufficient context about the intent without requiring excessive detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch OSDEV-2085-refactor-select-option-conversion

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc3510f and acb313a.

📒 Files selected for processing (1)
  • src/react/src/__tests__/components/EligibilityStep.test.js (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: run-dd-code-quality
  • GitHub Check: get-base-branch-dd-cov
  • GitHub Check: run-flake8-linter
  • GitHub Check: run-eslint-linter-and-prettier-formatter
  • GitHub Check: run-contricleaner-code-quality
  • GitHub Check: get-base-branch-countries-cov
  • GitHub Check: get-base-branch-contricleaner-cov
  • GitHub Check: run-countries-code-quality
  • GitHub Check: run-django-code-quality
  • GitHub Check: run-integration-test-code-quality
  • GitHub Check: get-base-branch-django-cov
  • GitHub Check: get-base-branch-fe-cov
  • GitHub Check: run-fe-code-quality
🔇 Additional comments (2)
src/react/src/__tests__/components/EligibilityStep.test.js (2)

25-85: LGTM: Mock implementation is correct.

The mock StyledSelect correctly passes the full option object (with value and label) to the onChange handler, which allows testing that the component properly transforms this into the stored label string.


262-276: LGTM: Test assertions correctly verify the new string-based storage.

The updated assertions properly verify that the component now stores the full label string instead of the enum value for eligible options.

Also applies to: 278-292


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/EligibilityStep.jsx (1)

164-164: Update PropTypes to reflect the new data model.

The relationship field is now validated as a string (see validationSchemas.js line 6), but the PropTypes still specify oneOfType([string, object]). Update to reflect that relationship is now exclusively a string.

Apply this diff:

-    relationship: oneOfType([string, object]),
+    relationship: string,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3198ff5 and 2a5b246.

📒 Files selected for processing (3)
  • src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/EligibilityStep.jsx (3 hunks)
  • src/react/src/components/InitialClaimFlow/ClaimForm/Steps/utils.js (1 hunks)
  • src/react/src/components/InitialClaimFlow/ClaimForm/validationSchemas.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/EligibilityStep.jsx (2)
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/utils.js (1)
  • findSelectedOption (5-8)
src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/constants.js (1)
  • RELATIONSHIP_OPTIONS (1-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: get-base-branch-countries-cov
  • GitHub Check: run-flake8-linter
  • GitHub Check: run-dd-code-quality
  • GitHub Check: run-integration-test-code-quality
  • GitHub Check: get-base-branch-dd-cov
  • GitHub Check: run-eslint-linter-and-prettier-formatter
  • GitHub Check: run-contricleaner-code-quality
  • GitHub Check: get-base-branch-contricleaner-cov
  • GitHub Check: run-countries-code-quality
  • GitHub Check: run-fe-code-quality
  • GitHub Check: run-django-code-quality
  • GitHub Check: get-base-branch-django-cov
  • GitHub Check: get-base-branch-fe-cov
🔇 Additional comments (2)
src/react/src/components/InitialClaimFlow/ClaimForm/validationSchemas.js (1)

6-8: LGTM! Schema update aligns with the refactor.

The change from Yup.object() to Yup.string() correctly reflects the new data model where relationship is stored as a label string rather than an option object.

src/react/src/components/InitialClaimFlow/ClaimForm/Steps/EligibilityStep/EligibilityStep.jsx (1)

36-39: Utility usage looks correct.

The findSelectedOption utility is properly used here to derive the option object from the stored label string for the StyledSelect component.

@vlad-shapik vlad-shapik changed the title [OSDEV-2085] Refactored new claim form to store select labels directly and extract shared utility [OSDEV-2085] Refactored new claim form to store select labels directly and extract shared utility for the StyledSelect component Oct 28, 2025
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 28, 2025 16:40 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:25 — with GitHub Actions Inactive
@sonarqubecloud
Copy link

@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:28 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Oct 29, 2025

React App | Jest test suite - Code coverage report

Total: 36.38%

Your code coverage diff: 0.01% ▴

✅ All code changes are covered

Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF left a comment

Choose a reason for hiding this comment

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

Re-approve.

@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:37 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:37 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:37 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik temporarily deployed to Quality Environment October 29, 2025 10:48 — with GitHub Actions Inactive
@vlad-shapik vlad-shapik merged commit 00a85d7 into main Oct 29, 2025
21 checks passed
@vlad-shapik vlad-shapik deleted the OSDEV-2085-refactor-select-option-conversion branch October 29, 2025 10:48
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.

4 participants