Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile - Move the gutenberg-editor-block-insertion-2 E2E tests to integration tests #46882

Merged
merged 1 commit into from
Jan 4, 2023
Merged
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
@@ -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.