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

@remote-ui/testing: Fix debug to filter props according to all option #169

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

jackokerman-stripe
Copy link
Contributor

The object returned from mount has a debug method that is supposed to accept an all option according to the linked @shopify/react-testing docs (This option is actually called allProps in @shopify/react-testing which is potentially confusing). This adds the filtering behavior described in the docs so that className, aria-*, and data-* prop names are omitted by default, but included it the { all: true } option is passed in.

@ghost ghost added the cla-needed label Jul 7, 2022
Copy link
Member

@lemonmade lemonmade left a comment

Choose a reason for hiding this comment

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

Just one comment on an existing bit of code, but otherwise this change LGTM!

return !/^(className)$|^(aria|data)-/.test(key);
})
.reduce<string[]>((list, key) => {
if (!key) {
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we had this condition before, but do you know when it can actually happen? It seems like key would always be defined, so this would only trip up on '', which shouldn't be a key name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this was here before, but I think you're right that key should always be truthy and this condition will never be hit. Even if there was node that somehow used 0 or undefined as a prop, these would come through non-empty truthy strings from Object.keys.

@lemonmade
Copy link
Member

@jackokerman-stripe you'll also need to sign the CLA (let me know if you have any issues with process).

Copy link
Contributor Author

@jackokerman-stripe jackokerman-stripe left a comment

Choose a reason for hiding this comment

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

@jackokerman-stripe you'll also need to sign the CLA (let me know if you have any issues with process).

Last week I emailed shopify-cla@shopify.com to get myself and @tennhard-stripe added to the existing CLA that Stripe has. Is there anything else I need to do?

return !/^(className)$|^(aria|data)-/.test(key);
})
.reduce<string[]>((list, key) => {
if (!key) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this was here before, but I think you're right that key should always be truthy and this condition will never be hit. Even if there was node that somehow used 0 or undefined as a prop, these would come through non-empty truthy strings from Object.keys.

@jackokerman-stripe
Copy link
Contributor Author

jackokerman-stripe commented Jul 27, 2022

@lemonmade I finally got the CLA sorted out. Let me know your thoughts on the key check — I think you're right that key will always be defined, but I'd probably keep the check just to be safe/avoid making unnecessary changes, and because it looks like it was pulled in from @shopify/react-testing.

@lemonmade lemonmade merged commit cf229d1 into Shopify:main Sep 13, 2022
@lemonmade
Copy link
Member

Sorry it took me so long to get around to this. Thank you for getting it all in a good state, will release this in @remote-ui/testing@1.3.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