Skip to content

Commit

Permalink
Move heading e2e tests to the heading block, remove extra active clas…
Browse files Browse the repository at this point in the history
…s check (#10326)
  • Loading branch information
andrewserong committed Feb 13, 2019
1 parent 69fc7cc commit 1c398b6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`splitting and merging blocks should create a paragraph block above when pressing enter at start of heading 1`] = `
"<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->
<!-- wp:heading -->
<h2>Abc</h2>
<!-- /wp:heading -->"
`;

exports[`splitting and merging blocks should create a paragraph block below when pressing enter at end of heading 1`] = `
"<!-- wp:heading -->
<h2>Abc</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->"
`;

exports[`splitting and merging blocks should delete an empty first line 1`] = `
"<!-- wp:paragraph -->
<p>First</p>
Expand Down
20 changes: 20 additions & 0 deletions packages/e2e-tests/specs/blocks/__snapshots__/heading.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,23 @@ exports[`Separator can be created by prefixing number sign and a space 1`] = `
<h3>3</h3>
<!-- /wp:heading -->"
`;

exports[`Separator should create a paragraph block above when pressing enter at start of heading 1`] = `
"<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->
<!-- wp:heading -->
<h2>Abc</h2>
<!-- /wp:heading -->"
`;

exports[`Separator should create a paragraph block below when pressing enter at end of heading 1`] = `
"<!-- wp:heading -->
<h2>Abc</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->"
`;
19 changes: 19 additions & 0 deletions packages/e2e-tests/specs/blocks/heading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
clickBlockAppender,
getEditedPostContent,
createNewPost,
insertBlock,
pressKeyTimes,
} from '@wordpress/e2e-test-utils';

describe( 'Separator', () => {
Expand All @@ -27,4 +29,21 @@ describe( 'Separator', () => {

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should create a paragraph block above when pressing enter at start of heading', async () => {
await insertBlock( 'Heading' );
await page.keyboard.type( 'Abc' );
await pressKeyTimes( 'ArrowLeft', 3 );
await page.keyboard.press( 'Enter' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should create a paragraph block below when pressing enter at end of heading', async () => {
await insertBlock( 'Heading' );
await page.keyboard.type( 'Abc' );
await page.keyboard.press( 'Enter' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );
20 changes: 0 additions & 20 deletions packages/e2e-tests/specs/splitting-merging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,4 @@ describe( 'splitting and merging blocks', () => {

expect( isInDefaultBlock ).toBe( true );
} );

it( 'should create a paragraph block above when pressing enter at start of heading', async () => {
await insertBlock( 'Heading' );
await page.keyboard.type( 'Abc' );
await pressKeyTimes( 'ArrowLeft', 3 );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'ArrowUp' );

const activeElementClassList = await page.evaluate( () => document.activeElement.classList );
expect( Object.values( activeElementClassList ) ).toContain( 'wp-block-paragraph' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should create a paragraph block below when pressing enter at end of heading', async () => {
await insertBlock( 'Heading' );
await page.keyboard.type( 'Abc' );
await page.keyboard.press( 'Enter' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit 1c398b6

Please sign in to comment.