From 5ff4e28995d792de85e539a19284d1fefa840cff Mon Sep 17 00:00:00 2001
From: Ella <4710635+ellatrix@users.noreply.github.com>
Date: Wed, 9 Aug 2023 12:47:44 +0300
Subject: [PATCH] Writing flow: add e2e tests for webkit and firefox (#53458)
---
...nner-blocks-with-arrow-keys-1-chromium.txt | 21 ---
...when-rapidly-pressing-Enter-1-chromium.txt | 43 ------
...te-around-inline-boundaries-1-chromium.txt | 11 --
...ble-with-normal-line-height-1-chromium.txt | 7 -
...ontenteditable-with-padding-1-chromium.txt | 7 -
...teditable-with-side-padding-1-chromium.txt | 11 --
...ot-prematurely-multi-select-1-chromium.txt | 7 -
...s-using-Enter-and-Backspace-1-chromium.txt | 7 -
...should-undo-split-in-one-go-1-chromium.txt | 3 -
...one-block-on-forward-delete-2-chromium.txt | 9 --
...one-block-on-forward-delete-1-chromium.txt | 13 --
...than-one-block-on-backspace-2-chromium.txt | 9 --
...than-one-block-on-backspace-1-chromium.txt | 13 --
.../editor/various/splitting-merging.spec.js | 67 +++++++++-
.../specs/editor/various/writing-flow.spec.js | 122 +++++++++++++++---
15 files changed, 167 insertions(+), 183 deletions(-)
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-Should-navigate-inner-blocks-with-arrow-keys-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-create-valid-paragraph-blocks-when-rapidly-pressing-Enter-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-around-inline-boundaries-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-normal-line-height-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-padding-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-side-padding-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-not-prematurely-multi-select-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-split-and-merge-paragraph-blocks-using-Enter-and-Backspace-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-undo-split-in-one-go-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-18edb-roduces-more-than-one-block-on-forward-delete-2-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-2a1ee-roduces-more-than-one-block-on-forward-delete-1-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-46dfa-rge-produces-more-than-one-block-on-backspace-2-chromium.txt
delete mode 100644 test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-92273-rge-produces-more-than-one-block-on-backspace-1-chromium.txt
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-Should-navigate-inner-blocks-with-arrow-keys-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-Should-navigate-inner-blocks-with-arrow-keys-1-chromium.txt
deleted file mode 100644
index f6834177f03b73..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-Should-navigate-inner-blocks-with-arrow-keys-1-chromium.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
First paragraph
-
-
-
-
-
-
-
-Second paragraph
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-create-valid-paragraph-blocks-when-rapidly-pressing-Enter-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-create-valid-paragraph-blocks-when-rapidly-pressing-Enter-1-chromium.txt
deleted file mode 100644
index 8b3e8afd099094..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-create-valid-paragraph-blocks-when-rapidly-pressing-Enter-1-chromium.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-around-inline-boundaries-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-around-inline-boundaries-1-chromium.txt
deleted file mode 100644
index 1ad3516b59244a..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-around-inline-boundaries-1-chromium.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-
-FirstAfter
-
-
-
-BeforeInsideSecondInsideAfter
-
-
-
-BeforeThird
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-normal-line-height-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-normal-line-height-1-chromium.txt
deleted file mode 100644
index c5276526e35be3..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-normal-line-height-1-chromium.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-
-1
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-padding-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-padding-1-chromium.txt
deleted file mode 100644
index cbf68836cabedb..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-padding-1-chromium.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-
-1
-
-
-
-2
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-side-padding-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-side-padding-1-chromium.txt
deleted file mode 100644
index 9c3517aa3a5946..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-navigate-contenteditable-with-side-padding-1-chromium.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-
-1
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-not-prematurely-multi-select-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-not-prematurely-multi-select-1-chromium.txt
deleted file mode 100644
index 21ee0884f979d1..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/Writing-Flow-should-not-prematurely-multi-select-1-chromium.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-
-1
-
-
-
->
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-split-and-merge-paragraph-blocks-using-Enter-and-Backspace-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-split-and-merge-paragraph-blocks-using-Enter-and-Backspace-1-chromium.txt
deleted file mode 100644
index e6b19a3a16b457..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-split-and-merge-paragraph-blocks-using-Enter-and-Backspace-1-chromium.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-
-First
-
-
-
-Second
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-undo-split-in-one-go-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-undo-split-in-one-go-1-chromium.txt
deleted file mode 100644
index 2c788e94846abb..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-should-undo-split-in-one-go-1-chromium.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-
-12
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-18edb-roduces-more-than-one-block-on-forward-delete-2-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-18edb-roduces-more-than-one-block-on-forward-delete-2-chromium.txt
deleted file mode 100644
index 463d4ecae0e093..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-18edb-roduces-more-than-one-block-on-forward-delete-2-chromium.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-hi-item 1
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-2a1ee-roduces-more-than-one-block-on-forward-delete-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-2a1ee-roduces-more-than-one-block-on-forward-delete-1-chromium.txt
deleted file mode 100644
index 04346aeb9e959c..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-2a1ee-roduces-more-than-one-block-on-forward-delete-1-chromium.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-
-hi
-
-
-
-item 1
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-46dfa-rge-produces-more-than-one-block-on-backspace-2-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-46dfa-rge-produces-more-than-one-block-on-backspace-2-chromium.txt
deleted file mode 100644
index 463d4ecae0e093..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-46dfa-rge-produces-more-than-one-block-on-backspace-2-chromium.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-hi-item 1
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-92273-rge-produces-more-than-one-block-on-backspace-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-92273-rge-produces-more-than-one-block-on-backspace-1-chromium.txt
deleted file mode 100644
index 04346aeb9e959c..00000000000000
--- a/test/e2e/specs/editor/various/__snapshots__/splitting-and-merging-blocks-test-restore-sele-92273-rge-produces-more-than-one-block-on-backspace-1-chromium.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-
-hi
-
-
-
-item 1
-
-
-
-
-
\ No newline at end of file
diff --git a/test/e2e/specs/editor/various/splitting-merging.spec.js b/test/e2e/specs/editor/various/splitting-merging.spec.js
index 16b5225cfc8d38..1c5e12be8abb11 100644
--- a/test/e2e/specs/editor/various/splitting-merging.spec.js
+++ b/test/e2e/specs/editor/various/splitting-merging.spec.js
@@ -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();
} );
@@ -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,
@@ -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' );
@@ -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 } ) => {
@@ -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 );
} );
} );
} );
diff --git a/test/e2e/specs/editor/various/writing-flow.spec.js b/test/e2e/specs/editor/various/writing-flow.spec.js
index 0c56fe9de0b21c..44ffb33e7a00cf 100644
--- a/test/e2e/specs/editor/various/writing-flow.spec.js
+++ b/test/e2e/specs/editor/various/writing-flow.spec.js
@@ -9,7 +9,7 @@ test.use( {
},
} );
-test.describe( 'Writing Flow', () => {
+test.describe( 'Writing Flow (@firefox, @webkit)', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );
@@ -63,7 +63,42 @@ test.describe( 'Writing Flow', () => {
await expect( activeElementLocator ).toBeFocused();
await expect( activeElementLocator ).toHaveText( 'First paragraph' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: 'First paragraph' },
+ },
+ {
+ name: 'core/columns',
+ attributes: {},
+ innerBlocks: [
+ {
+ name: 'core/column',
+ attributes: {},
+ innerBlocks: [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '1st col' },
+ },
+ ],
+ },
+ {
+ name: 'core/column',
+ attributes: {},
+ innerBlocks: [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '2nd col' },
+ },
+ ],
+ },
+ ],
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: 'Second paragraph' },
+ },
+ ] );
} );
test( 'Should navigate between inner and root blocks in navigation mode', async ( {
@@ -167,7 +202,22 @@ test.describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.type( 'Before' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: 'FirstAfter' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: {
+ content: 'BeforeInsideSecondInsideAfter',
+ },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: 'BeforeThird' },
+ },
+ ] );
} );
test( 'should navigate around nested inline boundaries', async ( {
@@ -424,13 +474,15 @@ test.describe( 'Writing Flow', () => {
await pageUtils.pressKeys( 'Enter', { times: 10 } );
// Check that none of the paragraph blocks have
in them.
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject(
+ Array( 11 ).fill( {
+ name: 'core/paragraph',
+ attributes: { content: '' },
+ } )
+ );
} );
- test( 'should navigate empty paragraphs (@firefox, @webkit)', async ( {
- editor,
- page,
- } ) => {
+ test( 'should navigate empty paragraphs', async ( { editor, page } ) => {
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'Enter' );
@@ -474,7 +526,16 @@ test.describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.type( '2' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '1' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: '2' },
+ },
+ ] );
} );
test( 'should navigate contenteditable with normal line height', async ( {
@@ -489,7 +550,16 @@ test.describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowUp' );
await page.keyboard.type( '1' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '1' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: '' },
+ },
+ ] );
} );
test( 'should not prematurely multi-select', async ( {
@@ -508,7 +578,16 @@ test.describe( 'Writing Flow', () => {
await page.keyboard.up( 'Shift' );
await page.keyboard.press( 'Backspace' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '1' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: '>' },
+ },
+ ] );
} );
test( 'should merge paragraphs', async ( { editor, page } ) => {
@@ -612,7 +691,7 @@ test.describe( 'Writing Flow', () => {
` );
} );
- test( 'should preserve horizontal position when navigating vertically between blocks', async ( {
+ test( 'should preserve horizontal position when navigating vertically between blocks (-webkit)', async ( {
editor,
page,
} ) => {
@@ -674,7 +753,20 @@ test.describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowUp' );
await page.keyboard.type( '1' );
- expect( await editor.getEditedPostContent() ).toMatchSnapshot();
+ expect( await editor.getBlocks() ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: '1' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: '' },
+ },
+ {
+ name: 'core/paragraph',
+ attributes: { content: '' },
+ },
+ ] );
} );
test( 'should extend selection into paragraph for list with longer last item', async ( {
@@ -915,7 +1007,7 @@ test.describe( 'Writing Flow', () => {
` );
} );
- test( 'should move to the start of the first line on ArrowUp', async ( {
+ test( 'should move to the start of the first line on ArrowUp (-firefox)', async ( {
page,
editor,
} ) => {
@@ -949,7 +1041,7 @@ test.describe( 'Writing Flow', () => {
).toHaveText( /^\.a+$/ );
} );
- test( 'should vertically move the caret from corner to corner', async ( {
+ test( 'should vertically move the caret from corner to corner (-webkit)', async ( {
page,
editor,
} ) => {