From 9e68a3d8f2ffe491040538b632fc0f6a34461d34 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 10 Aug 2023 11:12:16 +0300 Subject: [PATCH 1/2] Writing flow: add multi select e2e for firefox and webkit --- .../various/multi-block-selection.spec.js | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/test/e2e/specs/editor/various/multi-block-selection.spec.js b/test/e2e/specs/editor/various/multi-block-selection.spec.js index d109ed7d19447..8cb1371ee9d78 100644 --- a/test/e2e/specs/editor/various/multi-block-selection.spec.js +++ b/test/e2e/specs/editor/various/multi-block-selection.spec.js @@ -10,7 +10,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); * Some tests in this file use the character `|` to represent the caret's position * in a more readable format. */ -test.describe( 'Multi-block selection', () => { +test.describe( 'Multi-block selection (@firefox, @webkit)', () => { test.use( { multiBlockSelectionUtils: async ( { page, editor }, use ) => { await use( new MultiBlockSelectionUtils( { page, editor } ) ); @@ -48,7 +48,7 @@ test.describe( 'Multi-block selection', () => { } ); // See #14448: an incorrect buffer may trigger multi-selection too soon. - test( 'should only trigger multi-selection when at the end', async ( { + test( 'should only trigger multi-selection when at the end (-webkit)', async ( { page, editor, pageUtils, @@ -286,7 +286,7 @@ test.describe( 'Multi-block selection', () => { } ); // @see https://github.com/WordPress/gutenberg/issues/34118 - test( 'should properly select a single block even if `shift` was held for the selection', async ( { + test( 'should properly select a single block even if `shift` was held for the selection (-firefox)', async ( { page, editor, pageUtils, @@ -318,7 +318,7 @@ test.describe( 'Multi-block selection', () => { ] ); } ); - test( 'should properly select multiple blocks if selected nested blocks belong to different parent', async ( { + test( 'should properly select multiple blocks if selected nested blocks belong to different parent (-webkit)', async ( { editor, multiBlockSelectionUtils, } ) => { @@ -352,7 +352,7 @@ test.describe( 'Multi-block selection', () => { .toEqual( [ 1, 4 ] ); } ); - test( 'should properly select part of nested rich text block while holding shift', async ( { + test( 'should properly select part of nested rich text block while holding shift (-firefox)', async ( { page, editor, } ) => { @@ -1113,7 +1113,7 @@ test.describe( 'Multi-block selection', () => { ] ); } ); - test( 'should write over selection', async ( { + test( 'should write over selection (-firefox)', async ( { page, editor, pageUtils, @@ -1138,6 +1138,34 @@ test.describe( 'Multi-block selection', () => { ] ); } ); + test( 'should write over selection (-chromium, -webkit, @firefox)', async ( { + page, + editor, + pageUtils, + } ) => { + await editor.canvas + .getByRole( 'button', { name: 'Add default block' } ) + .click(); + await page.keyboard.type( '1[' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( ']2' ); + await page.keyboard.press( 'ArrowLeft' ); + // Select everything between []. + await pageUtils.pressKeys( 'Shift+ArrowLeft', { times: 3 } ); + + // Ensure selection is in the correct place. + await page.keyboard.type( '|' ); + // For some reason, this works completely fine when testing manually in + // Firefox, but with Playwright it only merges the blocks but doesn't + // insert the character. + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/paragraph', + attributes: { content: '12' }, + }, + ] ); + } ); + test( 'should handle Enter across blocks', async ( { page, editor, @@ -1213,7 +1241,7 @@ test.describe( 'Multi-block selection', () => { ] ); } ); - test( 'should partially select with shift + click (@webkit)', async ( { + test( 'should partially select with shift + click', async ( { page, editor, } ) => { From 2671891a58afc504aac70898dded86344613edbd Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 29 Feb 2024 22:05:14 +0200 Subject: [PATCH 2/2] Skip some in ff --- test/e2e/specs/editor/various/multi-block-selection.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/editor/various/multi-block-selection.spec.js b/test/e2e/specs/editor/various/multi-block-selection.spec.js index 8cb1371ee9d78..5ec90841310b7 100644 --- a/test/e2e/specs/editor/various/multi-block-selection.spec.js +++ b/test/e2e/specs/editor/various/multi-block-selection.spec.js @@ -614,7 +614,7 @@ test.describe( 'Multi-block selection (@firefox, @webkit)', () => { ] ); } ); - test( 'should keep correct selection when dragging outside block', async ( { + test( 'should keep correct selection when dragging outside block (-firefox)', async ( { page, editor, } ) => { @@ -730,7 +730,7 @@ test.describe( 'Multi-block selection (@firefox, @webkit)', () => { ] ); } ); - test( 'should clear selection when clicking next to blocks', async ( { + test( 'should clear selection when clicking next to blocks (-firefox)', async ( { page, editor, multiBlockSelectionUtils,