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

fix(testing): e2e flag no longer needed, testID is now applicable in dev or prod builds #10396

Merged
merged 3 commits into from Oct 4, 2023

Conversation

canmertc
Copy link
Contributor

@canmertc canmertc commented Oct 3, 2023

PR Checklist

What is the current behavior?

  • It is not possible to test an accessibility-enabled app by using the same build. Currently, it needs to be passed --env.e2e that enables testID and blocks accessibility features before building for testing. Passing this argument is needed because View.setContentDescription method which is also used by TalkBack to announce items is also used in testID property's Android implementation to store the view identifier.
  • Maestro (testing framework) is not able to select items by their id.
// Android

<Label text="My Button" testID="my-button" />

// not working
- assertVisible:
     id: "my-button"
     
// not working
- assertVisible:
     text: "My Button"
     
// working (but it shouldn't work this way)
- assertVisible:
     text: "my-button"
 
// working (but it shouldn't work this way)
- assertVisible: "my-button"

What is the new behavior?

  • AccessibilityNodeInfo.setViewIdResourceName is used to set resource id instead of View.setContentDescription that sets content description on Android.
  • No need to pass --env.e2e anymore. So the production builds can now be tested.
  • accessibilityIdentifier will be the source of truth. Setting testID property will also set accessibilityIdentifier. But setting accessibilityIdentifier property will update testID only if there is a testID already set and has a different value.
  • Maestro is now able to select items by their id and text
// Android

<Label text="My Button" testID="my-button" />

// working
- assertVisible:
     id: "my-button"
     
// working
- assertVisible:
     text: "My Button"
     
// working
- assertVisible:
     id: "my-button"
     text: "My Button"
 
// working
- assertVisible: "My Button"

- change testID to use resource id instead of content description (Android)
- remove need of passing `--env.e2e`
- `testID` property will also set `accessibilityIdentifier`. But `accessibilityIdentifier` property will set `testID` only if there is a `testID` already set.
@cla-bot cla-bot bot added the cla: yes label Oct 3, 2023
NathanWalker
NathanWalker previously approved these changes Oct 3, 2023
Copy link
Contributor

@NathanWalker NathanWalker left a comment

Choose a reason for hiding this comment

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

Brilliant work, thank you @canmertc

@NathanWalker NathanWalker changed the title fix(core): use the same build for testing fix(testing): e2e flag no longer needed, testID is now applicable in dev or prod builds Oct 3, 2023
@NathanWalker NathanWalker merged commit 0a2b220 into NativeScript:main Oct 4, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants