Commit e2144a7013 for woocommerce
commit e2144a7013e7f57c77e50d692b9d79f488f0f7f6
Author: Thomas Roberts <5656702+opr@users.noreply.github.com>
Date: Thu May 29 17:03:35 2025 +0100
Remove flaky Classic Shortcode Block E2E test and rewrite as Integration test (#58397)
diff --git a/plugins/woocommerce/changelog/wooplug-2686-flaky-test-merchant-can-transform-shortcode-block-into b/plugins/woocommerce/changelog/wooplug-2686-flaky-test-merchant-can-transform-shortcode-block-into
new file mode 100644
index 0000000000..369e00a582
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-2686-flaky-test-merchant-can-transform-shortcode-block-into
@@ -0,0 +1,5 @@
+Significance: patch
+Type: dev
+Comment: Test update only.
+
+
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/classic-shortcode/test/block.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/classic-shortcode/test/block.ts
new file mode 100644
index 0000000000..dd23dcbb2f
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/classic-shortcode/test/block.ts
@@ -0,0 +1,49 @@
+/**
+ * External dependencies
+ */
+import type { BlockAttributes } from '@wordpress/blocks';
+import '@testing-library/jest-dom';
+import { act, screen } from '@testing-library/react';
+
+/**
+ * Internal dependencies
+ */
+
+import '../';
+import '../../cart';
+import '../../checkout';
+import { initializeEditor } from '../../../../../tests/integration/helpers/integration-test-editor';
+
+async function setup( attributes: BlockAttributes ) {
+ const testBlock = [ { name: 'woocommerce/classic-shortcode', attributes } ];
+ return initializeEditor( testBlock );
+}
+
+describe( 'Classic Shortcode block', () => {
+ test( 'can convert to Cart block', async () => {
+ await setup( { shortcode: 'cart' } );
+
+ const transformButton = screen.getByRole( 'button', {
+ name: /Transform into blocks/i,
+ } );
+ await act( async () => {
+ await transformButton.click();
+ } );
+
+ expect( screen.getByLabelText( /Block: Cart/i ) ).toBeInTheDocument();
+ } );
+ test( 'can convert to Checkout block', async () => {
+ await setup( { shortcode: 'checkout' } );
+
+ const transformButton = screen.getByRole( 'button', {
+ name: /Transform into blocks/i,
+ } );
+ await act( async () => {
+ await transformButton.click();
+ } );
+
+ expect(
+ screen.getByLabelText( /Block: Checkout/i )
+ ).toBeInTheDocument();
+ } );
+} );
diff --git a/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/cart-template.block_theme.spec.ts b/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/cart-template.block_theme.spec.ts
index 6968bc3a73..dc32ae4b92 100644
--- a/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/cart-template.block_theme.spec.ts
+++ b/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/cart-template.block_theme.spec.ts
@@ -21,30 +21,3 @@ test.describe( 'Test the cart template', () => {
).toBeVisible();
} );
} );
-
-test.describe( 'Test editing the cart template', () => {
- test( 'Merchant can transform shortcode block into blocks', async ( {
- admin,
- editor,
- } ) => {
- await admin.visitSiteEditor( {
- postId: templatePath,
- postType: templateType,
- canvas: 'edit',
- } );
- await editor.setContent(
- '<!-- wp:woocommerce/classic-shortcode {"shortcode":"cart"} /-->'
- );
- await editor.canvas
- .locator( '.wp-block-woocommerce-classic-shortcode' )
- .waitFor();
- await editor.canvas
- .getByRole( 'button', { name: 'Transform into blocks' } )
- .click();
- await expect(
- editor.canvas
- .locator( 'button:has-text("Proceed to checkout")' )
- .first()
- ).toBeVisible();
- } );
-} );
diff --git a/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/checkout-template.block_theme.spec.ts b/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/checkout-template.block_theme.spec.ts
index 78c9d6a381..01f4d7e8cc 100644
--- a/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/checkout-template.block_theme.spec.ts
+++ b/plugins/woocommerce/client/blocks/tests/e2e/tests/templates/checkout-template.block_theme.spec.ts
@@ -48,28 +48,3 @@ test.describe( 'Test the checkout template', () => {
).toBeVisible();
} );
} );
-
-test.describe( 'Test editing the checkout template', () => {
- test( 'Merchant can transform shortcode block into blocks', async ( {
- admin,
- editor,
- } ) => {
- await admin.visitSiteEditor( {
- postId: templatePath,
- postType: templateType,
- canvas: 'edit',
- } );
- await editor.setContent(
- '<!-- wp:woocommerce/classic-shortcode {"shortcode":"checkout"} /-->'
- );
- await editor.canvas
- .locator( '.wp-block-woocommerce-classic-shortcode' )
- .waitFor();
- await editor.canvas
- .getByRole( 'button', { name: 'Transform into blocks' } )
- .click();
- await expect(
- editor.canvas.locator( 'button:has-text("Place order")' ).first()
- ).toBeVisible();
- } );
-} );