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

[Feature] Alert unit tests #301

Merged
merged 12 commits into from
Apr 30, 2024
Merged

[Feature] Alert unit tests #301

merged 12 commits into from
Apr 30, 2024

Conversation

narin
Copy link
Contributor

@narin narin commented Apr 29, 2024

Description of Change

Adds the following unit tests for Alert:

  • Check for rendering of header, description, children, buttons
  • Verify colors for each variant in light and dark mode
  • Expandable variants
  • Analytics passthroughs

This PR also renames the testId prop in Alert to testID to be consistent the other components and fixes one of the Button tests to use queryByText instead of the async findByText.

Note: Moved accessibility tests to #279 since we'll want to configure jest matchers

Testing Packages

N/A

Screenshots/Video

image

Testing

N/A, they're unit tests

PR Checklist

Code reviewer validation:

  • General
    • PR is linked to ticket(s)
    • PR has changelog label applied if it's to be included in the changelog
    • Acceptance criteria:
      • All satisfied or
      • Documented reason for not being performed or
      • Split to separate ticket and ticket is linked by relevant AC(s)
    • Above PR sections adequately filled out
    • If any breaking changes, in accordance with the pre-1.0.0 versioning guidelines: a CU ticket has been created for the VA Mobile App detailing necessary adjustments with the package version that will be published by this ticket
  • Code
    • Tests are included if appropriate (or split to separate ticket)
    • New functions have proper TSDoc annotations

Publish

If changes warrant a new version per the versioning guidelines and the PR is approved and ready to merge:

@narin narin marked this pull request as ready for review April 29, 2024 18:56
@narin narin requested a review from a team as a code owner April 29, 2024 18:56
@@ -45,8 +45,8 @@ describe('Button', () => {
expect(onPressSpy).toBeCalled()
})

it('should render label', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any harm in having things async even when they don't need to be?

With Link opted to have most async because I was getting confusing errors without it for some tests.

Copy link
Contributor Author

@narin narin Apr 30, 2024

Choose a reason for hiding this comment

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

I don't think so but we should avoid adding it if there's no async functions within. I think the errors might stem from some of the queries being async functions (e.g. findBy*) and some are not (queryBy*). When we add the jest matchers eslint plugin I think it provides some guidance on which ones should be used.

Copy link
Contributor

@TimRoe TimRoe left a comment

Choose a reason for hiding this comment

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

Dropping request changes to denote end of first pass--mostly just a few minor things for direct comments.

Non-direct comment: doesn't test accessibility. Seems like at a minimum should check header/description-a11yLabel overrides. Maybe should also check the icon scaling for the main icon and the chevron with its' unique behavior if we can do that around prior knowledge it renders everything at like 200% or whatever.

narin added 2 commits April 30, 2024 09:21
…te expand/collapse tests for better clarity.
…tment-of-veterans-affairs/va-mobile-library into feature/198-narin-alert-unit-tests
@narin
Copy link
Contributor Author

narin commented Apr 30, 2024

Moved accessibility tests to be a part of #279. Ready for another round of review.

@narin narin merged commit d059d29 into main Apr 30, 2024
6 of 8 checks passed
@narin narin deleted the feature/198-narin-alert-unit-tests branch April 30, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants