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 #330

Merged
merged 1 commit into from
Nov 21, 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.

Security

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 force-pushed the feat/adds-find-all-selectors-to-test-utils branch 4 times, most recently from 57fb6bc to 274c1dd Compare November 20, 2024 13:16
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.59%. Comparing base (97dee37) to head (91a1d0f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
- Coverage   93.97%   93.59%   -0.38%     
==========================================
  Files          61       61              
  Lines        4312     4312              
  Branches      532      737     +205     
==========================================
- Hits         4052     4036      -16     
- Misses        260      276      +16     

☔ 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:35
@orangevolon orangevolon requested a review from a team as a code owner November 20, 2024 13:35
@orangevolon orangevolon requested review from pan-kot and removed request for a team November 20, 2024 13:35
@@ -1,16 +1,126 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe the test-utils core?

Copy link
Contributor Author

@orangevolon orangevolon Nov 20, 2024

Choose a reason for hiding this comment

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

I assume you mean the whole file. For that the answer is yes, we can. There are minor differences between components and other three repos but I think it's totally doable.

There's also a lot more that we can centralize between the four repos, but IMO we need to discuss this in a separate thread.


function getComponentSelectors(componentName: string) {
const componentNamePascalCase = pascalCase(componentName);
const findAllRegex = new RegExp(`findAll${componentNamePascalCase}.*`);
Copy link
Member

Choose a reason for hiding this comment

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

There is a lot of transformations happening for a test file. Wouldn't it be better straightforward to have some mapping instead, like:

const components = [
  {
    name: 'Board',
    component: components.Board,
    findName: 'findBoard',
    findAllName: 'findAllBoard',
  },
]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whatever practice we go for, we need to make it consistent all across the repos. So gotta have the map also in the components repo and three other repos as well.

I agree with the concern, but I think we need to fix this a bit differently and outside of the scope of this PR.


function getComponentSelectors(componentName: string) {
const componentNamePascalCase = pascalCase(componentName);
const findAllRegex = new RegExp(`findAll${componentNamePascalCase}.*`);
Copy link
Member

Choose a reason for hiding this comment

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

Why is regex needed? Can a string comparison like target === findAll${componentNamePascalCase} work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pluralization. findAlert --> findAlerts

Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks

@orangevolon orangevolon requested a review from pan-kot November 20, 2024 14:11

function getComponentSelectors(componentName: string) {
const componentNamePascalCase = pascalCase(componentName);
const findAllRegex = new RegExp(`findAll${componentNamePascalCase}.*`);
Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks

@orangevolon orangevolon added this pull request to the merge queue Nov 21, 2024
Merged via the queue into main with commit 4a5fb2a Nov 21, 2024
38 of 39 checks passed
@orangevolon orangevolon deleted the feat/adds-find-all-selectors-to-test-utils branch November 21, 2024 12:37
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