Skip to content

Commit

Permalink
Writing flow: add e2e tests for webkit and firefox (#53458)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Aug 9, 2023
1 parent 4a24e85 commit 5ff4e28
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 183 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

67 changes: 60 additions & 7 deletions test/e2e/specs/editor/various/splitting-merging.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'splitting and merging blocks', () => {
test.describe( 'splitting and merging blocks (@firefox, @webkit)', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );
Expand Down Expand Up @@ -334,10 +334,17 @@ test.describe( 'splitting and merging blocks', () => {
await pageUtils.pressKeys( 'primary+z' );

// Check the content.
expect( await editor.getEditedPostContent() ).toMatchSnapshot();
expect( await editor.getBlocks() ).toMatchObject( [
{
name: 'core/paragraph',
attributes: {
content: '12',
},
},
] );
} );

test( 'should not split with line break in front', async ( {
test( 'should not split with line break in front (-firefox)', async ( {
editor,
page,
pageUtils,
Expand All @@ -364,6 +371,52 @@ test.describe( 'splitting and merging blocks', () => {
} );

test.describe( 'test restore selection when merge produces more than one block', () => {
const snap1 = [
{
name: 'core/paragraph',
attributes: {
content: 'hi',
},
},
{
name: 'core/paragraph',
attributes: {
content: 'item 1',
},
},
{
name: 'core/list',
innerBlocks: [
{
name: 'core/list-item',
attributes: {
content: 'item 2',
},
},
],
},
];

const snap2 = [
{
name: 'core/paragraph',
attributes: {
content: 'hi-item 1',
},
},
{
name: 'core/list',
innerBlocks: [
{
name: 'core/list-item',
attributes: {
content: 'item 2',
},
},
],
},
];

test( 'on forward delete', async ( { editor, page, pageUtils } ) => {
await editor.insertBlock( { name: 'core/paragraph' } );
await page.keyboard.type( 'hi' );
Expand All @@ -374,14 +427,14 @@ test.describe( 'splitting and merging blocks', () => {
await pageUtils.pressKeys( 'ArrowUp', { times: 3 } );
await page.keyboard.press( 'Delete' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
expect( await editor.getBlocks() ).toMatchObject( snap1 );

await page.keyboard.press( 'Delete' );
// Carret should be in the first block and at the proper position.
await page.keyboard.type( '-' );

// Check the content.
expect( await editor.getEditedPostContent() ).toMatchSnapshot();
expect( await editor.getBlocks() ).toMatchObject( snap2 );
} );

test( 'on backspace', async ( { editor, page, pageUtils } ) => {
Expand All @@ -395,14 +448,14 @@ test.describe( 'splitting and merging blocks', () => {
await pageUtils.pressKeys( 'ArrowLeft', { times: 6 } );
await page.keyboard.press( 'Backspace' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
expect( await editor.getBlocks() ).toMatchObject( snap1 );

await page.keyboard.press( 'Backspace' );
// Carret should be in the first block and at the proper position.
await page.keyboard.type( '-' );

// Check the content.
expect( await editor.getEditedPostContent() ).toMatchSnapshot();
expect( await editor.getBlocks() ).toMatchObject( snap2 );
} );
} );
} );
Loading

0 comments on commit 5ff4e28

Please sign in to comment.