From ae8c383dfb4c7e7324433813799a08489938e5c8 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Wed, 23 Oct 2019 12:01:57 +0300 Subject: [PATCH] Revert "Fix Android device tests for AndroidX migration (#1125)" This reverts commit 82de3b63811a35ae9f56f3bb1018bbffddeef41f. --- __device-tests__/helpers/utils.js | 23 ++------------------- __device-tests__/pages/editor-page.js | 27 +++++++------------------ ios/gutenberg.xcodeproj/project.pbxproj | 1 - 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/__device-tests__/helpers/utils.js b/__device-tests__/helpers/utils.js index c7fe76e0fecc5..a53e7547f78d9 100644 --- a/__device-tests__/helpers/utils.js +++ b/__device-tests__/helpers/utils.js @@ -114,28 +114,9 @@ const setupDriver = async () => { await driver.setImplicitWaitTimeout( 2000 ); await timer( 3000 ); - await driver.setOrientation( 'PORTRAIT' ); - // Proxy driver to patch functions on Android - // This is needed to adapt to changes in the way accessibility ids are being - // assigned after migrating to AndroidX and React Native 0.60. See: - // https://github.com/wordpress-mobile/gutenberg-mobile/pull/1112#issuecomment-501165250 - // for more details. - return new Proxy( driver, { - get: ( original, property ) => { - const propertiesToPatch = [ - 'elementByAccessibilityId', - 'hasElementByAccessibilityId', - ]; - if ( isAndroid() && ( propertiesToPatch.includes( property ) ) ) { - return async function( value, cb ) { - // Add a comma and a space to all ids - return await original[ property ]( `${ value }, `, cb ); - }; - } - return original[ property ]; - }, - } ); + await driver.setOrientation( 'PORTRAIT' ); + return driver; }; const stopDriver = async ( driver: wd.PromiseChainWebdriver ) => { diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index 4c27c1ef70cf0..a6265fb4af903 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -21,12 +21,6 @@ export default class EditorPage { headingBlockName = 'Heading'; imageBlockName = 'Image'; - // This is needed to adapt to changes in the way accessibility ids are being - // assigned after migrating to AndroidX and React Native 0.60. See: - // https://github.com/wordpress-mobile/gutenberg-mobile/pull/1112#issuecomment-501165250 - // for more details. - accessibilityIdSuffix = ''; - constructor( driver: wd.PromiseChainWebdriver ) { this.driver = driver; this.accessibilityIdKey = 'name'; @@ -35,7 +29,6 @@ export default class EditorPage { if ( isAndroid() ) { this.accessibilityIdXPathAttrib = 'content-desc'; this.accessibilityIdKey = 'contentDescription'; - this.accessibilityIdSuffix = ', '; } } @@ -105,7 +98,7 @@ export default class EditorPage { } async getTextViewForHtmlViewContent() { - const accessibilityId = `html-view-content${ this.accessibilityIdSuffix }`; + const accessibilityId = 'html-view-content'; let blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]`; if ( ! isAndroid() ) { @@ -176,13 +169,11 @@ export default class EditorPage { if ( ! await this.hasBlockAtPosition( position, blockName ) ) { throw Error( `No Block at position ${ position }` ); } - const parentId = `${ blockName } Block. Row ${ position }.${ this.accessibilityIdSuffix }`; - const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ parentId }"]`; - const blockId = `Move block up from row ${ position } to row ${ position - 1 }${ this.accessibilityIdSuffix }`; + const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`; let blockLocator = `${ parentLocator }/following-sibling::*`; blockLocator += isAndroid() ? '' : '//*'; - blockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ blockId }"]`; + blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block up from row ${ position } to row ${ position - 1 }"]`; const moveUpButton = await this.driver.elementByXPath( blockLocator ); await moveUpButton.click(); } @@ -193,13 +184,10 @@ export default class EditorPage { throw Error( `No Block at position ${ position }` ); } - const parentId = `${ blockName } Block. Row ${ position }.`; - const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ parentId }")]`; - - const blockId = `Move block down from row ${ position } to row ${ position + 1 }${ this.accessibilityIdSuffix }`; + const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`; let blockLocator = `${ parentLocator }/following-sibling::*`; blockLocator += isAndroid() ? '' : '//*'; - blockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ blockId }"]`; + blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block down from row ${ position } to row ${ position + 1 }"]`; const moveDownButton = await this.driver.elementByXPath( blockLocator ); await moveDownButton.click(); } @@ -211,14 +199,13 @@ export default class EditorPage { throw Error( `No Block at position ${ position }` ); } - const parentId = `${ blockName } Block. Row ${ position }.`; - const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ parentId }")]`; + const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`; let removeBlockLocator = `${ parentLocator }/following-sibling::*`; removeBlockLocator += isAndroid() ? '' : '//*'; let removeButtonIdentifier = `Remove block at row ${ position }`; if ( isAndroid() ) { - removeButtonIdentifier += `, Double tap to remove the block${ this.accessibilityIdSuffix }`; + removeButtonIdentifier += ', Double tap to remove the block'; const block = await this.getBlockAtPosition( position, blockName ); let checkList = await this.driver.elementsByXPath( removeBlockLocator ); while ( checkList.length === 0 ) { diff --git a/ios/gutenberg.xcodeproj/project.pbxproj b/ios/gutenberg.xcodeproj/project.pbxproj index fcdac34d79600..66b00c63153d9 100644 --- a/ios/gutenberg.xcodeproj/project.pbxproj +++ b/ios/gutenberg.xcodeproj/project.pbxproj @@ -381,7 +381,6 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, );