Skip to content

Commit

Permalink
Mobile - E2E Tests - Fix block insertion flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Dec 16, 2022
1 parent 9258e2d commit 538d7df
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ import {
describe( 'Gutenberg Editor tests for Block insertion 2', () => {
it( 'adds new block at the end of post', async () => {
await editorPage.addNewBlock( blockNames.heading );

const headingBlock = await editorPage.getBlockAtPosition(
blockNames.heading
);
expect( headingBlock ).toBeTruthy();

await editorPage.addNewBlock( blockNames.list );

const listItemBlock = await editorPage.getBlockAtPosition(
blockNames.listItem
);
expect( listItemBlock ).toBeTruthy();

const expectedHtml = [ headerBlockEmpty, listBlockEmpty ].join(
'\n\n'
);
Expand All @@ -29,6 +40,12 @@ describe( 'Gutenberg Editor tests for Block insertion 2', () => {

await editorPage.addNewBlock( blockNames.separator );

const separatorBlock = await editorPage.getBlockAtPosition(
blockNames.separator,
2
);
expect( separatorBlock ).toBeTruthy();

const expectedHtml = [
headerBlockEmpty,
separatorBlockEmpty,
Expand All @@ -47,6 +64,13 @@ describe( 'Gutenberg Editor tests for Block insertion 2', () => {
await separatorBlockElement.click();

await editorPage.addNewBlock( blockNames.image, 'before' );

const imageBlock = await editorPage.getBlockAtPosition(
blockNames.image,
2
);
expect( imageBlock ).toBeTruthy();

await editorPage.closePicker();

const expectedHtml = [
Expand All @@ -63,6 +87,12 @@ describe( 'Gutenberg Editor tests for Block insertion 2', () => {
it( 'inserts block at the end of post when no block is selected', async () => {
await editorPage.addNewBlock( blockNames.more );

const moreBlock = await editorPage.getBlockAtPosition(
blockNames.more,
5
);
expect( moreBlock ).toBeTruthy();

const expectedHtml = [
headerBlockEmpty,
imageBlockEmpty,
Expand All @@ -78,6 +108,12 @@ describe( 'Gutenberg Editor tests for Block insertion 2', () => {
it( 'creates a new Paragraph block tapping on the empty area below the last block', async () => {
await editorPage.addParagraphBlockByTappingEmptyAreaBelowLastBlock();

const paragraphBlock = await editorPage.getBlockAtPosition(
blockNames.paragraph,
6
);
expect( paragraphBlock ).toBeTruthy();

const expectedHtml = [
headerBlockEmpty,
imageBlockEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,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.getTextBlockAtPosition(
const paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
Expand All @@ -98,15 +98,19 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
const titleElement = await editorPage.getTitleElement( {
autoscroll: true,
} );
expect( titleElement ).toBeTruthy();
await titleElement.click();

await editorPage.addNewBlock( blockNames.paragraph );
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
const emptyParagraphBlock = await editorPage.getBlockAtPosition(
blockNames.paragraph
);
await clickMiddleOfElement( editorPage.driver, paragraphBlockElement );
expect( emptyParagraphBlock ).toBeTruthy();
const emptyParagraphBlockElement =
await editorPage.getTextBlockAtPosition( blockNames.paragraph );
expect( emptyParagraphBlockElement ).toBeTruthy();

await editorPage.sendTextToParagraphBlock( 1, testData.mediumText );
await paragraphBlockElement.click();
const html = await editorPage.getHtmlContent();
expect( html.toLowerCase() ).toBe(
testData.blockInsertionHtmlFromTitle.toLowerCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ const blockNames = {
image: 'Image',
latestPosts: 'Latest Posts',
list: 'List',
listItem: 'List item',
more: 'More',
paragraph: 'Paragraph',
search: 'Search',
Expand Down

1 comment on commit 538d7df

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3714495145
📝 Reported issues:

Please sign in to comment.