diff --git a/packages/react-native-editor/__device-tests__/helpers/caps.js b/packages/react-native-editor/__device-tests__/helpers/caps.js index 818a444c41bdf4..4ac431fb239e55 100644 --- a/packages/react-native-editor/__device-tests__/helpers/caps.js +++ b/packages/react-native-editor/__device-tests__/helpers/caps.js @@ -11,6 +11,7 @@ const ios = { exports.iosLocal = ( { iPadDevice = false } ) => ( { ...ios, deviceName: ! iPadDevice ? 'iPhone 13' : 'iPad Pro (9.7-inch)', + pixelRatio: ! iPadDevice ? 3 : 2, usePrebuiltWDA: true, } ); @@ -19,6 +20,7 @@ exports.iosServer = ( { iPadDevice = false } ) => ( { deviceName: ! iPadDevice ? 'iPhone 13 Simulator' : 'iPad Pro (9.7 inch) Simulator', + pixelRatio: ! iPadDevice ? 3 : 2, } ); exports.android = { diff --git a/packages/react-native-editor/__device-tests__/helpers/utils.js b/packages/react-native-editor/__device-tests__/helpers/utils.js index c5519cee3dea22..f81902f9afa1d4 100644 --- a/packages/react-native-editor/__device-tests__/helpers/utils.js +++ b/packages/react-native-editor/__device-tests__/helpers/utils.js @@ -448,28 +448,18 @@ const swipeFromTo = async ( driver, from = defaultCoordinates, to = defaultCoordinates, - delay + delay = 0 ) => - driver.touchPerform( [ - { - action: 'press', - options: from, - }, - { - action: 'wait', - options: { - ms: delay, - }, - }, - { - action: 'moveTo', - options: to, - }, - { - action: 'release', - options: {}, - }, - ] ); + await driver + .action( 'pointer', { + parameters: { pointerType: 'touch' }, + } ) + .move( { ...from, duration: 0 } ) + .down( { button: 0 } ) + .move( { ...to, duration: 300 } ) + .up( { button: 0 } ) + .pause( delay ) + .perform(); // Starts from the middle of the screen and swipes downwards const swipeDown = async ( driver, delay = 3000 ) => { @@ -569,16 +559,18 @@ const toggleOrientation = async ( driver ) => { */ const toggleDarkMode = ( driver, darkMode = true ) => { if ( isAndroid() ) { - return driver.execute( 'mobile: shell', [ + return driver.executeScript( 'mobile: shell', [ { command: `cmd uimode night ${ darkMode ? 'yes' : 'no' }`, }, ] ); } - return driver.execute( 'mobile: setAppearance', { - style: darkMode ? 'dark' : 'light', - } ); + return driver.executeScript( 'mobile: setAppearance', [ + { + style: darkMode ? 'dark' : 'light', + }, + ] ); }; const isEditorVisible = async ( driver ) => { 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 2a95d0324480a1..216ff50c419d58 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -67,8 +67,7 @@ class EditorPage { } async getAddBlockButton() { - const elements = - await this.driver.elementsByAccessibilityId( ADD_BLOCK_ID ); + const elements = await this.driver.$$( `~${ ADD_BLOCK_ID }` ); return elements[ 0 ]; } @@ -302,7 +301,10 @@ class EditorPage { async waitForKeyboardToBeHidden() { const { addButtonLocation } = this.initialValues; const addButton = await this.getAddBlockButton(); - const location = await addButton.getLocation(); + let location; + if ( addButton ) { + location = await addButton.getLocation(); + } let YLocation = addButtonLocation?.y; const currentOrientation = await this.driver.getOrientation(); const isLandscape = currentOrientation === 'LANDSCAPE'; @@ -316,7 +318,7 @@ class EditorPage { ); } - if ( location.y < YLocation ) { + if ( ! addButton || location?.y < YLocation ) { await this.waitForKeyboardToBeHidden(); } }