Skip to content
Closed
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 @@ -8,7 +8,7 @@ import testData from './helpers/test-data';
describe( 'Gutenberg Editor tests for Block insertion', () => {
it( 'should be able to insert multi-paragraph text, and text to another paragraph block in between', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getBlockAtPosition(
let paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
Expand All @@ -18,15 +18,15 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
await editorPage.sendTextToParagraphBlock( 1, testData.longText );
// Should have 3 paragraph blocks at this point.

paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
2
);
await paragraphBlockElement.click();

await editorPage.addNewBlock( blockNames.paragraph );

paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
3
);
Expand All @@ -44,7 +44,7 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {

// Workaround for now since deleting the first element causes a crash on CI for Android
if ( isAndroid() ) {
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
3,
{
Expand All @@ -57,7 +57,7 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
for ( let i = 3; i > 0; i-- ) {
// wait for accessibility ids to update
await editorPage.driver.sleep( 1000 );
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
i,
{
Expand All @@ -74,7 +74,7 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
for ( let i = 4; i > 0; i-- ) {
// wait for accessibility ids to update
await editorPage.driver.sleep( 1000 );
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
await clickMiddleOfElement(
Expand All @@ -88,7 +88,7 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {

it( 'should be able to insert block at the beginning of post from the title', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getBlockAtPosition(
let paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
Expand All @@ -110,7 +110,7 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
await titleElement.click();

await editorPage.addNewBlock( blockNames.paragraph );
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
await clickMiddleOfElement( editorPage.driver, paragraphBlockElement );
Expand Down
14 changes: 9 additions & 5 deletions packages/react-native-editor/__device-tests__/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ 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
blockNames.heading,
1,
{
useWaitForVisible: true,
}
);
if ( isAndroid() ) {
await headingBlockElement.click();
Expand All @@ -21,7 +25,7 @@ describe( 'Gutenberg Editor tests', () => {
);

await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getBlockAtPosition(
let paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
2
);
Expand All @@ -31,7 +35,7 @@ describe( 'Gutenberg Editor tests', () => {
);

await editorPage.addNewBlock( blockNames.paragraph );
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
3
);
Expand All @@ -41,7 +45,7 @@ describe( 'Gutenberg Editor tests', () => {
);

await editorPage.addNewBlock( blockNames.heading );
headingBlockElement = await editorPage.getBlockAtPosition(
headingBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.heading,
4
);
Expand All @@ -51,7 +55,7 @@ describe( 'Gutenberg Editor tests', () => {
);

await editorPage.addNewBlock( blockNames.paragraph );
paragraphBlockElement = await editorPage.getBlockAtPosition(
paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
5
);
Expand Down
12 changes: 7 additions & 5 deletions packages/react-native-editor/__device-tests__/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import testData from './helpers/test-data';
describe( 'Gutenberg Editor Image Block tests', () => {
it( 'should be able to add an image block', async () => {
await editorPage.addNewBlock( blockNames.image );
await editorPage.driver.sleep( 1000 );
await editorPage.closePicker();

let imageBlock = await editorPage.getBlockAtPosition(
blockNames.image
const imageBlock = await editorPage.getBlockAtPosition(
blockNames.image,
1,
{
useWaitForVisible: true,
}
);

// Can only add image from media library on iOS
Expand All @@ -26,7 +29,6 @@ describe( 'Gutenberg Editor Image Block tests', () => {
await editorPage.dismissKeyboard();
// End workaround.

imageBlock = await editorPage.getBlockAtPosition( imageBlock );
await swipeUp( editorPage.driver, imageBlock );
await editorPage.enterCaptionToSelectedImageBlock(
testData.imageCaption,
Expand All @@ -35,7 +37,7 @@ describe( 'Gutenberg Editor Image Block tests', () => {
await editorPage.dismissKeyboard();
}
await editorPage.addNewBlock( blockNames.paragraph );
const paragraphBlockElement = await editorPage.getBlockAtPosition(
const paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
2
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,118 +13,92 @@ import testData from './helpers/test-data';
describe( 'Gutenberg Editor tests for Paragraph Block', () => {
it( 'should be able to split one paragraph block into two', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
const paragraphBlockElement = await editorPage.getBlockAtPosition(
const paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
testData.shortText
);
const textViewElement = await editorPage.getTextViewForParagraphBlock(
paragraphBlockElement
await clickMiddleOfElement(
editorPage.driver,
paragraphBlockElement,
true
);
await clickMiddleOfElement( editorPage.driver, textViewElement );
await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
'\n',
false
);
expect(
( await editorPage.hasBlockAtPosition(
1,
blockNames.paragraph
) ) &&
( await editorPage.hasBlockAtPosition(
2,
blockNames.paragraph
) )
).toBe( true );

const text0 = await editorPage.getTextForParagraphBlockAtPosition( 1 );
const text1 = await editorPage.getTextForParagraphBlockAtPosition( 2 );
expect( await editorPage.getNumberOfParagraphBlocks() ).toEqual( 2 );
expect( text0 ).not.toBe( '' );
expect( text1 ).not.toBe( '' );
expect( testData.shortText ).toMatch(
new RegExp( `${ text0 + text1 }|${ text0 } ${ text1 }` )
);

await editorPage.removeBlockAtPosition( blockNames.paragraph, 2 );
await editorPage.removeBlockAtPosition( blockNames.paragraph );
} );

it( 'should be able to merge 2 paragraph blocks into 1', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getBlockAtPosition(
let paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
testData.shortText
);
let textViewElement = await editorPage.getTextViewForParagraphBlock(
paragraphBlockElement
await clickMiddleOfElement(
editorPage.driver,
paragraphBlockElement,
true
);
await clickMiddleOfElement( editorPage.driver, textViewElement );
await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
'\n'
);
expect(
( await editorPage.hasBlockAtPosition(
1,
blockNames.paragraph
) ) &&
( await editorPage.hasBlockAtPosition(
2,
blockNames.paragraph
) )
).toBe( true );

const text0 = await editorPage.getTextForParagraphBlockAtPosition( 1 );
const text1 = await editorPage.getTextForParagraphBlockAtPosition( 2 );
expect( await editorPage.getNumberOfParagraphBlocks() ).toEqual( 2 );
paragraphBlockElement = await editorPage.getBlockAtPosition(
blockNames.paragraph,
2
2,
{
useWaitForVisible: true,
}
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

textViewElement = await editorPage.getTextViewForParagraphBlock(
const textViewElement = await editorPage.getTextViewForParagraphBlock(
paragraphBlockElement
);
await clickBeginningOfElement( editorPage.driver, textViewElement );

const backspaceKey = isAndroid() ? backspace : '\b\b';
await editorPage.typeTextToParagraphBlock(
paragraphBlockElement,
backspace
backspaceKey
);

const text = await editorPage.getTextForParagraphBlockAtPosition( 1 );
expect( text0 + text1 ).toMatch( text );

expect(
await editorPage.hasBlockAtPosition( 2, blockNames.paragraph )
).toBe( false );
text0.replace( /\s/g, '' ) + text1.replace( /\s/g, '' )
).toMatch( text.replace( /\s/g, '' ) );
expect( await editorPage.getNumberOfParagraphBlocks() ).toEqual( 1 );
await editorPage.removeBlockAtPosition( blockNames.paragraph );
} );

it( 'should be able to create a post with multiple paragraph blocks', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
const paragraphBlockElement = await editorPage.getBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.sendTextToParagraphBlock( 1, testData.longText );

for ( let i = 3; i > 0; i-- ) {
Expand All @@ -139,18 +113,27 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
testData.lettersInParagraphBlock,
].join( '\n\n' )
);
// // Merge paragraphs.
const secondParagraphBlockElement = await editorPage.getBlockAtPosition(

// Merge paragraphs.
await editorPage.getTextForParagraphBlockAtPosition( 2 );
const paragraphBlockElement = await editorPage.getBlockAtPosition(
blockNames.paragraph,
2
2,
{
useWaitForVisible: true,
}
);
await clickBeginningOfElement(
editorPage.driver,
secondParagraphBlockElement

const textViewElement = await editorPage.getTextViewForParagraphBlock(
paragraphBlockElement
);

await clickBeginningOfElement( editorPage.driver, textViewElement );

const backspaceKey = isAndroid() ? backspace : '\b\b';
await editorPage.typeTextToParagraphBlock(
secondParagraphBlockElement,
backspace
paragraphBlockElement,
backspaceKey
);

// Verify the editor has not crashed.
Expand All @@ -168,21 +151,25 @@ describe( 'Gutenberg Editor tests for Paragraph Block', () => {
testData.paragraphBlockEmpty,
].join( '\n\n' )
);
// // Merge paragraphs.
const secondParagraphBlockElement = await editorPage.getBlockAtPosition(

// Merge paragraphs.
const paragraphBlockElement = await editorPage.getTextBlockLocatorAtPosition(
blockNames.paragraph,
2
);
await secondParagraphBlockElement.click();
const backspaceKey = isAndroid() ? backspace : '\b\b';
await editorPage.typeTextToParagraphBlock(
secondParagraphBlockElement,
backspace
paragraphBlockElement,
backspaceKey
);

// Verify the editor has not crashed.
const text = await editorPage.getTextForParagraphBlockAtPosition( 1 );
expect( text.length ).not.toEqual( 0 );

if ( isAndroid() ) {
await paragraphBlockElement.click();
}
await editorPage.removeBlockAtPosition( blockNames.paragraph );
} );
} );
Loading