Skip to content

feat(native): Add toBeVisible #145

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kdquistanchala
Copy link
Contributor

This PR adds the toBeVisible matcher for React Native

@kdquistanchala kdquistanchala changed the base branch from main to feat/native-to-be-empty March 21, 2025 22:13
@kdquistanchala kdquistanchala self-assigned this Mar 24, 2025
@kdquistanchala kdquistanchala added the enhancement New feature or request label Mar 24, 2025
@kdquistanchala kdquistanchala requested a review from suany0805 April 3, 2025 21:15
Copy link
Member

@JoseLion JoseLion left a comment

Choose a reason for hiding this comment

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

Looks good so far! I left a few suggestion, let me know if you have any question 🙂

Base automatically changed from feat/native-to-be-empty to main April 25, 2025 17:51
@kdquistanchala kdquistanchala force-pushed the feat/native-to-be-visible branch from 35e5052 to 82fa78b Compare April 25, 2025 18:41
@kdquistanchala kdquistanchala requested a review from JoseLion April 25, 2025 20:54
Copy link
Contributor

@lopenchi lopenchi left a comment

Choose a reason for hiding this comment

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

LGTM!

@lopenchi lopenchi force-pushed the feat/native-to-be-visible branch from 4cfe69c to dcded59 Compare July 14, 2025 21:42
Copy link
Member

@JoseLion JoseLion left a comment

Choose a reason for hiding this comment

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

Looking great! I left a couple of comments to help make the code easier to understand. Let me know what you think!

@@ -42,7 +42,7 @@ export class ElementAssertion extends Assertion<ReactTestInstance> {
}

/**
* Check if the component is enabled.
* Check if the component is enabled and has not been disabled by an ancestor.
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

});

return this.execute({
assertWhen: this.isElementVisible(this.actual) && !this.isAncestorNotVisible(this.actual),
Copy link
Member

Choose a reason for hiding this comment

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

I' reading the second condition like "...and not is ancestor not visible" which is weird 😅 Would it make more sense to invert the logic of the function and change it's name to isAncestorVisible(..)?

private isElementVisible(element: ReactTestInstance): boolean {
const { type } = element;
const elementType = type.toString();
if (elementType === "Modal" && !element?.props?.visible === true) {
Copy link
Member

Choose a reason for hiding this comment

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

!element?.props?.visible === true

This one is also very hard to read. So we first negate the value of an optional prop and the compare it to true? 😖 Is there a better way to write this condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants