Commit bc881f47e1c for woocommerce
commit bc881f47e1cc4617b15bb0529105848e51859115
Author: Lance Willett <lance@automattic.com>
Date: Thu Jun 11 06:24:04 2026 -0700
Fix Blocks E2E site editor save panel handling (#65619)
* Fix Blocks E2E site editor save panel handling
* Remove stale Gutenberg issue reference
---------
Co-authored-by: Lance Willett <lance.willett@automattic.com>
diff --git a/plugins/woocommerce/changelog/fix-blocks-site-editor-save-panel b/plugins/woocommerce/changelog/fix-blocks-site-editor-save-panel
new file mode 100644
index 00000000000..de77317c376
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-blocks-site-editor-save-panel
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Stabilize Blocks E2E site editor saves when the save panel opens with multiple dirty entities.
diff --git a/plugins/woocommerce/tests/e2e-pw/utils/blocks/editor/editor-utils.page.ts b/plugins/woocommerce/tests/e2e-pw/utils/blocks/editor/editor-utils.page.ts
index d05dc6255a8..ab5a2673ebc 100644
--- a/plugins/woocommerce/tests/e2e-pw/utils/blocks/editor/editor-utils.page.ts
+++ b/plugins/woocommerce/tests/e2e-pw/utils/blocks/editor/editor-utils.page.ts
@@ -239,30 +239,64 @@ export class Editor extends CoreEditor {
}
/**
- * This is to avoid tests failing due to two notices appearing at the same
- * time. This is an upstream issue with the `saveSiteEditorEntities` method.
- * It should be removed once the upstream issue is fixed.
- *
- * @see https://github.com/WordPress/gutenberg/issues/69042
+ * This extends the upstream `saveSiteEditorEntities` helper to handle cases
+ * where the save panel opens even when the caller expected only the current
+ * entity to be dirty.
*/
saveSiteEditorEntities = async ( {
isOnlyCurrentEntityDirty = false,
}: {
isOnlyCurrentEntityDirty?: boolean;
} = {} ) => {
- try {
- await new CoreEditor( { page: this.page } ).saveSiteEditorEntities(
- {
- isOnlyCurrentEntityDirty,
- }
- );
- } catch ( error ) {
- if (
- ! ( error instanceof Error ) ||
- ! error.message.includes( 'strict mode violation' )
- ) {
- throw error;
+ const editorTopBar = this.page.getByRole( 'region', {
+ name: 'Editor top bar',
+ } );
+ const saveButton = editorTopBar.getByRole( 'button', {
+ name: 'Save',
+ exact: true,
+ } );
+ const publishButton = editorTopBar.getByRole( 'button', {
+ name: 'Publish',
+ } );
+ const saveNoticeDismissButton = this.page
+ .getByRole( 'button', { name: 'Dismiss this notice' } )
+ .filter( { hasText: /(updated|published)\./ } );
+
+ const staleSaveNoticeCount = await saveNoticeDismissButton.count();
+ for ( let i = 0; i < staleSaveNoticeCount; i++ ) {
+ const staleSaveNotice = saveNoticeDismissButton.first();
+ if ( ! ( await staleSaveNotice.isVisible() ) ) {
+ break;
}
+ await staleSaveNotice.click();
+ }
+
+ const buttonToClick = ( await saveButton.isVisible() )
+ ? saveButton
+ : publishButton;
+
+ await buttonToClick.click();
+
+ const panelSaveButton = this.page
+ .getByRole( 'region', {
+ name: /(Editor publish|Save panel)/,
+ } )
+ .getByRole( 'button', { name: 'Save', exact: true } );
+ const saveNotice = saveNoticeDismissButton.first();
+
+ if ( isOnlyCurrentEntityDirty ) {
+ await expect(
+ panelSaveButton.or( saveNotice ).first()
+ ).toBeVisible();
+ }
+
+ if (
+ ! isOnlyCurrentEntityDirty ||
+ ( await panelSaveButton.isVisible() )
+ ) {
+ await panelSaveButton.click();
}
+
+ await expect( saveNotice ).toBeVisible();
};
}