Commit 21ce889455e for woocommerce
commit 21ce889455e843a68cb2fba0762a1998c32d4def
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Mon Oct 5 18:57:00 2026 +0300
e2e tests: Speed up the slowest email editor e2e specs (#69404)
diff --git a/plugins/woocommerce/changelog/dev-testops-302-faster-email-editor-e2e b/plugins/woocommerce/changelog/dev-testops-302-faster-email-editor-e2e
new file mode 100644
index 00000000000..715a504d390
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-testops-302-faster-email-editor-e2e
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Speed up the slowest email editor e2e specs; no production change.
+
diff --git a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-loads.spec.ts b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-loads.spec.ts
index 492ab7ed3e2..4917601545b 100644
--- a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-loads.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-loads.spec.ts
@@ -13,7 +13,7 @@ import {
disableEmailEditor,
enableEmailEditor,
} from './helpers/enable-email-editor-feature';
-import { accessTheEmailEditor } from '../../utils/email';
+import { accessTheEmailEditor, openEmailPostInEditor } from '../../utils/email';
import { setOption } from '../../utils/options';
test.describe(
@@ -33,9 +33,16 @@ test.describe(
};
const accessAndTrackEmailPost = async ( page: Page ) => {
+ const [ knownPostId ] = emailPostIds;
let postId: string | null = null;
try {
- await accessTheEmailEditor( page, 'New order' );
+ // The settings page is slow, so only the first test in a worker opens
+ // the editor through it. The lock keeps the post in place until afterAll.
+ if ( knownPostId ) {
+ await openEmailPostInEditor( page, knownPostId );
+ } else {
+ await accessTheEmailEditor( page, 'New order' );
+ }
} finally {
postId = captureEmailPostId( page );
}
diff --git a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-settings-sidebar.spec.ts b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-settings-sidebar.spec.ts
index c441a6cb9fd..e59d86b36e9 100644
--- a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-settings-sidebar.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-settings-sidebar.spec.ts
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { test, expect } from '@playwright/test';
+import { test, expect, type Page } from '@playwright/test';
/**
* Internal dependencies
@@ -15,6 +15,7 @@ import {
import {
accessTheEmailEditor,
ensureEmailEditorSettingsPanelIsOpened,
+ openEmailPostInEditor,
} from '../../utils/email';
import { locks } from '../../fixtures/fixtures';
@@ -24,6 +25,23 @@ test.describe(
() => {
test.use( { storageState: ADMIN_STATE_PATH } );
+ const emailPostIds = new Map< string, string >();
+
+ // The settings page is slow, so only the first test per email in a worker
+ // opens the editor through it. The lock keeps the post in place until afterAll.
+ const openEmail = async ( page: Page, emailTitle: string ) => {
+ const knownPostId = emailPostIds.get( emailTitle );
+ if ( knownPostId ) {
+ await openEmailPostInEditor( page, knownPostId );
+ return;
+ }
+ await accessTheEmailEditor( page, emailTitle );
+ const postId = new URL( page.url() ).searchParams.get( 'post' );
+ if ( postId ) {
+ emailPostIds.set( emailTitle, postId );
+ }
+ };
+
test.beforeAll( async ( { baseURL } ) => {
await enableEmailEditor( baseURL );
} );
@@ -35,7 +53,7 @@ test.describe(
} );
test( 'Can update email status', async ( { page } ) => {
- await accessTheEmailEditor( page, 'Customer note' );
+ await openEmail( page, 'Customer note' );
await page
.getByLabel( 'Email' )
@@ -53,8 +71,17 @@ test.describe(
await expect(
page.locator( '.editor-post-status__toggle' )
).toContainText( 'Inactive' );
- // eslint-disable-next-line playwright/no-wait-for-timeout -- wait for content to be saved and updated.
- await page.waitForTimeout( 1000 );
+ await expect
+ .poll( () =>
+ page.evaluate( () => {
+ const editor = window.wp.data.select( 'core/editor' );
+ return (
+ ! editor.isSavingPost() &&
+ ! editor.isEditedPostDirty()
+ );
+ } )
+ )
+ .toBe( true );
await page.reload();
await expect(
page.locator( '.editor-post-status__toggle' )
@@ -75,7 +102,7 @@ test.describe(
test( 'Can update email subject and preview text', async ( {
page,
} ) => {
- await accessTheEmailEditor( page, 'Customer note' );
+ await openEmail( page, 'Customer note' );
await page
.getByLabel( 'Email' )
@@ -163,7 +190,7 @@ test.describe(
} );
test( 'Can update email recipients', async ( { page } ) => {
- await accessTheEmailEditor( page, 'New order' );
+ await openEmail( page, 'New order' );
await page
.getByLabel( 'Email' )
.getByRole( 'button', { name: 'Settings' } )
@@ -215,7 +242,7 @@ test.describe(
test( 'Does not show the core Content block list in the Email tab', async ( {
page,
} ) => {
- await accessTheEmailEditor( page, 'Customer note' );
+ await openEmail( page, 'Customer note' );
const emailTab = page.getByLabel( 'Email' );
await expect(
@@ -237,7 +264,7 @@ test.describe(
test( 'Shows the Content list in the Block tab of a content-only block', async ( {
page,
} ) => {
- await accessTheEmailEditor( page, 'Customer note' );
+ await openEmail( page, 'Customer note' );
// The email content replaces the post-content inner blocks when it
// loads, so wait for it before inserting a block.
await expect(
diff --git a/plugins/woocommerce/tests/e2e/utils/email.ts b/plugins/woocommerce/tests/e2e/utils/email.ts
index 1b6b076d147..e7b0a83ce07 100644
--- a/plugins/woocommerce/tests/e2e/utils/email.ts
+++ b/plugins/woocommerce/tests/e2e/utils/email.ts
@@ -134,6 +134,20 @@ export async function accessTheEmailEditor(
} );
}
+/**
+ * Open an existing email post in the email editor, skipping the slow Email settings page.
+ * Note: Ensure the block email editor feature flag is already enabled.
+ *
+ * @param {import('@playwright/test').Page } page The Playwright page.
+ * @param {string} postId The woo_email post ID.
+ */
+export async function openEmailPostInEditor( page: Page, postId: string ) {
+ await page.goto( `/wp-admin/post.php?post=${ postId }&action=edit` );
+ await expect( page.locator( '#woocommerce-email-editor' ) ).toBeVisible( {
+ timeout: 20000,
+ } );
+}
+
export async function ensureEmailEditorSettingsPanelIsOpened( page: Page ) {
const status = await page.evaluate( async () => {
const elem = document.querySelector(