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 4f6917ea29be33315f89b96ea811278408390207
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import { backspace, isAndroid, isLocalEnvironment } from './helpers/utils';
import { waitIfAndroid, backspace } from './helpers/utils';

describe( 'Gutenberg Editor tests for List block', () => {
// Prevent regression of https://github.com/wordpress-mobile/gutenberg-mobile/issues/871
Expand All @@ -16,11 +16,8 @@ describe( 'Gutenberg Editor tests for List block', () => {
// Send an Enter.
await editorPage.typeTextToTextBlock( listBlockElement, '\n', false );

// Click List block on Android.
// Only needed when testing in local environment
if ( isAndroid() && isLocalEnvironment() ) {
await listBlockElement.click();
}
// Instead of introducing separate conditions for local and CI environment, add this wait for Android to accomodate both environments
await waitIfAndroid();

// Send a backspace.
await editorPage.typeTextToTextBlock(
Expand All @@ -31,9 +28,7 @@ describe( 'Gutenberg Editor tests for List block', () => {

// There is a delay in Sauce Labs when a key is sent
// There isn't an element to check as it's being typed into an element that already exists, workaround is to add this wait until there's a better solution
if ( isAndroid() ) {
await editorPage.driver.sleep( 1500 );
}
await waitIfAndroid();

// Switch to html and verify html.
const html = await editorPage.getHtmlContent();
Expand Down
16 changes: 15 additions & 1 deletion packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ const waitForMediaLibrary = async ( driver ) => {
};

/**
*
* @param {string} driver
* @param {string} elementLocator
* @param {number} iteration - Default value is 0
* @return {string} - Returns the first element found, throws error if no element found
*/
const waitForVisible = async ( driver, elementLocator, iteration = 0 ) => {
const maxIteration = 25;
Expand All @@ -492,6 +492,12 @@ const waitForVisible = async ( driver, elementLocator, iteration = 0 ) => {
return locator[ 0 ];
};

/**
* @param {string} driver
* @param {string} elementLocator
* @param {number} iteration - Default value is 0
* @return {boolean} - Returns true if element is found, false otherwise
*/
const isElementVisible = async ( driver, elementLocator, iteration = 0 ) => {
const maxIteration = 5;
const timeout = 1000;
Expand All @@ -513,6 +519,13 @@ const isElementVisible = async ( driver, elementLocator, iteration = 0 ) => {
return true;
};

// Only for Android
const waitIfAndroid = async () => {
if ( isAndroid() ) {
await editorPage.driver.sleep( 1000 );
}
};

module.exports = {
backspace,
clickBeginningOfElement,
Expand All @@ -537,4 +550,5 @@ module.exports = {
typeString,
waitForMediaLibrary,
waitForVisible,
waitIfAndroid,
};