mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: testID property for use with e2e testing without interfering with a11y (#9793)
* fix(android): nested frames were sometimes not recreated (#9748) Co-authored-by: Eduardo Speroni <edusperoni@gmail.com> * feat: testID property for use with e2e testing without interfering with a11y * feat: better testID support along a11y wip * fix: make sure we have a defined id * feat: --env.e2e to enable testID * chore: return if using testID * chore: cleanup Co-authored-by: Eduardo Speroni <edusperoni@gmail.com> Co-authored-by: Igor Randjelovic <rigor789@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import { layout } from '../../utils';
|
||||
import { isString, isNullOrUndefined } from '../../utils/types';
|
||||
import { accessibilityIdentifierProperty } from '../../accessibility/accessibility-properties';
|
||||
import * as Utils from '../../utils';
|
||||
import { testIDProperty } from '../../ui/core/view';
|
||||
|
||||
export * from './text-base-common';
|
||||
|
||||
@@ -443,13 +444,21 @@ export class TextBase extends TextBaseCommon {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeTextViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
|
||||
}
|
||||
|
||||
[accessibilityIdentifierProperty.setNative](value: string): void {
|
||||
// we override the default setter to apply it on nativeTextViewProtected
|
||||
const id = Utils.ad.resources.getId(':id/nativescript_accessibility_id');
|
||||
[testIDProperty.setNative](value: string): void {
|
||||
this.setTestID(this.nativeTextViewProtected, value);
|
||||
}
|
||||
|
||||
if (id) {
|
||||
this.nativeTextViewProtected.setTag(id, value);
|
||||
this.nativeTextViewProtected.setTag(value);
|
||||
[accessibilityIdentifierProperty.setNative](value: string): void {
|
||||
if (typeof __USE_TEST_ID__ !== 'undefined' && __USE_TEST_ID__ && this.testID) {
|
||||
// ignore when using testID;
|
||||
} else {
|
||||
// we override the default setter to apply it on nativeTextViewProtected
|
||||
const id = Utils.ad.resources.getId(':id/nativescript_accessibility_id');
|
||||
|
||||
if (id) {
|
||||
this.nativeTextViewProtected.setTag(id, value);
|
||||
this.nativeTextViewProtected.setTag(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user