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

Handle empty address FormData in AddressWIthAutofillReviewField #29847

Merged
merged 3 commits into from
May 20, 2024

Conversation

coope93
Copy link
Contributor

@coope93 coope93 commented May 17, 2024

Summary

  • Handle loading AddressWIthAutofillReviewField when no state value is provided in the formData prop.
  • It was previously throwing an error because the result was undefined when trying to look up the state label, but now it will just render it as empty.
  • Added a test to validate when we pass an empty address and did a small refactor of the test file to DRY it up a bit.

Related issue(s)

department-of-veterans-affairs/va.gov-team#83332

Testing done

  • Added FE test to handle this scenario

What areas of the site does it impact?

Form 10-10 EZCG

Acceptance criteria

Quality Assurance & Testing

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Linting warnings have been addressed
  • Accessibility testing has been performed

Error Handling

  • Browser console contains no warnings or errors.
  • Events are being sent to the appropriate logging solution

Authentication

  • Did you login to a local build and verify all authenticated routes work as expected with a test user

@coope93 coope93 requested review from a team as code owners May 17, 2024 14:41
@coope93 coope93 changed the title Handle empty address FormData Handle empty address FormData in AddressWIthAutofillReviewField May 17, 2024
@@ -5,7 +5,7 @@ import constants from 'vets-json-schema/dist/constants.json';
export const AddressWithAutofillReviewField = ({ formData, inputLabel }) => {
const stateLabel = constants.states.USA.find(
state => state.value === formData.state,
).label;
)?.label;
Copy link
Contributor Author

@coope93 coope93 May 17, 2024

Choose a reason for hiding this comment

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

This is the only functional change in the PR beyond tests. Trying to get the label for an empty or undefined state throws an error without the optional chaining operator here.

inputLabel: 'Primary Family Caregiver\u2019s',
};

const subject = (props = defaultProps) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrapped our render and getSelectors calls into a subject and set the defaultProps on it with the ability to pass in custom props.

Copy link
Contributor

@Mitch-A6 Mitch-A6 left a comment

Choose a reason for hiding this comment

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

👍 Looks good!

Copy link
Contributor

@mkerns1 mkerns1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@coope93 coope93 merged commit b8461c2 into main May 20, 2024
69 checks passed
@coope93 coope93 deleted the coope93-83332-handle-empty-address branch May 20, 2024 15:03
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.

None yet

5 participants