Skip to content

Commit

Permalink
Mobile - Move the gutenberg-editor-block-insertion-2 E2E remaining te…
Browse files Browse the repository at this point in the history
…sts into integration tests (#46882)
  • Loading branch information
geriux committed Jan 4, 2023
1 parent 4313a88 commit f5785a3
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Inserter can add blocks adds new block at the end of post 1`] = `
"<!-- wp:spacer -->
<div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
<!-- /wp:spacer -->
<!-- wp:heading -->
<h2 class=\\"wp-block-heading\\"></h2>
<!-- /wp:heading -->"
`;
exports[`Inserter can add blocks after another block 1`] = `
"<!-- wp:spacer -->
<div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
Expand Down Expand Up @@ -28,6 +38,48 @@ exports[`Inserter can add blocks before another block 1`] = `
<!-- /wp:paragraph -->"
`;
exports[`Inserter can add blocks creates a new Paragraph block tapping on the empty area below the last block 1`] = `
"<!-- wp:spacer -->
<div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
<!-- /wp:spacer -->
<!-- wp:heading -->
<h2 class=\\"wp-block-heading\\"></h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->"
`;
exports[`Inserter can add blocks inserts between 2 existing blocks 1`] = `
"<!-- wp:spacer -->
<div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
<!-- /wp:spacer -->
<!-- wp:more -->
<!--more-->
<!-- /wp:more -->
<!-- wp:heading -->
<h2 class=\\"wp-block-heading\\"></h2>
<!-- /wp:heading -->"
`;
exports[`Inserter can add blocks inserts block at the end of post when no block is selected 1`] = `
"<!-- wp:spacer -->
<div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
<!-- /wp:spacer -->
<!-- wp:heading -->
<h2 class=\\"wp-block-heading\\"></h2>
<!-- /wp:heading -->
<!-- wp:more -->
<!--more-->
<!-- /wp:more -->"
`;
exports[`Inserter can add blocks to the beginning 1`] = `
"<!-- wp:more -->
<!--more-->
Expand Down
93 changes: 93 additions & 0 deletions packages/block-editor/src/components/inserter/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,98 @@ describe( 'Inserter', () => {

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'adds new block at the end of post', async () => {
const screen = await initializeEditor();

// Add Spacer block
await addBlock( screen, 'Spacer' );

// Add Heading block
await addBlock( screen, 'Heading' );

// Get Heading block
const headingBlock = await getBlock( screen, 'Heading', {
rowIndex: 2,
} );
expect( headingBlock ).toBeVisible();

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'inserts between 2 existing blocks', async () => {
const screen = await initializeEditor();

// Add Spacer block
await addBlock( screen, 'Spacer' );

// Add Heading block
await addBlock( screen, 'Heading' );

// Get Spacer block
const spacerBlock = await getBlock( screen, 'Spacer' );
fireEvent.press( spacerBlock );

// Add More block
await addBlock( screen, 'More' );

// Get More block
const moreBlock = await getBlock( screen, 'More', { rowIndex: 2 } );
expect( moreBlock ).toBeVisible();

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'inserts block at the end of post when no block is selected', async () => {
const screen = await initializeEditor();
const { getAllByLabelText } = screen;

// Add Spacer block
await addBlock( screen, 'Spacer' );

// Add Heading block
await addBlock( screen, 'Heading' );

// Select the title
const titleInputElement = await getAllByLabelText(
'Post title. test'
)[ 0 ];
expect( titleInputElement ).toBeVisible();
fireEvent.press( titleInputElement );

// Add More block
await addBlock( screen, 'More' );

// Get More block
const moreBlock = await getBlock( screen, 'More', { rowIndex: 3 } );
expect( moreBlock ).toBeVisible();

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'creates a new Paragraph block tapping on the empty area below the last block', async () => {
const screen = await initializeEditor();
const { getByLabelText } = screen;

// Add Spacer block
await addBlock( screen, 'Spacer' );

// Add Heading block
await addBlock( screen, 'Heading' );

// Get the empty paragraph placeholder
const paragraphPlaceholder = await getByLabelText(
'Add paragraph block'
);
fireEvent.press( paragraphPlaceholder );

// Get Paragraph block
const paragraphBlock = await getBlock( screen, 'Paragraph', {
rowIndex: 3,
} );
expect( paragraphBlock ).toBeVisible();

expect( getEditorHtml() ).toMatchSnapshot();
} );
} );
} );

This file was deleted.

1 comment on commit f5785a3

@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/3839800952
📝 Reported issues:

Please sign in to comment.