From 43238b00601869f60b2f9869d2163c58b262bba2 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Tue, 26 Oct 2021 13:05:30 +0300 Subject: [PATCH 1/2] Look for newly available blocks too --- .../__device-tests__/pages/editor-page.js | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index a59297bd5dd589..8bc6c1ab358182 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -300,6 +300,7 @@ class EditorPage { // Attempts to find the given block button in the block inserter control. async findBlockButton( blockName ) { const blockAccessibilityLabel = `${ blockName } block`; + const blockAccessibilityLabelNewBlock = `${ blockAccessibilityLabel }, newly available`; if ( isAndroid() ) { const size = await this.driver.getWindowSize(); @@ -308,6 +309,9 @@ class EditorPage { while ( ! ( await this.driver.hasElementByAccessibilityId( blockAccessibilityLabel + ) ) && + ! ( await this.driver.hasElementByAccessibilityId( + blockAccessibilityLabelNewBlock ) ) ) { swipeFromTo( @@ -317,14 +321,31 @@ class EditorPage { ); } - return await this.driver.elementByAccessibilityId( - blockAccessibilityLabel - ); + if ( + await this.driver.hasElementByAccessibilityId( + blockAccessibilityLabel + ) + ) { + return await this.driver.elementByAccessibilityId( + blockAccessibilityLabel + ); + } else { + return await this.driver.elementByAccessibilityId( + blockAccessibilityLabelNewBlock + ); + } } - const blockButton = await this.driver.elementByAccessibilityId( - blockAccessibilityLabel - ); + const blockButton = ( await this.driver.hasElementByAccessibilityId( + blockAccessibilityLabelNewBlock + ) ) + ? await this.driver.elementByAccessibilityId( + blockAccessibilityLabelNewBlock + ) + : await this.driver.elementByAccessibilityId( + blockAccessibilityLabel + ); + const size = await this.driver.getWindowSize(); // The virtual home button covers the bottom 34 in portrait and 21 on landscape on iOS. // We start dragging a bit above it to not trigger home button. From 9657f696be15bdb4e026c4dcce1a833618a960b8 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Tue, 26 Oct 2021 13:17:57 +0300 Subject: [PATCH 2/2] Fix lint issue, no need for else --- .../__device-tests__/pages/editor-page.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index 8bc6c1ab358182..35a3cf2ea510b5 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -323,17 +323,17 @@ class EditorPage { if ( await this.driver.hasElementByAccessibilityId( - blockAccessibilityLabel + blockAccessibilityLabelNewBlock ) ) { - return await this.driver.elementByAccessibilityId( - blockAccessibilityLabel - ); - } else { return await this.driver.elementByAccessibilityId( blockAccessibilityLabelNewBlock ); } + + return await this.driver.elementByAccessibilityId( + blockAccessibilityLabel + ); } const blockButton = ( await this.driver.hasElementByAccessibilityId(