Skip to content

Commit

Permalink
Mobile - Skip some of the Drag & Drop E2E on iOS (#41529)
Browse files Browse the repository at this point in the history
* Mobile - Skip some of the Drag & Drop E2E on iOS

* Replace if condition to use onlyOnAndroid wrapper instead
  • Loading branch information
Gerardo Pacheco authored and dcalhoun committed Jul 7, 2022
1 parent fb5f7e4 commit aee2a06
Showing 1 changed file with 68 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

// Used to skip some tests on iOS
const onlyOnAndroid = isAndroid() ? it : it.skip;

describe( 'Gutenberg Editor Drag & Drop blocks tests', () => {
beforeEach( async () => {
await clearClipboard( editorPage.driver );
Expand Down Expand Up @@ -53,61 +56,73 @@ describe( 'Gutenberg Editor Drag & Drop blocks tests', () => {
await editorPage.removeBlockAtPosition( blockNames.paragraph, 1 );
} );

it( 'should be able to long-press on a text-based block to paste a text in a focused textinput', async () => {
// 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();
onlyOnAndroid(
'should be able to long-press on a text-based block to paste a text in a focused textinput',
async () => {
// 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 );

// Remove the block
await editorPage.removeBlockAtPosition( blockNames.paragraph );
}

// 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 );

// Remove the block
await editorPage.removeBlockAtPosition( blockNames.paragraph );
} );

it( 'should be able to long-press on a text-based block using the PlainText component to paste a text in a focused textinput', async () => {
// 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();
);

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 () => {
// 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.removeBlockAtPosition( blockNames.shortcode );
}

// 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.removeBlockAtPosition( blockNames.shortcode );
} );
);

it( 'should be able to drag & drop a text-based block when the textinput is not focused', async () => {
// Initialize the editor with two Paragraph blocks
Expand Down

0 comments on commit aee2a06

Please sign in to comment.