From 29ef9cc865d7f50d6b13d99b1b09c4d01ac94417 Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Thu, 15 Oct 2026 14:12:39 +0200 Subject: [PATCH 1/4] Add comments E2E test --- .github/files/e2e-tests/e2e-matrix.js | 7 ++ .../jetpack/changelog/add-comments-e2e | 4 ++ .../plugins/jetpack/tests/e2e/package.json | 2 +- .../e2e/plugins/e2e-comments-new-hotness.php | 14 ++++ .../e2e/specs/comments/block-editor.test.ts | 67 +++++++++++++++++++ .../docker/jetpack-docker-config-default.yml | 1 + 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/add-comments-e2e create mode 100644 projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php create mode 100644 projects/plugins/jetpack/tests/e2e/specs/comments/block-editor.test.ts diff --git a/.github/files/e2e-tests/e2e-matrix.js b/.github/files/e2e-tests/e2e-matrix.js index 88527f173d84..b91eba62d705 100644 --- a/.github/files/e2e-tests/e2e-matrix.js +++ b/.github/files/e2e-tests/e2e-matrix.js @@ -30,6 +30,13 @@ const projects = [ targets: [ 'plugins/jetpack', 'packages/forms' ], buildGroup: 'jetpack-core', }, + { + project: 'Jetpack comments', + path: 'projects/plugins/jetpack/tests/e2e', + testArgs: [ 'specs/comments' ], + targets: [ 'packages/comments' ], + buildGroup: 'jetpack-core', + }, { project: 'Jetpack sync', path: 'projects/plugins/jetpack/tests/e2e', diff --git a/projects/plugins/jetpack/changelog/add-comments-e2e b/projects/plugins/jetpack/changelog/add-comments-e2e new file mode 100644 index 000000000000..595b91c7cf8b --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-comments-e2e @@ -0,0 +1,4 @@ +Significance: patch +Type: other +Comment: Add an E2E test for the Jetpack Comments block editor. + diff --git a/projects/plugins/jetpack/tests/e2e/package.json b/projects/plugins/jetpack/tests/e2e/package.json index 36481ebd4469..16a3e42028ca 100644 --- a/projects/plugins/jetpack/tests/e2e/package.json +++ b/projects/plugins/jetpack/tests/e2e/package.json @@ -3,7 +3,7 @@ "type": "module", "scripts": { "allure-report": "allure generate --clean --output ./output/allure-report ./output/allure-results && allure open ./output/allure-report", - "build": "pnpm jetpack build packages/my-jetpack js-packages/social-logos js-packages/boost-score-api js-packages/components js-packages/number-formatters js-packages/charts js-packages/social-previews packages/wp-build-polyfills packages/forms packages/assets packages/connection packages/publicize packages/blaze js-packages/ai-client plugins/jetpack -v --no-pnpm-install --production", + "build": "pnpm jetpack build packages/my-jetpack js-packages/social-logos js-packages/boost-score-api js-packages/components js-packages/number-formatters js-packages/charts js-packages/social-previews packages/wp-build-polyfills packages/forms packages/comments packages/assets packages/connection packages/publicize packages/blaze js-packages/ai-client plugins/jetpack -v --no-pnpm-install --production", "clean": "rm -rf output", "config:decrypt": "pnpm test-decrypt-default-config && pnpm test-decrypt-config", "distclean": "rm -rf node_modules", diff --git a/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php b/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php new file mode 100644 index 000000000000..5561aa0ba2b6 --- /dev/null +++ b/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php @@ -0,0 +1,14 @@ + { + await testUtils.executeWpCommand( [ 'plugin', 'activate', 'e2e-comments-new-hotness' ] ); + await testUtils.activateModule( 'comments' ); +} ); + +test.afterAll( async ( { requestUtils, testUtils } ) => { + if ( postId !== undefined ) { + await requestUtils.rest( { + method: 'DELETE', + path: `/wp/v2/posts/${ postId }`, + params: { force: true }, + } ); + } + await testUtils.deactivateModule( 'comments' ); + await testUtils.executeWpCommand( [ 'plugin', 'deactivate', 'e2e-comments-new-hotness' ] ); +} ); + +test.describe( 'Comments: Block editor', () => { + test( 'Posts a comment with a paragraph, a list, and a quote', async ( { + page, + requestUtils, + } ) => { + const post: { id: number; link: string } = await requestUtils.rest( { + method: 'POST', + path: '/wp/v2/posts', + data: { title: 'E2E Comments', status: 'publish' }, + } ); + postId = post.id; + + await test.step( 'Write the comment in the block editor', async () => { + await page.goto( post.link ); + await page.getByRole( 'textbox', { name: 'Comment' } ).click(); + + const editor = page.locator( '.jetpack-comments__editor' ); + await expect( editor.locator( '[contenteditable="true"]' ).first() ).toBeFocused(); + + await page.keyboard.type( 'Hello from E2E' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '- First item' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '> A quote' ); + + // A block that crashes on select takes the whole editor down to the plain textarea. + await expect( editor.locator( '[data-type="core/list"]' ) ).toBeVisible(); + await expect( editor.locator( '[data-type="core/quote"]' ) ).toBeVisible(); + } ); + + await test.step( 'Post it', async () => { + await page.getByRole( 'button', { name: 'Comment', exact: true } ).click(); + + await expect + .poll( async () => { + const comments = await requestUtils.rest( { + path: '/wp/v2/comments', + params: { post: post.id, context: 'edit' }, + } ); + return comments[ 0 ]?.content.raw ?? ''; + } ) + .toMatch( /Hello from E2E[\s\S]*
  • First item<\/li>[\s\S]* Date: Thu, 15 Oct 2026 18:41:20 +0200 Subject: [PATCH 2/4] Add image to comments E2E test --- .../e2e/specs/comments/block-editor.test.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/tests/e2e/specs/comments/block-editor.test.ts b/projects/plugins/jetpack/tests/e2e/specs/comments/block-editor.test.ts index f4d617fdc6c8..dcacdf36ce40 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/comments/block-editor.test.ts +++ b/projects/plugins/jetpack/tests/e2e/specs/comments/block-editor.test.ts @@ -2,6 +2,13 @@ import { expect, test } from '@automattic/_jetpack-e2e-commons/fixtures/base-tes let postId: number | undefined; +const IMAGE = 'https://example.com/e2e.png'; +// A 1x1 PNG, so the image loads without the network. +const PNG = Buffer.from( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', + 'base64' +); + test.beforeAll( async ( { testUtils } ) => { await testUtils.executeWpCommand( [ 'plugin', 'activate', 'e2e-comments-new-hotness' ] ); await testUtils.activateModule( 'comments' ); @@ -20,7 +27,7 @@ test.afterAll( async ( { requestUtils, testUtils } ) => { } ); test.describe( 'Comments: Block editor', () => { - test( 'Posts a comment with a paragraph, a list, and a quote', async ( { + test( 'Posts a comment with a paragraph, a list, a quote, and an image', async ( { page, requestUtils, } ) => { @@ -31,6 +38,8 @@ test.describe( 'Comments: Block editor', () => { } ); postId = post.id; + await page.route( IMAGE, route => route.fulfill( { contentType: 'image/png', body: PNG } ) ); + await test.step( 'Write the comment in the block editor', async () => { await page.goto( post.link ); await page.getByRole( 'textbox', { name: 'Comment' } ).click(); @@ -48,6 +57,16 @@ test.describe( 'Comments: Block editor', () => { // A block that crashes on select takes the whole editor down to the plain textarea. await expect( editor.locator( '[data-type="core/list"]' ) ).toBeVisible(); await expect( editor.locator( '[data-type="core/quote"]' ) ).toBeVisible(); + + await page.getByRole( 'button', { name: 'Add block' } ).click(); + await page.getByRole( 'menuitem', { name: 'Image' } ).click(); + await editor.getByRole( 'textbox', { name: 'URL' } ).fill( IMAGE ); + await editor.getByRole( 'button', { name: 'Apply' } ).click(); + // A failed load clears the URL, so the image must actually draw. + await expect( editor.locator( '[data-type="core/image"] img' ) ).toHaveJSProperty( + 'naturalWidth', + 1 + ); } ); await test.step( 'Post it', async () => { @@ -61,7 +80,9 @@ test.describe( 'Comments: Block editor', () => { } ); return comments[ 0 ]?.content.raw ?? ''; } ) - .toMatch( /Hello from E2E[\s\S]*
  • First item<\/li>[\s\S]*First item<\/li>[\s\S]*https:\/\/example\.com\/e2e\.png<\/figure>/ + ); } ); } ); } ); From 290c9f9769bf6702637195b5b5613250c65459f5 Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Thu, 15 Oct 2026 21:31:19 +0200 Subject: [PATCH 3/4] Drop the comments opt-in plugin --- .../tests/e2e/plugins/e2e-comments-new-hotness.php | 14 -------------- .../tests/e2e/specs/comments/block-editor.test.ts | 2 -- tools/docker/jetpack-docker-config-default.yml | 1 - 3 files changed, 17 deletions(-) delete mode 100644 projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php diff --git a/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php b/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php deleted file mode 100644 index 5561aa0ba2b6..000000000000 --- a/projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php +++ /dev/null @@ -1,14 +0,0 @@ - { - await testUtils.executeWpCommand( [ 'plugin', 'activate', 'e2e-comments-new-hotness' ] ); await testUtils.activateModule( 'comments' ); } ); @@ -23,7 +22,6 @@ test.afterAll( async ( { requestUtils, testUtils } ) => { } ); } await testUtils.deactivateModule( 'comments' ); - await testUtils.executeWpCommand( [ 'plugin', 'deactivate', 'e2e-comments-new-hotness' ] ); } ); test.describe( 'Comments: Block editor', () => { diff --git a/tools/docker/jetpack-docker-config-default.yml b/tools/docker/jetpack-docker-config-default.yml index 003bfc7ecbd0..948a6e3bcbef 100644 --- a/tools/docker/jetpack-docker-config-default.yml +++ b/tools/docker/jetpack-docker-config-default.yml @@ -73,7 +73,6 @@ e2e: projects/plugins/boost/tests/e2e/plugins/e2e-critical-css-force-errors.php: /var/www/html/wp-content/plugins/e2e-critical-css-force-errors.php projects/plugins/boost/tests/e2e/plugins/e2e-dashboard-modernization.php: /var/www/html/wp-content/plugins/e2e-dashboard-modernization.php projects/plugins/boost/tests/e2e/plugins/e2e-dashboard-jitm.php: /var/www/html/wp-content/plugins/e2e-dashboard-jitm.php - projects/plugins/jetpack/tests/e2e/plugins/e2e-comments-new-hotness.php: /var/www/html/wp-content/plugins/e2e-comments-new-hotness.php projects/plugins/paypal-payment-buttons/tests/e2e/plugins/e2e-paypal-feature-flag.php: /var/www/html/wp-content/plugins/e2e-paypal-feature-flag.php projects/plugins/premium-analytics/tests/e2e/plugins/e2e-premium-analytics-helper/: /var/www/html/wp-content/plugins/e2e-premium-analytics-helper/ tools/e2e-commons/plugins/e2e-search-test-helper.php: /var/www/html/wp-content/plugins/e2e-search-test-helper.php From 4cd75787ce4950ad15f0cd5dce267426b8e37299 Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Thu, 15 Oct 2026 22:05:09 +0200 Subject: [PATCH 4/4] Run comments E2E on Jetpack changes --- .github/files/e2e-tests/e2e-matrix.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/files/e2e-tests/e2e-matrix.js b/.github/files/e2e-tests/e2e-matrix.js index b91eba62d705..9b2bb4afc5cb 100644 --- a/.github/files/e2e-tests/e2e-matrix.js +++ b/.github/files/e2e-tests/e2e-matrix.js @@ -34,7 +34,7 @@ const projects = [ project: 'Jetpack comments', path: 'projects/plugins/jetpack/tests/e2e', testArgs: [ 'specs/comments' ], - targets: [ 'packages/comments' ], + targets: [ 'plugins/jetpack', 'packages/comments' ], buildGroup: 'jetpack-core', }, {