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
Next Next commit
update tests using paragraph, heading and list blocks
  • Loading branch information
jostnes committed Apr 28, 2022
commit 8b70472d143cf6d890c22e67063c23f4192eef46
26 changes: 9 additions & 17 deletions packages/react-native-editor/__device-tests__/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import { isAndroid } from './helpers/utils';
import testData from './helpers/test-data';

describe( 'Gutenberg Editor tests', () => {
it( 'should be able to create a post with heading and paragraph blocks', async () => {
await editorPage.addNewBlock( blockNames.heading );
let headingBlockElement = await editorPage.getBlockAtPosition(
blockNames.heading,
1,
{
useWaitForVisible: true,
}
let headingBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.heading
);
if ( isAndroid() ) {
await headingBlockElement.click();
}
await editorPage.sendTextToHeadingBlock(

await editorPage.typeTextToTextBlock(
headingBlockElement,
testData.heading,
false
testData.heading
);

await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
2
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.mediumText
);
Expand All @@ -39,7 +31,7 @@ describe( 'Gutenberg Editor tests', () => {
blockNames.paragraph,
3
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.mediumText
);
Expand All @@ -49,7 +41,7 @@ describe( 'Gutenberg Editor tests', () => {
blockNames.heading,
4
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
headingBlockElement,
testData.heading
);
Expand All @@ -59,7 +51,7 @@ describe( 'Gutenberg Editor tests', () => {
blockNames.paragraph,
5
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.mediumText
);
Expand Down
36 changes: 18 additions & 18 deletions packages/react-native-editor/__device-tests__/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@ import testData from './helpers/test-data';
describe( 'Gutenberg Editor tests for List block', () => {
it( 'should be able to add a new List block', async () => {
await editorPage.addNewBlock( blockNames.list );
const listBlockElement = await editorPage.getBlockAtPosition(
blockNames.list
);
// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}
let listBlockElement = await editorPage.getListBlock( {
isEmptyBlock: true,
} );

// Send the first list item text.
await editorPage.sendTextToListBlock(
await editorPage.typeTextToTextBlock(
listBlockElement,
testData.listItem1
testData.listItem1,
false
);

listBlockElement = await editorPage.getListBlock();

// Send an Enter.
await editorPage.sendTextToListBlock( listBlockElement, '\n' );
await editorPage.typeTextToTextBlock( listBlockElement, '\n', false );

listBlockElement = await editorPage.getListBlock();

// Send the second list item text.
await editorPage.sendTextToListBlock(
await editorPage.typeTextToTextBlock(
listBlockElement,
testData.listItem2
testData.listItem2,
false
);

// Switch to html and verify html.
Expand All @@ -38,12 +39,11 @@ describe( 'Gutenberg Editor tests for List block', () => {

// This test depends on being run immediately after 'should be able to add a new List block'
it( 'should update format to ordered list, using toolbar button', async () => {
let listBlockElement = await editorPage.getBlockAtPosition(
blockNames.list
);
let listBlockElement = await editorPage.getListBlock();

// Click List block to force EditText focus.
await listBlockElement.click();
if ( isAndroid() ) {
listBlockElement.click();
}

// Send a click on the order list format button.
await editorPage.clickOrderedListToolBarButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import { isAndroid } from './helpers/utils';
import testData from './helpers/test-data';

describe( 'Gutenberg Editor tests for List block (end)', () => {
it( 'should be able to end a List block', async () => {
await editorPage.addNewBlock( blockNames.list );
const listBlockElement = await editorPage.getBlockAtPosition(
blockNames.list
);

// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}
const listBlockElement = await editorPage.getListBlock();

// Send the first list item text.
await editorPage.sendTextToListBlock(
await editorPage.typeTextToTextBlock(
listBlockElement,
testData.listItem1
testData.listItem1,
false
);

// Send an Enter.
await editorPage.sendTextToListBlock( listBlockElement, '\n' );

// Send an Enter.
await editorPage.sendTextToListBlock( listBlockElement, '\n' );
await editorPage.typeTextToTextBlock( listBlockElement, '\n\n', false );

const html = await editorPage.getHtmlContent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ describe( 'Gutenberg Editor tests for List block', () => {
// Prevent regression of https://github.com/wordpress-mobile/gutenberg-mobile/issues/871
it( 'should handle spaces in a list', async () => {
await editorPage.addNewBlock( blockNames.list );
let listBlockElement = await editorPage.getBlockAtPosition(
blockNames.list
);
// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}
let listBlockElement = await editorPage.getListBlock();

// Send the list item text.
await editorPage.sendTextToListBlock( listBlockElement, ' a' );
await editorPage.typeTextToTextBlock( listBlockElement, ' a', false );

// Send an Enter.
await editorPage.sendTextToListBlock( listBlockElement, '\n' );
await editorPage.typeTextToTextBlock( listBlockElement, '\n', false );

// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}
// Send a backspace.
await editorPage.sendTextToListBlock( listBlockElement, backspace );
await editorPage.typeTextToTextBlock(
listBlockElement,
backspace,
false
);

// Switch to html and verify html.
const html = await editorPage.getHtmlContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.shortText
);
await clickMiddleOfElement( editorPage.driver, paragraphBlockElement );
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
'\n',
false
Expand All @@ -44,19 +44,13 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
let paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.shortText
);
await clickMiddleOfElement( editorPage.driver, paragraphBlockElement );
await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
'\n'
);
await editorPage.typeTextToTextBlock( paragraphBlockElement, '\n' );

const text0 = await editorPage.getTextForParagraphBlockAtPosition( 1 );
const text1 = await editorPage.getTextForParagraphBlockAtPosition( 2 );
Expand All @@ -71,7 +65,7 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
paragraphBlockElement
);

await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
backspace
);
Expand Down Expand Up @@ -112,7 +106,7 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
editorPage.driver,
paragraphBlockElement
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
backspace
);
Expand Down Expand Up @@ -140,7 +134,7 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
blockNames.paragraph,
2
);
await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
backspace
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ describe( 'Gutenberg Editor paste tests', () => {
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.pastePlainText
);
Expand All @@ -59,9 +56,6 @@ describe( 'Gutenberg Editor paste tests', () => {
blockNames.paragraph,
2
);
if ( isAndroid() ) {
await paragraphBlockElement2.click();
}

// Paste into second paragraph block.
await longPressMiddleOfElement(
Expand All @@ -83,9 +77,6 @@ describe( 'Gutenberg Editor paste tests', () => {
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

// Copy content to clipboard.
await longPressMiddleOfElement(
Expand All @@ -108,9 +99,6 @@ describe( 'Gutenberg Editor paste tests', () => {
blockNames.paragraph,
2
);
if ( isAndroid() ) {
await paragraphBlockElement2.click();
}

// Paste into second paragraph block.
await longPressMiddleOfElement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,30 @@ describe( 'Gutenberg Editor tests', () => {
let paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.typeTextToParagraphBlock(
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.mediumText
);

await toggleOrientation( editorPage.driver );
// On Android the keyboard hides the add block button, let's hide it after rotation
if ( isAndroid() ) {
await editorPage.driver.hideDeviceKeyboard();
await editorPage.dismissKeyboard();
}

await editorPage.addNewBlock( blockNames.paragraph );

if ( isAndroid() ) {
await editorPage.driver.hideDeviceKeyboard();
await editorPage.dismissKeyboard();
}

paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
2
);
while ( ! paragraphBlockElement ) {
await editorPage.driver.hideDeviceKeyboard();
paragraphBlockElement = await editorPage.getBlockAtPosition(
blockNames.paragraph,
2
);
}
await editorPage.typeTextToParagraphBlock(

await editorPage.typeTextToTextBlock(
paragraphBlockElement,
testData.mediumText
);
Expand Down
Loading