From 6529a7f455ba595893b7e991e9eb349874d63dd7 Mon Sep 17 00:00:00 2001 From: Ella Date: Wed, 7 Feb 2024 21:44:36 +0200 Subject: [PATCH 1/3] Footnotes: fix anchor order replacing --- packages/core-data/src/footnotes/index.js | 2 +- test/e2e/specs/editor/various/footnotes.spec.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core-data/src/footnotes/index.js b/packages/core-data/src/footnotes/index.js index b80ba65d142edb..066c0ea37a8240 100644 --- a/packages/core-data/src/footnotes/index.js +++ b/packages/core-data/src/footnotes/index.js @@ -64,7 +64,7 @@ export function updateFootnotesFromMeta( blocks, meta ) { const richTextValue = typeof value === 'string' ? RichTextData.fromHTMLString( value ) - : value; + : new RichTextData( value ); richTextValue.replacements.forEach( ( replacement ) => { if ( replacement.type === 'core/footnote' ) { diff --git a/test/e2e/specs/editor/various/footnotes.spec.js b/test/e2e/specs/editor/various/footnotes.spec.js index 52dde38cac8136..8dcda078b1f3a5 100644 --- a/test/e2e/specs/editor/various/footnotes.spec.js +++ b/test/e2e/specs/editor/various/footnotes.spec.js @@ -60,6 +60,13 @@ test.describe( 'Footnotes', () => { }, ] ); + // Check if the numbers in the editor content update. + const anchorNumber = await editor.canvas + .locator( ':root' ) + .evaluate( () => document.querySelector( '.fn' ).textContent ); + + expect( anchorNumber ).toBe( '1' ); + await editor.canvas.locator( 'p:text("first paragraph")' ).click(); await editor.showBlockToolbar(); From 5ed64a9605157409dbbca82fd7a41ab2b3b6e307 Mon Sep 17 00:00:00 2001 From: Ella Date: Wed, 7 Feb 2024 21:50:13 +0200 Subject: [PATCH 2/3] fix comment --- test/e2e/specs/editor/various/footnotes.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/editor/various/footnotes.spec.js b/test/e2e/specs/editor/various/footnotes.spec.js index 8dcda078b1f3a5..ca336fb50c44b0 100644 --- a/test/e2e/specs/editor/various/footnotes.spec.js +++ b/test/e2e/specs/editor/various/footnotes.spec.js @@ -60,7 +60,7 @@ test.describe( 'Footnotes', () => { }, ] ); - // Check if the numbers in the editor content update. + // Check if the numbers in the editor content updated. const anchorNumber = await editor.canvas .locator( ':root' ) .evaluate( () => document.querySelector( '.fn' ).textContent ); From d1ebcb3faa00c5610fe5b78c65840cf274a58f7d Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 8 Feb 2024 10:59:07 +0200 Subject: [PATCH 3/3] Use toHaveText --- test/e2e/specs/editor/various/footnotes.spec.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/e2e/specs/editor/various/footnotes.spec.js b/test/e2e/specs/editor/various/footnotes.spec.js index ca336fb50c44b0..01017b2d2ea2e6 100644 --- a/test/e2e/specs/editor/various/footnotes.spec.js +++ b/test/e2e/specs/editor/various/footnotes.spec.js @@ -61,11 +61,7 @@ test.describe( 'Footnotes', () => { ] ); // Check if the numbers in the editor content updated. - const anchorNumber = await editor.canvas - .locator( ':root' ) - .evaluate( () => document.querySelector( '.fn' ).textContent ); - - expect( anchorNumber ).toBe( '1' ); + await expect( editor.canvas.locator( '.fn' ) ).toHaveText( '1' ); await editor.canvas.locator( 'p:text("first paragraph")' ).click();