diff --git a/packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion-2.test.js b/packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion-2.test.js index e86439f20de16..44cc767ec5bfc 100644 --- a/packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion-2.test.js +++ b/packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion-2.test.js @@ -10,6 +10,7 @@ import { paragraphBlockEmpty, separatorBlockEmpty, } from './helpers/test-data'; +import { waitForMediaLibrary } from './helpers/utils'; describe( 'Gutenberg Editor tests for Block insertion 2', () => { it( 'adds new block at the end of post', async () => { @@ -65,14 +66,15 @@ describe( 'Gutenberg Editor tests for Block insertion 2', () => { await editorPage.addNewBlock( blockNames.image, 'before' ); + await waitForMediaLibrary( editorPage.driver ); + await editorPage.closePicker(); + const imageBlock = await editorPage.getBlockAtPosition( blockNames.image, 2 ); expect( imageBlock ).toBeTruthy(); - await editorPage.closePicker(); - const expectedHtml = [ headerBlockEmpty, imageBlockEmpty, diff --git a/packages/react-native-editor/__device-tests__/helpers/utils.js b/packages/react-native-editor/__device-tests__/helpers/utils.js index 64d802f30dbec..93f4e008ac0ed 100644 --- a/packages/react-native-editor/__device-tests__/helpers/utils.js +++ b/packages/react-native-editor/__device-tests__/helpers/utils.js @@ -313,12 +313,17 @@ const clickElementOutsideOfTextInput = async ( driver, element ) => { }; // Long press to activate context menu. -const longPressMiddleOfElement = async ( driver, element ) => { +const longPressMiddleOfElement = async ( + driver, + element, + customElementSize +) => { const location = await element.getLocation(); - const size = await element.getSize(); + const size = customElementSize || ( await element.getSize() ); const x = location.x + size.width / 2; const y = location.y + size.height / 2; + const action = new wd.TouchAction( driver ) .longPress( { x, y } ) .wait( 5000 ) // Setting to wait a bit longer because this is failing more frequently on the CI 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 2f5aae6de9cbf..c7e6e6fe1f18d 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -305,7 +305,17 @@ class EditorPage { ); if ( relativePosition === 'before' ) { - await longPressMiddleOfElement( this.driver, addButton ); + // On Android it doesn't get the right size of the button + const customElementSize = { + width: 43, + height: 43, + }; + + await longPressMiddleOfElement( + this.driver, + addButton, + customElementSize + ); const addBlockBeforeButtonLocator = isAndroid() ? '//android.widget.Button[@content-desc="Add Block Before"]' : '//XCUIElementTypeButton[@name="Add Block Before"]';