Provide missing element visibility expectations API.
The Issue
While extending the toBeVisible expectation API to receive an optional parameter of visibility threshold, in response to a feature request (see issue), another missing feature was brought up for discussion, alongside some questions regarding the current API.
- The current API for visibility expectation (toBeVisible(pct?: number)) receives only integers within the range [1, 100], and checks whether the element is visible at least with the given visibility threshold, because of underlying constraints (espresso matchers) and therefore cannot be used to check whether the view has any visibility (
>0%visible), or whether is not visible at all. - Negating the expectation with
not, creates a confusing statement since it is quite nonintuitive what is the expected result (for example,not.toBeVisible(10), this expects the view to have less than 10% visibility). - The current API name for the expectation does not implies that the
pctargument is a threshold, and that the check includes the threshold as a valid visibility percentage (at-leastN%visible, and not greater-thanN%visible). - The default value of the visibility threshold is
75, which is also very nonintuitive or makes any sense.
Suggested Solution
Add new APIs for visibility expectations, to allow any kind of visibility check with more descriptive names, and to deprecated the current method.
(1) toHaveVisibility(): checks whether the element is visible at all (the visibility percent is greater than 0%).
(2) toHaveVisibilityGreaterThan(percent): checks whether the element visibility percent is greater than percent.
(3) toHaveVisibilityGreaterThanOrEqualTo(percent): checks whether the element visibility percent is greater than or equal to percent.
Also, if we want to achieve an even higher level of readability in the tests, we can also provide aliases for the negations of (2) and (3):
(4) toHaveVisibilityLowerThan(percent): checks whether the element visibility percent is lower than percent.
(5) toHaveVisibilityLowerThanOrEqualTo(percent): checks whether the element visibility percent is lower than or equal to percent.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this reporsitory, read this discussion.
The issue has been closed for inactivity.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this reporsitory, read this discussion.
The issue has been closed for inactivity.
@noomorph, @jonathanmos, @d4vidi – could you go over this proposal in async mode and tell what do you think, and suggest alternatives if some points don't look good enough?
Putting this into status: discussion.
I'm inclined to say an async discussion wouldn't be very productive in this case. I think we should leave any such discussions for when things materialize such that it work on this would in fact become tangible (e.g. prioritized by us / picked up by the community) - in which case the owner could set up a discussion in sync-mode (meeting/live chat)