Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: testID property for use with e2e testing without interfering with a11y #9793

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

Merged
merged 7 commits into from
Mar 8, 2022

Conversation

NathanWalker
Copy link
Contributor

@NathanWalker NathanWalker commented Feb 23, 2022

PR Checklist

What is the current behavior?

Using automationText for e2e testing interferes with a11y.

What is the new behavior?

Adds a new testID property matching what the React Native community adopted, also reference api here which helps discern e2e testing id's apart from anything specific to a11y.

  • confirm when set if it should modify any other behavior to achieve what's needed for clear e2e testing

@NathanWalker NathanWalker added this to the 8.2 milestone Feb 23, 2022
@cla-bot cla-bot bot added the cla: yes label Feb 23, 2022
@rigor789 rigor789 force-pushed the feat/test-id-property branch from ea6262b to f56d7c9 Compare March 3, 2022 18:33
@rigor789 rigor789 force-pushed the feat/test-id-property branch from f56d7c9 to 803553a Compare March 3, 2022 18:35
@rigor789 rigor789 marked this pull request as draft March 3, 2022 20:29
@rigor789
Copy link
Member

rigor789 commented Mar 3, 2022

Marked as WIP - still need to do a cleanup pass and run a few more tests with both appium and detox.

@farfromrefug
Copy link
Collaborator

@NathanWalker seems quite good to me.
One question i have is are we sure this:

if (typeof __USE_TEST_ID__ !== 'undefined' && __USE_TEST_ID__ && this.testID) {
...
}

is removed if __USE_TEST_ID__ is not defined and is transformed to if (this.testID) {..} if set ?

It is worth testing to ensure the code is removed completely

@rigor789
Copy link
Member

rigor789 commented Mar 7, 2022

@farfromrefug I'll be checking that - just got a detox demo set up, still need an appium one to check all cases - and then clean up anything that can be cleaned up...

If that doesn't get tree-shaken, I'll just drop the typeof check - since we'll be setting it in webpack by default to false (unless --env.e2e).

@NathanWalker NathanWalker marked this pull request as ready for review March 8, 2022 16:45
@rigor789
Copy link
Member

rigor789 commented Mar 8, 2022

@farfromrefug seems to be tree-shaken away just fine!

// default

    [_view_common__WEBPACK_IMPORTED_MODULE_0__.testIDProperty.setNative](value) {
        this.setTestID(this.nativeViewProtected, value);
    }
    setTestID(view, value) {
        if (false) {}
    }
// with --env.e2e

    [_view_common__WEBPACK_IMPORTED_MODULE_0__.testIDProperty.setNative](value) {
        this.setTestID(this.nativeViewProtected, value);
    }
    setTestID(view, value) {
        if (true) {
            const id = _utils__WEBPACK_IMPORTED_MODULE_11__.ad.resources.getId(':id/nativescript_accessibility_id');
            if (id) {
                view.setTag(id, value);
                view.setTag(value);
            }
            view.setContentDescription(value);
        }
    }

@farfromrefug
Copy link
Collaborator

@rigor789 very good! very good to know we write something like this 😃

@rigor789 rigor789 merged commit 8be543b into release/8.2.0 Mar 8, 2022
@rigor789 rigor789 deleted the feat/test-id-property branch March 8, 2022 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants