Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint fixes
  • Loading branch information
jostnes committed May 10, 2022
commit 6a9dae269c924409694c01400f825c1cadb1771c
26 changes: 5 additions & 21 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,7 @@ const waitForMediaLibrary = async ( driver ) => {
* @param {string} elementLocator
* @param {number} iteration - Default value is 0
*/
const waitForVisible = async (
driver,
elementLocator,
iteration = 0
) => {
const waitForVisible = async ( driver, elementLocator, iteration = 0 ) => {
const maxIteration = 25;
const timeout = 1000;

Expand All @@ -490,21 +486,13 @@ const waitForVisible = async (
const locator = await driver.elementsByXPath( elementLocator );
if ( locator.length !== 1 ) {
// if locator is not visible, try again
return waitForVisible(
driver,
elementLocator,
iteration + 1
);
return waitForVisible( driver, elementLocator, iteration + 1 );
}

return locator[ 0 ];
};

const isElementVisible = async (
driver,
elementLocator,
iteration = 0
) => {
const isElementVisible = async ( driver, elementLocator, iteration = 0 ) => {
const maxIteration = 5;
const timeout = 1000;

Expand All @@ -519,15 +507,11 @@ const isElementVisible = async (
const locator = await driver.elementsByXPath( elementLocator );
if ( locator.length !== 1 ) {
// if locator is not visible, try again
return waitForVisible(
driver,
elementLocator,
iteration + 1
);
return waitForVisible( driver, elementLocator, iteration + 1 );
}

return true;
}
};

module.exports = {
backspace,
Expand Down
32 changes: 17 additions & 15 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,19 @@ class EditorPage {
// List Block functions
// =========================

async getListBlockAtPosition( position = 1, options = { isEmptyBlock: false } ) {

async getListBlockAtPosition(
position = 1,
options = { isEmptyBlock: false }
) {
// Go to the correct list at position
const listBlockPositionLocator = isAndroid()
const listBlockPositionLocator = isAndroid()
? `//android.view.ViewGroup[@content-desc="List Block. Row ${ position }"]`
: `(//XCUIElementTypeOther[contains(@name, "List Block. Row ${ position }")])[5]`
: `(//XCUIElementTypeOther[contains(@name, "List Block. Row ${ position }")])[5]`;

let listBlock = await waitForVisible( this.driver, listBlockPositionLocator );
let listBlock = await waitForVisible(
this.driver,
listBlockPositionLocator
);
await listBlock.click();

// iOS needs a click to get the text element
Expand All @@ -581,19 +586,16 @@ class EditorPage {
? `(//XCUIElementTypeStaticText[contains(@name, "List")])`
: `//XCUIElementTypeButton[contains(@name, "List")]`;

listBlock = await waitForVisible(
this.driver,
listBlockLocator
);
listBlock = await waitForVisible( this.driver, listBlockLocator );
await listBlock.click();
}

const listBlockTextLocatorIOS = options.isEmptyBlock
? `(//XCUIElementTypeStaticText[contains(@name, "List")])`
: `//XCUIElementTypeButton[contains(@name, "List")]//XCUIElementTypeTextView`;
const listBlockTextLocator = isAndroid()
? `//android.view.ViewGroup[contains(@content-desc, "List Block.")]/android.widget.EditText`
const listBlockTextLocatorIOS = options.isEmptyBlock
? `(//XCUIElementTypeStaticText[contains(@name, "List")])`
: `//XCUIElementTypeButton[contains(@name, "List")]//XCUIElementTypeTextView`;

const listBlockTextLocator = isAndroid()
? `//android.view.ViewGroup[contains(@content-desc, "List Block.")]/android.widget.EditText`
: listBlockTextLocatorIOS;

return await waitForVisible( this.driver, listBlockTextLocator );
Expand Down