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

[Android] ActivityIndicator: setting resource-id from the testID prop #48271

Conversation

mateoguzmana
Copy link
Contributor

@mateoguzmana mateoguzmana commented Dec 14, 2024

Summary:

Fixes #39092

Right now, the testID prop that is passed to the ActivityIndicator component is not being applied as a resource-id. In this PR, we overwrite the onInitializeAccessibilityNodeInfo in the ProgressBarContainerView to set this resource-id.

Changelog:

[ANDROID][ADDED] - ActivityIndicator: setting resource-id from the testID prop

Test Plan:

Render a simple activity indicator and pass a testID as follows:

import {ActivityIndicator} from 'react-native';

function Playground() {
  return (
    <ActivityIndicator
      color="white"
      testID="default_activity_indicator"
      accessibilityLabel="Wait for content to load!"
    />
  );
}
Inspect the element using an e2e tool such as Maestro or Appium, the `resource-id` is not present: (see screenshot) image

Apply the changes and then:

Inspect again, the `resource-id` is present now: (see screenshot) image

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 14, 2024
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 14, 2024
@mateoguzmana mateoguzmana changed the title [Android] ActivityIndicator: setting resource-id from the testID prop [Android] ActivityIndicator: setting resource-id from the testID prop Dec 14, 2024
@mateoguzmana mateoguzmana force-pushed the fix/android-activity-indicator-test-id branch from bdb2f31 to d5a918f Compare December 15, 2024 23:42
@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 16, 2024
@facebook-github-bot
Copy link
Contributor

@javache merged this pull request in 87b1bad.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @mateoguzmana in 87b1bad

When will my fix make it into a release? | How to file a pick request?

facebook-github-bot pushed a commit that referenced this pull request Dec 19, 2024
Summary:
Follow up from #48271 and #48254, I noticed that the Modal component also doesn't map the `resource-id` from the `testID` on Android. This PR addresses that.

## Changelog:

[ANDROID] [FIXED] - Modal: Setting `resource-id` from `testID` prop

Pull Request resolved: #48313

Test Plan:
Alternatively do:
```
$ adb shell uiautomator dump
UI hierchary dumped to: /sdcard/window_dump.xml
$ adb pull /sdcard/window_dump.xml
/sdcard/window_dump.xml: 1 file pulled, 0 skipped. 1.1 MB/s (3505 bytes in 0.003s)
```
and check in XML: ` resource-id="playground-modal"  class="android.view.ViewGroup" `
-------
Using Appium, check that the `testID` prop passed from JS is mapped as `resource-id` in the rendered view group of the Modal.

<details>
<summary>Example of the code implementation in the RNTester Playground:</summary>

```tsx
function Playground() {
  const [modalVisible, setModalVisible] = React.useState(false);

  return (
    <>
      <Modal
        visible={modalVisible}
        testID="playground-modal">
        <Text testID="inner-text-test-id">Hello World!</Text>
      </Modal>

      <Button
        title="Open Modal"
        onPress={() => {
          setModalVisible(true);
        }}
      />
    </>
  );
}
```
</details>

<details>
<summary>Output in Appium Inspector:</summary>

<img width="913" alt="image" src="https://github.com/user-attachments/assets/514ae2b3-35a8-4a1a-8efc-1ca6bd73f189" />

</details>

Reviewed By: javache

Differential Revision: D67369350

Pulled By: alanleedev

fbshipit-source-id: a799ad5b974895a39d9287e3d76d1139a6ef6a83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] TestID for Activity Indicator component is not visible
4 participants