-
Notifications
You must be signed in to change notification settings - Fork 273
feat: ...byRole type queries accepts second arg #875
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
Conversation
ca7b4c7
to
ea68aa1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's a good direction. Please take a look at 31ef0b9 to see how to resolve API changes in a backward compatible way
…react-native-testing-library into feat/by-role-second-arg
@kiranjd is it something you're still interested in getting in? This is a feature that is clearly lacking for our current API, and I'd love to help you getting that in a mergeable state. |
@AugustinLF Missed following up on this. I remember I had a few questions. I'll post the questions and follow it up to finish within this week. Thank you 🙏 |
src/helpers/makeA11yQuery.js
Outdated
import type { WaitForOptions } from '../waitFor'; | ||
import { | ||
ErrorWithStack, | ||
prepareErrorMessage, | ||
createQueryByError, | ||
} from './errors'; | ||
|
||
type QueryOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name in QueryOptions
type for getBy
is optional. But, it's a must for the function, filterWithName
. Is this duplication that I get rid of or is this okay?
(I haven't worked with types all that much 😬 )
- adds tests for deprecations - change second param on findBy queries
…ing-library into feat/by-role-second-arg
291ebcc
to
a5f168c
Compare
'interval', | ||
'stackTraceError', | ||
]; | ||
const warnDeprectedWaitForOptionsUsage = (queryOptions?: WaitForOptions) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const warnDeprectedWaitForOptionsUsage = (queryOptions?: WaitForOptions) => { | |
const warnDeprecatedWaitForOptionsUsage = (queryOptions?: WaitForOptions) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also pls move it to helpers/errors.ts
, as this looks like reusable function that can be used with other findByXxx
queries if they decide to go with query options.
@kiranjd Do you need any help, is there anything I can do to help you getting that in? :) |
@@ -19,6 +47,10 @@ type QueryAllReturn = Array<ReactTestInstance>; | |||
type FindReturn = Promise<GetReturn>; | |||
type FindAllReturn = Promise<GetAllReturn>; | |||
|
|||
export type QueryOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type should be renamed to ByRoleOptions
bacause this type of option is only relevant to byRole
queries.
isNodeValid(node) && matcherFn(node.props[name], matcher); | ||
|
||
return ( | ||
matchesRole && !!getQueriesForElement(node).queryByText(options.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we should match for either queryByText(options.name)
or queryByLabelText(options.name)
@@ -31,8 +65,27 @@ const makeA11yQuery = <P extends unknown, M extends unknown>( | |||
queryNames: QueryNames, | |||
matcherFn: (prop: P, value: M) => boolean | |||
) => (instance: ReactTestInstance) => { | |||
const getBy = (matcher: M) => { | |||
const filterWithName = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested name filterByAccessibilityName
Let's pause this PR for couple of days till we get a11y query reorganisation from #325 done. This should allow for easy separate query options type per each query, so that the |
Yes, those changes caused lot of conflicts
On Wed, 4 May 2022 at 3:58 PM, Maciej Jastrzebski ***@***.***> wrote:
Let's pause this PR for couple of days till we get a11y query
reorganisation from #325
<#325>
done. This should allow for easy separate query options type per each
query, so that the name options will be allowed only for byRole queries
and not all a11y queries.
—
Reply to this email directly, view it on GitHub
<#875 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGFANA3PQMXZBXCJ744WUCDVIJGMTANCNFSM5JHKFNKQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Kiran JD
|
@mdjastrzebski is this a good time to take this PR further? If so, should I raise a separate PR to continue the work? |
@kiranjd I feel like yes we should be able to start working on that once again. I'd however wait for the go from @mdjastrzebski who might have something else planned before that. Nonetheless, feel free to let me know if you need any help on that, I'm very keen in getting this one in. |
@kiranjd go ahead 👍🏻 Now is the right time to work on this PR, as we've got a11y properly refactored. |
@kiranjd is there anything we can do to help you to get that in? It'd bring so much value, I'm really looking to get that one in <3 |
@AugustinLF Thanks for the support. I will work on this and hopefully get this in a mergeable state by this weekend 🤞🏻 |
@kiranjd if you're short on time to finish this PR I can definitely help fixing the last few things to get it merged, let me know if you want help :) |
@AugustinLF Have tried to redo the changes from the last state when it was working. There seems to be a lot of refactoring undergone in the meanwhile. |
@kiranjd yeah RNTL codebase did move a lot since the original PR submission :-) @AugustinLF I would be great if you could help to move this forward, as |
This PR has been rebased and updated by @AugustinLF as #1127. Thank you @kiranjd 👏🏻 for the initial implementation! |
Closes #827
Summary
Test plan