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

Writing flow: add e2e tests for webkit and firefox #53458

Merged
merged 1 commit into from
Aug 9, 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

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