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

feat: Adds findAll finder to test utils #53

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

orangevolon
Copy link
Contributor

@orangevolon orangevolon commented Nov 19, 2024

Description

Adds two findAll[COMPONENT_NAME]s() test utils selectors to each component wrapper.
Similar to: cloudscape-design/components#3024

Depends on cloudscape-design/test-utils#74

Related links, issue #, if available: Test utils API improvements project

How has this been tested?

✅ Copies including the JSDocs and the pluralizations have been reviewed by the content team.
🧪 Unit tests added to both selectors and dom test utils.

Related links, issue #, if available: Test utils API improvements project

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@orangevolon orangevolon changed the title feat: Adds findAll finder function feat: Adds findAll finder to test utils Nov 19, 2024
@orangevolon orangevolon force-pushed the feat/adds-find-all-selectors-to-test-utils branch 3 times, most recently from a8e1435 to 2337d60 Compare November 20, 2024 13:06
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2aa88d5) to head (0610b55).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #53   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines          348       348           
  Branches        31        31           
=========================================
  Hits           348       348           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@orangevolon orangevolon marked this pull request as ready for review November 20, 2024 13:16
@orangevolon orangevolon requested a review from a team as a code owner November 20, 2024 13:16
@orangevolon orangevolon requested review from YueyingLu and removed request for a team November 20, 2024 13:16
// Every component has the same set of selector functions.
// For this reason, casting the function names into the Alert component.
const findName = `find${componentNamePascalCase}` as "findCodeView";
const findAllName = wrapperPropsList.find((selector) => findAllRegex.test(selector)) as "findAllCodeViews";
Copy link
Member

Choose a reason for hiding this comment

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

Why here the type of findName and findAllName as "findCodeView"? Can it be other component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for simplification. All of the findAllXX and findXX behave exactly the same. So casting it into one of them is enough for this test. Otherwise there's nothing special about CodeViews. It can be any other component from this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also fixed the comment above ✅

},
];

function renderComponents(componentName: string, props = RENDER_COMPONENTS_DEFAULT_PROPS) {
Copy link
Member

Choose a reason for hiding this comment

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

Will we extend it to more than CodeView? What to do if different components need different props?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have the same pattern in all of the repos (except components), which we read the needed props from defaultProps file (Line 25).

@orangevolon orangevolon added this pull request to the merge queue Nov 20, 2024
Merged via the queue into main with commit f12b6cc Nov 20, 2024
39 checks passed
@orangevolon orangevolon deleted the feat/adds-find-all-selectors-to-test-utils branch November 20, 2024 16:15
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.

2 participants