Skip to content

Commit

Permalink
Add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Apr 12, 2019
1 parent 442b734 commit 72da05d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ exports[`RichText should not lose selection direction 1`] = `
<!-- /wp:paragraph -->"
`;

exports[`RichText should not undo backtick transform with backspace after selection change 1`] = `""`;

exports[`RichText should not undo backtick transform with backspace after typing 1`] = `""`;

exports[`RichText should only mutate text data on input 1`] = `
"<!-- wp:paragraph -->
<p>1<strong>2</strong>34</p>
Expand All @@ -65,3 +69,9 @@ exports[`RichText should transform backtick to code 2`] = `
<p>A \`backtick\`</p>
<!-- /wp:paragraph -->"
`;

exports[`RichText should undo backtick transform with backspace 1`] = `
"<!-- wp:paragraph -->
<p>\`a\`</p>
<!-- /wp:paragraph -->"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ exports[`List should not transform lines in block when transforming multiple blo
<!-- /wp:list -->"
`;
exports[`List should not undo asterisk transform with backspace after typing 1`] = `""`;
exports[`List should outdent with children 1`] = `
"<!-- wp:list -->
<ul><li>a<ul><li>b<ul><li>c</li></ul></li></ul></li></ul>
Expand Down Expand Up @@ -261,3 +263,9 @@ exports[`List should split into two with paragraph and merge lists 3`] = `
<ul><li>two</li></ul>
<!-- /wp:list -->"
`;
exports[`List should undo asterisk transform with backspace 1`] = `
"<!-- wp:paragraph -->
<p>* </p>
<!-- /wp:paragraph -->"
`;
17 changes: 17 additions & 0 deletions packages/e2e-tests/specs/blocks/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ describe( 'List', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should undo asterisk transform with backspace', async () => {
await clickBlockAppender();
await page.keyboard.type( '* ' );
await page.keyboard.press( 'Backspace' );

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

it( 'should not undo asterisk transform with backspace after typing', async () => {
await clickBlockAppender();
await page.keyboard.type( '* a' );
await page.keyboard.press( 'Backspace' );
await page.keyboard.press( 'Backspace' );

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

it( 'can be created by typing "/list"', async () => {
// Create a list with the slash block shortcut.
await clickBlockAppender();
Expand Down
29 changes: 29 additions & 0 deletions packages/e2e-tests/specs/rich-text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,35 @@ describe( 'RichText', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should undo backtick transform with backspace', async () => {
await clickBlockAppender();
await page.keyboard.type( '`a`' );
await page.keyboard.press( 'Backspace' );

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

it( 'should not undo backtick transform with backspace after typing', async () => {
await clickBlockAppender();
await page.keyboard.type( '`a`b' );
await page.keyboard.press( 'Backspace' );
await page.keyboard.press( 'Backspace' );

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

it( 'should not undo backtick transform with backspace after selection change', async () => {
await clickBlockAppender();
await page.keyboard.type( '`a`' );
// Move inside format boundary.
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Backspace' );

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

it( 'should not format text after code backtick', async () => {
await clickBlockAppender();
await page.keyboard.type( 'A `backtick` and more.' );
Expand Down

0 comments on commit 72da05d

Please sign in to comment.