Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile] Remove wd usage and removes disabled tests #55541

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import {
clearClipboard,
longPressMiddleOfElement,
tapSelectAllAboveElement,
tapCopyAboveElement,
tapPasteAboveElement,
toggleOrientation,
isAndroid,
} from './helpers/utils';
import { toggleOrientation, isAndroid } from './helpers/utils';
import testData from './helpers/test-data';

describe( 'Gutenberg Editor Rotation tests', () => {
Expand Down Expand Up @@ -56,100 +48,3 @@ describe( 'Gutenberg Editor Rotation tests', () => {
);
} );
} );

describe( 'Gutenberg Editor Paste tests', () => {
// skip iOS for now
if ( ! isAndroid() ) {
it( 'skips the tests on any platform other than Android', async () => {
expect( true ).toBe( true );
} );
return;
}

beforeAll( async () => {
await clearClipboard( editorPage.driver );
} );

it.skip( 'copies plain text from one paragraph block and pastes in another', async () => {
await editorPage.initializeEditor();
await editorPage.addNewBlock( blockNames.paragraph );
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);

await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.pastePlainText
);

// Copy content to clipboard.
await longPressMiddleOfElement(
editorPage.driver,
paragraphBlockElement
);
await tapSelectAllAboveElement(
editorPage.driver,
paragraphBlockElement
);
await tapCopyAboveElement( editorPage.driver, paragraphBlockElement );

// Create another paragraph block.
await editorPage.addNewBlock( blockNames.paragraph );
if ( isAndroid() ) {
// On Andrdoid 10 a new auto-suggestion popup is appearing to let the user paste text recently put in the clipboard. Let's dismiss it.
await editorPage.dismissAndroidClipboardSmartSuggestion();
}
const paragraphBlockElement2 = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
2
);

// Paste into second paragraph block.
await tapPasteAboveElement( editorPage.driver, paragraphBlockElement2 );

const text = await editorPage.getTextForParagraphBlockAtPosition( 2 );
expect( text ).toBe( testData.pastePlainText );
} );

it.skip( 'copies styled text from one paragraph block and pastes in another', async () => {
// Create paragraph block with styled text by editing html.
await editorPage.initializeEditor( {
initialData: testData.pasteHtmlText,
} );
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);

// Copy content to clipboard.
await longPressMiddleOfElement(
editorPage.driver,
paragraphBlockElement
);
await tapSelectAllAboveElement(
editorPage.driver,
paragraphBlockElement
);
await tapCopyAboveElement( editorPage.driver, paragraphBlockElement );

// Create another paragraph block.
await editorPage.addNewBlock( blockNames.paragraph );
if ( isAndroid() ) {
// On Andrdoid 10 a new auto-suggestion popup is appearing to let the user paste text recently put in the clipboard. Let's dismiss it.
await editorPage.dismissAndroidClipboardSmartSuggestion();
}
const paragraphBlockElement2 = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
2
);

// Paste into second paragraph block.
await tapPasteAboveElement( editorPage.driver, paragraphBlockElement2 );

// Check styled text by verifying html contents.
const html = await editorPage.getHtmlContent();

expect( html.toLowerCase() ).toBe(
testData.pasteHtmlTextResult.toLowerCase()
);
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import {
clearClipboard,
dragAndDropAfterElement,
isAndroid,
setClipboard,
tapPasteAboveElement,
} from './helpers/utils';
import { clearClipboard, dragAndDropAfterElement } from './helpers/utils';
import testData from './helpers/test-data';

// Tests associated with this const are temporarily off for both platforms due to failures.
// They should be enabled for Android-only when a fix is in place.
const onlyOnAndroid = it.skip;

