diff --git a/plugins/woocommerce/changelog/e2e-fix-flaky-gutenberg-services-tests b/plugins/woocommerce/changelog/e2e-fix-flaky-gutenberg-services-tests new file mode 100644 index 00000000000..50932fd8833 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-fix-flaky-gutenberg-services-tests @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +E2E tests: Fix flaky Gutenberg, WC Services tests diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js index 048209f2c13..1ea6f72308b 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js @@ -6,6 +6,7 @@ const { insertBlock, transformIntoBlocks, publishPage, + openEditorSettings, } = require( '../../utils/editor' ); const simpleProductName = 'Very Simple Product'; @@ -80,13 +81,8 @@ test.describe( let canvas = await getCanvas( page ); // Open Settings sidebar if closed - if ( - await page - .getByLabel( 'Editor Settings', { exact: true } ) - .isHidden() - ) { - await canvas.getByLabel( 'Settings', { exact: true } ).click(); - } + await openEditorSettings( { page } ); + // Activate the terms and conditions checkbox await canvas.getByLabel( 'Block: Terms and Conditions' ).click(); await page.getByLabel( 'Require checkbox' ).check(); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/mini-cart.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/mini-cart.spec.js index 661bc98f7f7..573510cac3d 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/mini-cart.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/mini-cart.spec.js @@ -1,5 +1,8 @@ const { test, expect } = require( '@playwright/test' ); -const { disableWelcomeModal } = require( '../../utils/editor' ); +const { + disableWelcomeModal, + openEditorSettings, +} = require( '../../utils/editor' ); const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; const { random } = require( '../../utils/helpers' ); @@ -147,6 +150,9 @@ test.describe( .click(); await expect( page.getByLabel( 'Block: Mini-Cart' ) ).toBeVisible(); + // Open Settings sidebar if closed + await openEditorSettings( { page } ); + // customize mini cart block await page.getByLabel( 'Block: Mini-Cart' ).click(); // display total price diff --git a/plugins/woocommerce/tests/e2e-pw/utils/editor.js b/plugins/woocommerce/tests/e2e-pw/utils/editor.js index 0e44bda277e..2523983fa53 100644 --- a/plugins/woocommerce/tests/e2e-pw/utils/editor.js +++ b/plugins/woocommerce/tests/e2e-pw/utils/editor.js @@ -26,6 +26,15 @@ const disableWelcomeModal = async ( { page } ) => { } }; +const openEditorSettings = async ( { page } ) => { + // Open Settings sidebar if closed + if ( await page.getByLabel( 'Editor Settings' ).isVisible() ) { + console.log( 'Editor Settings is open, skipping action.' ); + } else { + await page.getByLabel( 'Settings', { exact: true } ).click(); + } +}; + const getCanvas = async ( page ) => { return page.frame( 'editor-canvas' ) || page; }; @@ -106,6 +115,7 @@ module.exports = { goToPageEditor, goToPostEditor, disableWelcomeModal, + openEditorSettings, getCanvas, fillPageTitle, insertBlock,