Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyc committed Jul 2, 2020
1 parent a340ca4 commit 6b23977
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cpt locking template_lock all should insert line breaks when using enter and shift-enter 1`] = `
"<!-- wp:image -->
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
<!-- /wp:image -->
<!-- wp:paragraph {\\"placeholder\\":\\"Add a description\\"} -->
<p>First line<br>Second line<br>Third line</p>
<!-- /wp:paragraph -->
<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p></p></blockquote>
<!-- /wp:quote -->
<!-- wp:columns -->
<div class=\\"wp-block-columns\\"></div>
<!-- /wp:columns -->"
`;
exports[`cpt locking template_lock all should not error when deleting the cotents of a paragraph 1`] = `
"<!-- wp:image -->
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
Expand Down
13 changes: 13 additions & 0 deletions packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getEditedPostContent,
insertBlock,
pressKeyTimes,
pressKeyWithModifier,
setPostContent,
} from '@wordpress/e2e-test-utils';

Expand Down Expand Up @@ -85,6 +86,18 @@ describe( 'cpt locking', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should insert line breaks when using enter and shift-enter', async () => {
await page.click(
'.block-editor-block-list__block[data-type="core/paragraph"]'
);
await page.keyboard.type( 'First line' );
await pressKeyTimes( 'Enter', 1 );
await page.keyboard.type( 'Second line' );
await pressKeyWithModifier( 'shift', 'Enter' );
await page.keyboard.type( 'Third line' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should show invalid template notice if the blocks do not match the templte', async () => {
const content = await getEditedPostContent();
const [ , contentWithoutImage ] = content.split(
Expand Down

0 comments on commit 6b23977

Please sign in to comment.