describe( 'Gutenberg Editor Drag & Drop blocks tests', () => {
beforeEach( async () => {
await clearClipboard( editorPage.driver );
Expand Down Expand Up @@ -52,72 +42,6 @@ describe( 'Gutenberg Editor Drag & Drop blocks tests', () => {
expect( firstBlockText ).toMatch( testData.shortText );
} );

onlyOnAndroid(
'should be able to long-press on a text-based block to paste a text in a focused textinput',
async () => {
await editorPage.initializeEditor();
// Add a Paragraph block
await editorPage.addNewBlock( blockNames.paragraph );
const paragraphBlockElement =
await editorPage.getTextBlockAtPosition( blockNames.paragraph );

// Set clipboard text
await setClipboard( editorPage.driver, testData.shortText );

// Dismiss auto-suggestion popup
if ( isAndroid() ) {
// On Andrdoid 10 a new auto-suggestion popup is appearing to let the user paste text recently put in the clipboard. Let's dismiss it.
await editorPage.dismissAndroidClipboardSmartSuggestion();
}

// Paste into the Paragraph block
await tapPasteAboveElement(
editorPage.driver,
paragraphBlockElement
);
const paragraphText =
await editorPage.getTextForParagraphBlockAtPosition( 1 );

// Expect to have the pasted text in the Paragraph block
expect( paragraphText ).toMatch( testData.shortText );
}
);

onlyOnAndroid(
'should be able to long-press on a text-based block using the PlainText component to paste a text in a focused textinput',
async () => {
await editorPage.initializeEditor();
// Add a Shortcode block
await editorPage.addNewBlock( blockNames.shortcode );
const shortcodeBlockElement =
await editorPage.getShortBlockTextInputAtPosition(
blockNames.shortcode
);

// Set clipboard text
await setClipboard( editorPage.driver, testData.shortText );

// Dismiss auto-suggestion popup
if ( isAndroid() ) {
// On Andrdoid 10 a new auto-suggestion popup is appearing to let the user paste text recently put in the clipboard. Let's dismiss it.
await editorPage.dismissAndroidClipboardSmartSuggestion();
}

// Paste into the Shortcode block
await tapPasteAboveElement(
editorPage.driver,
shortcodeBlockElement
);
const shortcodeText = await shortcodeBlockElement.text();

// Expect to have the pasted text in the Shortcode block
expect( shortcodeText ).toMatch( testData.shortText );

// Remove the block
await editorPage.removeBlock();
}
);

it( 'should be able to drag & drop a text-based block when another textinput is focused', async () => {
// Initialize the editor with two Paragraph blocks
await editorPage.initializeEditor( {
Expand Down
70 changes: 1 addition & 69 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
const childProcess = require( 'child_process' );
// eslint-disable-next-line import/no-extraneous-dependencies, import/named
import { remote, Key } from 'webdriverio';
// TODO: Replace usage of wd in favor of WebdriverIO
const wd = null;

const crypto = require( 'crypto' );
const path = require( 'path' );
/**
Expand Down Expand Up @@ -47,9 +46,6 @@ let appiumProcess;

const backspace = '\u0008';

// $block-edge-to-content value
const blockEdgeToContent = 16;

const IOS_BUNDLE_ID = 'org.wordpress.gutenberg.development';
const ANDROID_COMPONENT_NAME = 'com.gutenberg/.MainActivity';
const SAUCE_LABS_TIMEOUT = 240;
Expand Down Expand Up @@ -232,12 +228,6 @@ const typeString = async ( driver, element, str, clear ) => {
}
};

const doubleTap = async ( driver, element ) => {
const action = new wd.TouchAction( driver );
action.tap( { el: element, count: 2 } );
await action.perform();
};

/**
* Returns the mapped keycode for a string to use in `pressKeycode` function.
*
Expand Down Expand Up @@ -311,16 +301,6 @@ const clickBeginningOfElement = async ( driver, element ) => {
] );
};

// Clicks in the top left of a text-based element outside of the TextInput
const clickElementOutsideOfTextInput = async ( driver, element ) => {
const location = await element.getLocation();
const y = isAndroid() ? location.y - blockEdgeToContent : location.y;
const x = isAndroid() ? location.x - blockEdgeToContent : location.x;

const action = new wd.TouchAction( driver ).press( { x, y } ).release();
await action.perform();
};

// Long press to activate context menu.
const longPressMiddleOfElement = async (
driver,
Expand Down Expand Up @@ -358,49 +338,6 @@ const longPressMiddleOfElement = async (
.perform();
};

// Press "Select All" in floating context menu.
const tapSelectAllAboveElement = async ( driver, element ) => {
const location = await element.getLocation();
const action = await new wd.TouchAction( driver );
const x = location.x + 300;
const y = location.y - 50;
action.press( { x, y } );
action.release();
await action.perform();
};

// Press "Copy" in floating context menu.
const tapCopyAboveElement = async ( driver, element ) => {
const location = await element.getLocation();
const action = await new wd.TouchAction( driver );
const x = location.x + 220;
const y = location.y - 50;
action.wait( 2000 );
action.press( { x, y } );
action.wait( 2000 );
action.release();
await action.perform();
};

// Press "Paste" in floating context menu.
const tapPasteAboveElement = async ( driver, element ) => {
await longPressMiddleOfElement( driver, element );

if ( isAndroid() ) {
const location = await element.getLocation();
const action = await new wd.TouchAction( driver );
action.wait( 2000 );
action.press( { x: location.x + 100, y: location.y - 50 } );
action.wait( 2000 );
action.release();
await action.perform();
} else {
const pasteButtonLocator = '//XCUIElementTypeMenuItem[@name="Paste"]';
await clickIfClickable( driver, pasteButtonLocator );
await driver.sleep( 3000 ); // Wait for paste notification to disappear.
}
};

const tapStatusBariOS = async ( driver ) => {
await driver.touchPerform( [
{
Expand Down Expand Up @@ -818,10 +755,8 @@ module.exports = {
backspace,
clearClipboard,
clickBeginningOfElement,
clickElementOutsideOfTextInput,
clickIfClickable,
clickMiddleOfElement,
doubleTap,
dragAndDropAfterElement,
isAndroid,
isEditorVisible,
Expand All @@ -836,9 +771,6 @@ module.exports = {
swipeDown,
swipeFromTo,
swipeUp,
tapCopyAboveElement,
tapPasteAboveElement,
tapSelectAllAboveElement,
tapStatusBariOS,
timer,
toggleDarkMode,
Expand Down
18 changes: 0 additions & 18 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
* Internal dependencies
*/
const {
doubleTap,
isAndroid,
isEditorVisible,
setClipboard,
setupDriver,
stopDriver,
swipeDown,
swipeFromTo,
swipeUp,
tapPasteAboveElement,
toggleHtmlMode,
typeString,
waitForVisible,
Expand Down Expand Up @@ -258,21 +255,6 @@ class EditorPage {
return text;
}

// Set html editor content explicitly.
async setHtmlContent( html ) {
await toggleHtmlMode( this.driver, true );

await setClipboard( this.driver, html );

const htmlContentView = await this.getTextViewForHtmlViewContent();

await htmlContentView.click();
await doubleTap( this.driver, htmlContentView );
await tapPasteAboveElement( this.driver, htmlContentView );

await toggleHtmlMode( this.driver, false );
}

async dismissKeyboard() {
const orientation = await this.driver.getOrientation();
const keyboardShown = await this.driver.isKeyboardShown();
Expand Down
Loading