-
-
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/tests/e2e/config/custom-matchers/to-render-block.js b/tests/e2e/config/custom-matchers/to-render-block.js
index cb6eb518baa..562b2c087ec 100644
--- a/tests/e2e/config/custom-matchers/to-render-block.js
+++ b/tests/e2e/config/custom-matchers/to-render-block.js
@@ -1,3 +1,8 @@
+/**
+ * Internal dependencies
+ */
+import { getBlocksBySlug } from '../../utils.js';
+
expect.extend( {
async toRenderBlock( page, block = {} ) {
const gutenbergNotFoundError = ( await page.content() ).match(
@@ -39,11 +44,11 @@ expect.extend( {
};
}
- const blockElement = await page.$( block.class );
- if ( blockElement === null ) {
+ const blocks = await getBlocksBySlug( block.slug );
+ if ( blocks >= 1 ) {
return {
message: () =>
- `the ${ block.name || 'block' } with classname \`${
+ `${ block.name || 'block' } with classname \`${
block.class
}\` did not render.`,
pass: false,
diff --git a/tests/e2e/config/jest.setup.js b/tests/e2e/config/jest.setup.js
index 2ce19f2c536..002d3825225 100644
--- a/tests/e2e/config/jest.setup.js
+++ b/tests/e2e/config/jest.setup.js
@@ -12,6 +12,7 @@ import {
} from '@wordpress/e2e-test-utils';
import { setDefaultOptions } from 'expect-puppeteer';
import { get } from 'lodash';
+
/**
* Internal dependencies
*/
diff --git a/tests/e2e/fixtures/fixture-data.js b/tests/e2e/fixtures/fixture-data.js
index 97194702bb5..1ad81f5a625 100644
--- a/tests/e2e/fixtures/fixture-data.js
+++ b/tests/e2e/fixtures/fixture-data.js
@@ -278,7 +278,7 @@ const Settings = () => [
},
{
id: 'woocommerce_specific_allowed_countries',
- value: [ 'DZ', 'CA', 'NZ', 'ES', 'GB', 'US' ],
+ value: [ 'AL', 'DZ', 'CA', 'NZ', 'ES', 'GB', 'US' ],
},
{
id: 'woocommerce_ship_to_countries',
@@ -286,7 +286,7 @@ const Settings = () => [
},
{
id: 'woocommerce_specific_ship_to_countries',
- value: [ 'DZ', 'CA', 'NZ', 'ES', 'GB', 'US' ],
+ value: [ 'AL', 'DZ', 'CA', 'NZ', 'ES', 'GB', 'US' ],
},
{
id: 'woocommerce_enable_coupons',
diff --git a/tests/e2e/specs/backend/active-filters.test.js b/tests/e2e/specs/backend/active-filters.test.js
index 7cfd2bff722..c912b97df43 100644
--- a/tests/e2e/specs/backend/active-filters.test.js
+++ b/tests/e2e/specs/backend/active-filters.test.js
@@ -2,16 +2,19 @@
* External dependencies
*/
import {
+ switchBlockInspectorTab,
switchUserToAdmin,
- openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
-
import {
visitBlockPage,
selectBlockByName,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
+/**
+ * Internal dependencies
+ */
+import { openSettingsSidebar } from '../../utils.js';
+
const block = {
name: 'Active Filters',
slug: 'woocommerce/active-filters',
@@ -31,9 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName( block.slug );
+ await switchBlockInspectorTab( 'Settings' );
} );
it( "allows changing the block's title", async () => {
diff --git a/tests/e2e/specs/backend/attribute-filter.test.js b/tests/e2e/specs/backend/attribute-filter.test.js
index 4bda1c37ef2..5b42cb1f7a0 100644
--- a/tests/e2e/specs/backend/attribute-filter.test.js
+++ b/tests/e2e/specs/backend/attribute-filter.test.js
@@ -2,17 +2,21 @@
* External dependencies
*/
import {
+ switchBlockInspectorTab,
switchUserToAdmin,
- openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
import {
visitBlockPage,
saveOrPublish,
selectBlockByName,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
+/**
+ * Internal dependencies
+ */
+import { openSettingsSidebar } from '../../utils.js';
+
const block = {
name: 'Filter by Attribute',
slug: 'woocommerce/attribute-filter',
@@ -63,9 +67,9 @@ describe( `${ block.name } Block`, () => {
describe( 'Attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
+ await openSettingsSidebar();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await switchBlockInspectorTab( 'Settings' );
} );
it( "allows changing the block's title", async () => {
diff --git a/tests/e2e/specs/backend/cart.test.js b/tests/e2e/specs/backend/cart.test.js
index 5e177dd4f99..3e5ad553748 100644
--- a/tests/e2e/specs/backend/cart.test.js
+++ b/tests/e2e/specs/backend/cart.test.js
@@ -3,7 +3,6 @@
*/
import {
clickBlockToolbarButton,
- openDocumentSettingsSidebar,
switchUserToAdmin,
searchForBlock,
openGlobalBlockInserter,
@@ -13,20 +12,25 @@ import {
findLabelWithText,
visitBlockPage,
selectBlockByName,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { merchant } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
-import { openWidgetEditor, closeModalIfExists } from '../../utils.js';
+import {
+ openSettingsSidebar,
+ openWidgetEditor,
+ closeModalIfExists,
+} from '../../utils.js';
const block = {
name: 'Cart',
slug: 'woocommerce/cart',
class: '.wp-block-woocommerce-cart',
selectors: {
+ disabledInsertButton:
+ "//button[@aria-disabled='true']//span[text()='Cart']",
insertButton: "//button//span[text()='Cart']",
},
};
@@ -107,14 +111,22 @@ describe( `${ block.name } Block`, () => {
'//div[@data-type="woocommerce/cart-order-summary-block"]//button[@aria-label="Add block"]'
);
await addBlockButton.click();
+ await expect( page ).toFill(
+ 'input.components-search-control__input',
+ 'Table'
+ );
const tableButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Table")]'
);
+ await expect( tableButton ).not.toBeNull();
+ await expect( page ).toFill(
+ 'input.components-search-control__input',
+ 'Audio'
+ );
const audioButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Audio")]'
);
- expect( tableButton ).not.toBeNull();
- expect( audioButton ).not.toBeNull();
+ await expect( audioButton ).not.toBeNull();
// // Now check the filled cart block and expect only the Table block to be available there.
await selectBlockByName( 'woocommerce/filled-cart-block' );
@@ -122,13 +134,14 @@ describe( `${ block.name } Block`, () => {
'//div[@data-type="woocommerce/filled-cart-block"]//button[@aria-label="Add block"]'
);
await filledCartAddBlockButton.click();
+
const filledCartTableButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Table")]'
);
+ expect( filledCartTableButton ).not.toBeNull();
const filledCartAudioButton = await page.$x(
'//*[@role="option" and contains(., "Audio")]'
);
- expect( filledCartTableButton ).not.toBeNull();
expect( filledCartAudioButton ).toHaveLength( 0 );
} );
@@ -179,17 +192,14 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled(
- 'Settings'
- );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/cart-order-summary-shipping-block'
);
} );
it( 'can toggle Shipping calculator', async () => {
- const selector = ` .wc-block-components-totals-shipping__change-address__link`;
+ const selector = `.wc-block-components-totals-shipping__change-address__link`;
const toggleLabel = await findLabelWithText(
'Shipping calculator'
);
diff --git a/tests/e2e/specs/backend/checkout.test.js b/tests/e2e/specs/backend/checkout.test.js
index 8d30fc18881..28cc2296609 100644
--- a/tests/e2e/specs/backend/checkout.test.js
+++ b/tests/e2e/specs/backend/checkout.test.js
@@ -2,7 +2,6 @@
* External dependencies
*/
import {
- openDocumentSettingsSidebar,
switchUserToAdmin,
openGlobalBlockInserter,
insertBlock,
@@ -11,7 +10,6 @@ import {
findLabelWithText,
visitBlockPage,
selectBlockByName,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { merchant } from '@woocommerce/e2e-utils';
@@ -20,6 +18,7 @@ import { merchant } from '@woocommerce/e2e-utils';
*/
import {
searchForBlock,
+ openSettingsSidebar,
openWidgetEditor,
closeModalIfExists,
} from '../../utils.js';
@@ -125,10 +124,7 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled(
- 'Settings'
- );
+ await openSettingsSidebar();
await selectBlockByName( block.slug );
} );
@@ -163,7 +159,7 @@ describe( `${ block.name } Block`, () => {
'.wc-block-checkout__shipping-method button',
{ text: 'Shipping' }
);
- await openDocumentSettingsSidebar();
+ await openSettingsSidebar();
const toggleLabel = await findLabelWithText(
'Hide shipping costs until an address is entered'
);
@@ -225,10 +221,7 @@ describe( `${ block.name } Block`, () => {
describe( 'shipping address block attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled(
- 'Settings'
- );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-address-block'
);
@@ -277,10 +270,7 @@ describe( `${ block.name } Block`, () => {
describe( 'action block attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled(
- 'Settings'
- );
+ await openSettingsSidebar();
await selectBlockByName( 'woocommerce/checkout-actions-block' );
} );
diff --git a/tests/e2e/specs/backend/customer-account.test.js b/tests/e2e/specs/backend/customer-account.test.js
index 073eb8b4996..1b8c47c63ef 100644
--- a/tests/e2e/specs/backend/customer-account.test.js
+++ b/tests/e2e/specs/backend/customer-account.test.js
@@ -2,13 +2,15 @@
* External dependencies
*/
import {
+ switchBlockInspectorTab,
switchUserToAdmin,
- openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
-import {
- visitBlockPage,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { visitBlockPage } from '@woocommerce/blocks-test-utils';
+
+/**
+ * Internal dependencies
+ */
+import { openSettingsSidebar } from '../../utils.js';
const block = {
name: 'Customer account',
@@ -35,8 +37,8 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
+ await switchBlockInspectorTab( 'Settings' );
await page.click( block.class );
} );
diff --git a/tests/e2e/specs/backend/price-filter.test.js b/tests/e2e/specs/backend/price-filter.test.js
index cc142e7e95e..0c9d3a1db96 100644
--- a/tests/e2e/specs/backend/price-filter.test.js
+++ b/tests/e2e/specs/backend/price-filter.test.js
@@ -2,15 +2,19 @@
* External dependencies
*/
import {
- openDocumentSettingsSidebar,
+ switchBlockInspectorTab,
switchUserToAdmin,
} from '@wordpress/e2e-test-utils';
import {
visitBlockPage,
selectBlockByName,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
+/**
+ * Internal dependencies
+ */
+import { openSettingsSidebar } from '../../utils.js';
+
const block = {
name: 'Filter by Price',
slug: 'woocommerce/price-filter',
@@ -30,11 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'Attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled(
- 'Settings'
- );
+ await openSettingsSidebar();
await selectBlockByName( block.slug );
+ await switchBlockInspectorTab( 'Settings' );
} );
it( "allows changing the block's title", async () => {
diff --git a/tests/e2e/specs/backend/product-categories.test.js b/tests/e2e/specs/backend/product-categories.test.js
index 058692eeeca..6b607a0b13a 100644
--- a/tests/e2e/specs/backend/product-categories.test.js
+++ b/tests/e2e/specs/backend/product-categories.test.js
@@ -2,7 +2,6 @@
* External dependencies
*/
import { getAllBlocks, switchUserToAdmin } from '@wordpress/e2e-test-utils';
-
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/**
diff --git a/tests/e2e/specs/backend/product-query.test.ts b/tests/e2e/specs/backend/product-query.test.ts
index 5e2dd9dfd75..e7231eb1bf6 100644
--- a/tests/e2e/specs/backend/product-query.test.ts
+++ b/tests/e2e/specs/backend/product-query.test.ts
@@ -5,13 +5,9 @@ import {
getAllBlocks,
switchUserToAdmin,
canvas,
- openDocumentSettingsSidebar,
openListView,
} from '@wordpress/e2e-test-utils';
-import {
- visitBlockPage,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
@@ -20,6 +16,7 @@ import {
insertBlockDontWaitForInsertClose,
GUTENBERG_EDITOR_CONTEXT,
describeOrSkip,
+ openSettingsSidebar,
} from '../../utils';
const block = {
@@ -53,8 +50,7 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
it.skip( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => {
await visitBlockPage( `${ block.name } Block` );
const canvasEl = canvas();
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await openListView();
await page.click(
'.block-editor-list-view-block__contents-container a.components-button'
diff --git a/tests/e2e/specs/backend/product-query/advanced-filters.test.ts b/tests/e2e/specs/backend/product-query/advanced-filters.test.ts
index 36d4e45b34e..f7325217d41 100644
--- a/tests/e2e/specs/backend/product-query/advanced-filters.test.ts
+++ b/tests/e2e/specs/backend/product-query/advanced-filters.test.ts
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
+import { ensureSidebarOpened, canvas } from '@wordpress/e2e-test-utils';
import {
saveOrPublish,
selectBlockByName,
@@ -8,11 +9,9 @@ import {
getFixtureProductsData,
shopper,
getToggleIdByLabel,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { ElementHandle } from 'puppeteer';
import { setCheckbox } from '@woocommerce/e2e-utils';
-import { ensureSidebarOpened, canvas } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
@@ -48,7 +47,6 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
await resetProductQueryBlockPage();
await ensureSidebarOpened();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
$productFiltersPanel = await findToolsPanelWithTitle(
'Advanced Filters'
);
diff --git a/tests/e2e/specs/backend/product-query/popular-filters.test.ts b/tests/e2e/specs/backend/product-query/popular-filters.test.ts
index 0a393d29e76..86bb8241716 100644
--- a/tests/e2e/specs/backend/product-query/popular-filters.test.ts
+++ b/tests/e2e/specs/backend/product-query/popular-filters.test.ts
@@ -11,7 +11,6 @@ import {
selectBlockByName,
visitBlockPage,
saveOrPublish,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/**
@@ -29,7 +28,6 @@ import {
const getPopularFilterPanel = async () => {
await ensureSidebarOpened();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
return await findSidebarPanelWithTitle( 'Popular Filters' );
};
diff --git a/tests/e2e/specs/backend/rating-filter.test.js b/tests/e2e/specs/backend/rating-filter.test.js
index 1bd04ea9106..324b37edf68 100644
--- a/tests/e2e/specs/backend/rating-filter.test.js
+++ b/tests/e2e/specs/backend/rating-filter.test.js
@@ -2,17 +2,15 @@
* External dependencies
*/
import {
+ switchBlockInspectorTab,
switchUserToAdmin,
- openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
-import {
- visitBlockPage,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
+import { openSettingsSidebar } from '../../utils';
const block = {
name: 'Filter by Rating',
@@ -32,9 +30,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await page.click( block.class );
+ await switchBlockInspectorTab( 'Settings' );
} );
it( 'product count can be toggled', async () => {
diff --git a/tests/e2e/specs/backend/site-editing-templates.test.js b/tests/e2e/specs/backend/site-editing-templates.test.js
index ccc033c3ae7..7abef3e64b9 100644
--- a/tests/e2e/specs/backend/site-editing-templates.test.js
+++ b/tests/e2e/specs/backend/site-editing-templates.test.js
@@ -128,7 +128,7 @@ const SELECTORS = {
const CUSTOMIZED_STRING = 'My awesome customization';
const WOOCOMMERCE_ID = 'woocommerce/woocommerce';
-const WOOCOMMERCE_PARSED_ID = 'WooCommerce';
+const WOOCOMMERCE_PARSED_ID = 'woocommerce/woocommerceCustomized';
describe( 'Store Editing Templates', () => {
useTheme( 'emptytheme' );
diff --git a/tests/e2e/specs/backend/stock-filter.test.js b/tests/e2e/specs/backend/stock-filter.test.js
index a8f65050fd5..626899eeb43 100644
--- a/tests/e2e/specs/backend/stock-filter.test.js
+++ b/tests/e2e/specs/backend/stock-filter.test.js
@@ -2,17 +2,18 @@
* External dependencies
*/
import {
+ switchBlockInspectorTab,
switchUserToAdmin,
- openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
-import {
- visitBlockPage,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
+/**
+ * Internal dependencies
+ */
+import { openSettingsSidebar } from '../../utils';
import { findLabelWithText } from '../../../utils';
const block = {
@@ -33,9 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => {
beforeEach( async () => {
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await page.click( block.class );
+ await switchBlockInspectorTab( 'Settings' );
} );
it( 'product count can be toggled', async () => {
diff --git a/tests/e2e/specs/merchant/checkout-terms.test.js b/tests/e2e/specs/merchant/checkout-terms.test.js
index 70824729214..0b92e0828ec 100644
--- a/tests/e2e/specs/merchant/checkout-terms.test.js
+++ b/tests/e2e/specs/merchant/checkout-terms.test.js
@@ -1,22 +1,17 @@
/**
* External dependencies
*/
-import {
- merchant,
- openDocumentSettingsSidebar,
- setCheckbox,
- unsetCheckbox,
-} from '@woocommerce/e2e-utils';
+import { merchant, setCheckbox, unsetCheckbox } from '@woocommerce/e2e-utils';
import {
visitBlockPage,
selectBlockByName,
saveOrPublish,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
+import { openSettingsSidebar } from '../../utils';
import {
shopper,
preventCompatibilityNotice,
@@ -66,8 +61,7 @@ describe( 'Merchant → Checkout → Can adjust T&S and Privacy Policy options',
await preventCompatibilityNotice();
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName( 'woocommerce/checkout-terms-block' );
const [ termsCheckboxLabel ] = await page.$x(
`//label[contains(text(), "Require checkbox") and contains(@class, "components-toggle-control__label")]`
@@ -106,8 +100,7 @@ describe( 'Merchant → Checkout → Can adjust T&S and Privacy Policy options',
// Deactivate checkboxes for T&S and Privacy Policy links.
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName( 'woocommerce/checkout-terms-block' );
await unsetCheckbox( termsCheckboxId );
await saveOrPublish();
diff --git a/tests/e2e/specs/shopper/active-filters.test.ts b/tests/e2e/specs/shopper/active-filters.test.ts
index 71752d12cee..1793f050bcd 100644
--- a/tests/e2e/specs/shopper/active-filters.test.ts
+++ b/tests/e2e/specs/shopper/active-filters.test.ts
@@ -11,13 +11,13 @@ import {
} from '@wordpress/e2e-test-utils';
import { SHOP_PAGE } from '@woocommerce/e2e-utils';
import { Frame, Page } from 'puppeteer';
-import { insertBlockUsingSlash } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import {
goToTemplateEditor,
+ insertAllProductsBlock,
useTheme,
saveTemplate,
waitForAllProductsBlockLoaded,
@@ -96,7 +96,7 @@ describe( 'Shopper → Active Filters Block', () => {
} );
await insertBlocks();
- await insertBlockUsingSlash( 'All Products' );
+ await insertAllProductsBlock();
await configureAttributeFilterBlock( page );
await publishPost();
@@ -182,7 +182,7 @@ describe( 'Shopper → Active Filters Block', () => {
expect( isRefreshed ).not.toHaveBeenCalled();
} );
- it( 'Clicking "Clear All" button removes all active filter', async () => {
+ it( 'Clicking "Clear All" button removes all active filters', async () => {
const isRefreshed = jest.fn( () => void 0 );
await page.waitForSelector( block.class );
await page.waitForSelector(
@@ -317,7 +317,7 @@ describe( 'Shopper → Active Filters Block', () => {
await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME );
} );
- it( 'Clicking "Clear All" button removes all active filter and the page redirects to the base URL', async () => {
+ it( 'Clicking "Clear All" button removes all active filters and the page redirects to the base URL', async () => {
const isRefreshed = jest.fn( () => void 0 );
page.on( 'load', isRefreshed );
await page.waitForSelector( selectors.frontend.stockFilterBlock );
diff --git a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js
index f1e9e726db7..c0cf8483e9a 100644
--- a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js
+++ b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js
@@ -3,7 +3,6 @@
*/
import {
merchant,
- openDocumentSettingsSidebar,
setCheckbox,
unsetCheckbox,
withRestApi,
@@ -13,9 +12,9 @@ import {
selectBlockByName,
saveOrPublish,
getToggleIdByLabel,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { visitAdminPage } from '@wordpress/e2e-test-utils';
+
/**
* Internal dependencies
*/
@@ -30,7 +29,7 @@ import {
BASE_URL,
} from '../../../../utils';
import { merchant as merchantUtils } from '../../../../utils/merchant';
-import { createCoupon } from '../../../utils';
+import { createCoupon, openSettingsSidebar } from '../../../utils';
let coupon;
@@ -154,8 +153,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice();
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-address-block'
);
@@ -168,8 +166,7 @@ describe( 'Shopper → Checkout', () => {
afterAll( async () => {
await shopper.block.emptyCart();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-address-block'
);
@@ -200,6 +197,36 @@ describe( 'Shopper → Checkout', () => {
await shopper.block.verifyShippingDetails( SHIPPING_DETAILS );
await shopper.block.verifyBillingDetails( BILLING_DETAILS );
} );
+ it( 'User can add postcodes for different countries', async () => {
+ await shopper.block.goToShop();
+ await shopper.addToCartFromShopPage( SIMPLE_PHYSICAL_PRODUCT_NAME );
+ await shopper.block.goToCheckout();
+ await page.waitForSelector(
+ '.wc-block-checkout__use-address-for-billing input[type="checkbox"]'
+ );
+ await unsetCheckbox(
+ '.wc-block-checkout__use-address-for-billing input[type="checkbox"]'
+ );
+ await shopper.block.fillShippingDetails( {
+ ...SHIPPING_DETAILS,
+ country: 'Albania',
+ state: 'Berat',
+ postcode: '1234',
+ } );
+
+ await shopper.block.fillBillingDetails( {
+ ...BILLING_DETAILS,
+ country: 'United Kingdom',
+ postcode: 'SW1 1AA',
+ } );
+
+ await expect( page ).not.toMatchElement(
+ '.wc-block-components-validation-error p',
+ {
+ text: 'Please enter a valid postcode',
+ }
+ );
+ } );
} );
describe( 'Checkout Form Errors', () => {
@@ -310,8 +337,7 @@ describe( 'Shopper → Checkout', () => {
afterAll( async () => {
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
@@ -379,8 +405,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice();
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
@@ -438,8 +463,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice();
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
@@ -469,8 +493,7 @@ describe( 'Shopper → Checkout', () => {
await merchantUtils.enableLocalPickup();
await merchantUtils.addLocalPickupLocation();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
@@ -514,8 +537,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice();
await merchant.login();
await visitBlockPage( 'Checkout Block' );
- await openDocumentSettingsSidebar();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await openSettingsSidebar();
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
diff --git a/tests/e2e/specs/shopper/filter-products-by-attribute.test.ts b/tests/e2e/specs/shopper/filter-products-by-attribute.test.ts
index 2431491f3df..74400fa166c 100644
--- a/tests/e2e/specs/shopper/filter-products-by-attribute.test.ts
+++ b/tests/e2e/specs/shopper/filter-products-by-attribute.test.ts
@@ -8,23 +8,21 @@ import {
insertBlock,
switchUserToAdmin,
publishPost,
- ensureSidebarOpened,
} from '@wordpress/e2e-test-utils';
-import {
- selectBlockByName,
- insertBlockUsingSlash,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { selectBlockByName } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import {
BASE_URL,
+ enableApplyFiltersButton,
goToTemplateEditor,
+ insertAllProductsBlock,
saveTemplate,
useTheme,
waitForAllProductsBlockLoaded,
+ waitForCanvas,
} from '../../utils';
import { saveOrPublish } from '../../../utils';
@@ -36,8 +34,6 @@ const block = {
editor: {
firstAttributeInTheList:
'.woocommerce-search-list__list > li > label > input.woocommerce-search-list__item-input',
- filterButtonToggle:
- '//label[text()="Show \'Apply filters\' button"]',
doneButton: '.wc-block-attribute-filter__selection > button',
},
frontend: {
@@ -71,7 +67,7 @@ describe( `${ block.name } Block`, () => {
title: block.name,
} );
- await insertBlockUsingSlash( 'All Products' );
+ await insertAllProductsBlock();
await insertBlock( block.name );
const canvasEl = canvas();
@@ -190,14 +186,9 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId,
} );
- await ensureSidebarOpened();
+ await waitForCanvas();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
-
- const [ filterButtonToggle ] = await page.$x(
- block.selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
+ await enableApplyFiltersButton();
await saveTemplate();
await goToShopPage();
@@ -309,14 +300,10 @@ describe( `${ block.name } Block`, () => {
it( 'should refresh the page only if the user clicks on button', async () => {
await page.goto( editorPageUrl );
- await ensureSidebarOpened();
- await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
- const [ filterButtonToggle ] = await page.$x(
- block.selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
+ await waitForCanvas();
+ await selectBlockByName( block.slug );
+ await enableApplyFiltersButton();
await saveOrPublish();
await page.goto( frontedPageUrl );
diff --git a/tests/e2e/specs/shopper/filter-products-by-price.test.ts b/tests/e2e/specs/shopper/filter-products-by-price.test.ts
index cd5ca7c68e4..c9a68fccf2f 100644
--- a/tests/e2e/specs/shopper/filter-products-by-price.test.ts
+++ b/tests/e2e/specs/shopper/filter-products-by-price.test.ts
@@ -7,22 +7,20 @@ import {
insertBlock,
switchUserToAdmin,
publishPost,
- ensureSidebarOpened,
} from '@wordpress/e2e-test-utils';
-import {
- selectBlockByName,
- insertBlockUsingSlash,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
-} from '@woocommerce/blocks-test-utils';
+import { selectBlockByName } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import {
BASE_URL,
+ enableApplyFiltersButton,
goToTemplateEditor,
+ insertAllProductsBlock,
saveTemplate,
useTheme,
+ waitForCanvas,
waitForAllProductsBlockLoaded,
} from '../../utils';
import { clickLink, saveOrPublish } from '../../../utils';
@@ -32,10 +30,6 @@ const block = {
slug: 'woocommerce/price-filter',
class: '.wc-block-price-filter',
selectors: {
- editor: {
- filterButtonToggle:
- '//label[text()="Show \'Apply filters\' button"]',
- },
frontend: {
priceMaxAmount: '.wc-block-price-filter__amount--max',
productsList: '.wc-block-grid__products > li',
@@ -75,7 +69,7 @@ describe( `${ block.name } Block`, () => {
} );
await insertBlock( block.name );
- await insertBlockUsingSlash( 'All Products' );
+ await insertAllProductsBlock();
await insertBlock( 'Active Filters' );
await publishPost();
@@ -186,17 +180,9 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId,
} );
+ await waitForCanvas();
await selectBlockByName( block.slug );
- await ensureSidebarOpened();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
-
- await page.waitForXPath(
- block.selectors.editor.filterButtonToggle
- );
- const [ filterButtonToggle ] = await page.$x(
- block.selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
+ await enableApplyFiltersButton();
await saveTemplate();
await goToShopPage();
@@ -298,17 +284,9 @@ describe( `${ block.name } Block`, () => {
it( 'should refresh the page only if the user click on button', async () => {
await page.goto( editorPageUrl );
- await ensureSidebarOpened();
+ await waitForCanvas();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
- await page.waitForXPath(
- block.selectors.editor.filterButtonToggle
- );
- const [ filterButtonToggle ] = await page.$x(
- block.selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
-
+ await enableApplyFiltersButton();
await saveOrPublish();
await page.goto( frontedPageUrl );
diff --git a/tests/e2e/specs/shopper/filter-products-by-rating.test.ts b/tests/e2e/specs/shopper/filter-products-by-rating.test.ts
index 80a0a02151b..fe43f77985f 100644
--- a/tests/e2e/specs/shopper/filter-products-by-rating.test.ts
+++ b/tests/e2e/specs/shopper/filter-products-by-rating.test.ts
@@ -5,16 +5,15 @@ import {
createNewPost,
deleteAllTemplates,
insertBlock,
+ switchBlockInspectorTab,
switchUserToAdmin,
publishPost,
ensureSidebarOpened,
} from '@wordpress/e2e-test-utils';
import {
selectBlockByName,
- insertBlockUsingSlash,
saveOrPublish,
getToggleIdByLabel,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { setCheckbox } from '@woocommerce/e2e-utils';
@@ -23,7 +22,9 @@ import { setCheckbox } from '@woocommerce/e2e-utils';
*/
import {
BASE_URL,
+ enableApplyFiltersButton,
goToTemplateEditor,
+ insertAllProductsBlock,
saveTemplate,
useTheme,
waitForAllProductsBlockLoaded,
@@ -35,10 +36,6 @@ const block = {
slug: 'woocommerce/rating-filter',
class: '.wc-block-rating-filter',
selectors: {
- editor: {
- filterButtonToggle:
- '//label[text()="Show \'Apply filters\' button"]',
- },
frontend: {
productsList: '.wc-block-grid__products > li',
queryProductsList: '.wp-block-post-template > li',
@@ -70,7 +67,7 @@ describe( `${ block.name } Block`, () => {
} );
await insertBlock( block.name );
- await insertBlockUsingSlash( 'All Products' );
+ await insertAllProductsBlock();
await publishPost();
link = await page.evaluate( () =>
@@ -162,17 +159,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas();
await selectBlockByName( block.slug );
- await ensureSidebarOpened();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
-
- await page.waitForXPath(
- block.selectors.editor.filterButtonToggle
- );
-
- const [ filterButtonToggle ] = await page.$x(
- selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
+ await enableApplyFiltersButton();
await saveTemplate();
await goToShopPage();
@@ -271,7 +258,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas();
await ensureSidebarOpened();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await switchBlockInspectorTab( 'Settings' );
await setCheckbox(
await getToggleIdByLabel( "Show 'Apply filters' button", 1 )
);
diff --git a/tests/e2e/specs/shopper/filter-products-by-stock.test.ts b/tests/e2e/specs/shopper/filter-products-by-stock.test.ts
index 7fdacc9a793..61283a76584 100644
--- a/tests/e2e/specs/shopper/filter-products-by-stock.test.ts
+++ b/tests/e2e/specs/shopper/filter-products-by-stock.test.ts
@@ -5,16 +5,15 @@ import {
createNewPost,
deleteAllTemplates,
insertBlock,
+ switchBlockInspectorTab,
switchUserToAdmin,
publishPost,
ensureSidebarOpened,
} from '@wordpress/e2e-test-utils';
import {
selectBlockByName,
- insertBlockUsingSlash,
getToggleIdByLabel,
saveOrPublish,
- switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { setCheckbox } from '@woocommerce/e2e-utils';
@@ -23,7 +22,9 @@ import { setCheckbox } from '@woocommerce/e2e-utils';
*/
import {
BASE_URL,
+ enableApplyFiltersButton,
goToTemplateEditor,
+ insertAllProductsBlock,
saveTemplate,
useTheme,
waitForAllProductsBlockLoaded,
@@ -35,10 +36,6 @@ const block = {
slug: 'woocommerce/stock-filter',
class: '.wc-block-stock-filter',
selectors: {
- editor: {
- filterButtonToggle:
- '//label[text()="Show \'Apply filters\' button"]',
- },
frontend: {
productsList: '.wc-block-grid__products > li',
classicProductsList: '.products.columns-3 > li',
@@ -69,7 +66,7 @@ describe( `${ block.name } Block`, () => {
} );
await insertBlock( block.name );
- await insertBlockUsingSlash( 'All Products' );
+ await insertAllProductsBlock();
await publishPost();
link = await page.evaluate( () =>
@@ -168,16 +165,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas();
await selectBlockByName( block.slug );
- await ensureSidebarOpened();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
- await page.waitForXPath(
- block.selectors.editor.filterButtonToggle
- );
-
- const [ filterButtonToggle ] = await page.$x(
- selectors.editor.filterButtonToggle
- );
- await filterButtonToggle.click();
+ await enableApplyFiltersButton();
await saveTemplate();
await goToShopPage();
@@ -276,7 +264,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas();
await ensureSidebarOpened();
await selectBlockByName( block.slug );
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
+ await switchBlockInspectorTab( 'Settings' );
await setCheckbox(
await getToggleIdByLabel( "Show 'Apply filters' button" )
);
diff --git a/tests/e2e/specs/shopper/product-query/product-query-with-templates.test.ts b/tests/e2e/specs/shopper/product-query/product-query-with-templates.test.ts
index 9328004f709..bfd948485f3 100644
--- a/tests/e2e/specs/shopper/product-query/product-query-with-templates.test.ts
+++ b/tests/e2e/specs/shopper/product-query/product-query-with-templates.test.ts
@@ -6,8 +6,6 @@ import {
ensureSidebarOpened,
} from '@wordpress/e2e-test-utils';
-import { switchBlockInspectorTabWhenGutenbergIsInstalled } from '@woocommerce/blocks-test-utils';
-
/**
* Internal dependencies
*/
@@ -20,7 +18,6 @@ import {
import {
addProductQueryBlock,
block,
- configureProductQueryBlock,
getProductsNameFromClassicTemplate,
getProductsNameFromProductQuery,
toggleInheritQueryFromTemplateSetting,
@@ -39,7 +36,6 @@ describe( `${ block.name } Block`, () => {
} );
await ensureSidebarOpened();
await addProductQueryBlock();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
} );
it( 'when Inherit Query from template is disabled all the settings that customize the query should be hidden', async () => {
@@ -55,7 +51,7 @@ describe( `${ block.name } Block`, () => {
} );
it( 'when Inherit Query from template is enabled all the settings that customize the query should be hidden', async () => {
- await configureProductQueryBlock();
+ await ensureSidebarOpened();
const popularFilterEl = await page.$(
block.selectors.editor.popularFilter
@@ -78,7 +74,7 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId,
} );
await addProductQueryBlock();
- await configureProductQueryBlock();
+ await ensureSidebarOpened();
await page.waitForNetworkIdle();
await saveTemplate();
await page.waitForNetworkIdle();
@@ -107,7 +103,7 @@ describe( `${ block.name } Block`, () => {
postId: taxonomyProductCategory,
} );
await addProductQueryBlock();
- await configureProductQueryBlock();
+ await ensureSidebarOpened();
await page.waitForNetworkIdle();
await saveTemplate();
await page.waitForNetworkIdle();
@@ -139,7 +135,7 @@ describe( `${ block.name } Block`, () => {
postId: tagProductCategory,
} );
await addProductQueryBlock();
- await configureProductQueryBlock();
+ await ensureSidebarOpened();
await page.waitForNetworkIdle();
await saveTemplate();
await page.waitForNetworkIdle();
@@ -171,7 +167,7 @@ describe( `${ block.name } Block`, () => {
postId: productSearchResults,
} );
await addProductQueryBlock();
- await configureProductQueryBlock();
+ await ensureSidebarOpened();
await page.waitForNetworkIdle();
await saveTemplate();
await page.waitForNetworkIdle();
diff --git a/tests/e2e/specs/shopper/product-query/utils.ts b/tests/e2e/specs/shopper/product-query/utils.ts
index 08c86c01b81..da8e3f2b30b 100644
--- a/tests/e2e/specs/shopper/product-query/utils.ts
+++ b/tests/e2e/specs/shopper/product-query/utils.ts
@@ -1,8 +1,7 @@
/**
* External dependencies
*/
-import { insertBlock, ensureSidebarOpened } from '@wordpress/e2e-test-utils';
-import { switchBlockInspectorTabWhenGutenbergIsInstalled } from '@woocommerce/blocks-test-utils';
+import { insertBlock } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
@@ -39,11 +38,6 @@ export const toggleInheritQueryFromTemplateSetting = async () => {
await button.click();
};
-export const configureProductQueryBlock = async () => {
- await ensureSidebarOpened();
- await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
-};
-
export const getProductsNameFromClassicTemplate = async () => {
const products = await page.$$(
block.selectors.frontend.classicProductsListName
diff --git a/tests/e2e/utils.js b/tests/e2e/utils.js
index 9184b226cb3..cc36c9b1525 100644
--- a/tests/e2e/utils.js
+++ b/tests/e2e/utils.js
@@ -4,13 +4,17 @@
import { Coupon, HTTPClientFactory } from '@woocommerce/api';
import config from 'config';
import {
+ canvas,
disableSiteEditorWelcomeGuide,
+ ensureSidebarOpened,
openGlobalBlockInserter,
+ switchBlockInspectorTab,
switchUserToAdmin,
visitAdminPage,
pressKeyWithModifier,
searchForBlock as searchForFSEBlock,
enterEditMode,
+ getAllBlocks,
} from '@wordpress/e2e-test-utils';
import { addQueryArgs } from '@wordpress/url';
import { WP_ADMIN_DASHBOARD } from '@woocommerce/e2e-utils';
@@ -69,6 +73,13 @@ const SELECTORS = {
editButton:
'.edit-site-site-hub__edit-button[aria-label="Open the editor"]',
},
+ editor: {
+ filterButtonToggle: '//label[text()="Show \'Apply filters\' button"]',
+ },
+ frontend: {
+ XPathSubmitButton:
+ "//*[contains(@class,'wc-block-components-filter-submit-button')]",
+ },
};
/**
@@ -149,20 +160,17 @@ export const isBlockInsertedInWidgetsArea = async ( blockName ) => {
};
/**
- * Visits site editor dependening on used WordPress version and how Gutenberg is installed.
+ * Visits site editor depending on used WordPress version and how Gutenberg is installed.
*
* @param {Object} params Query parameters to add to the URL.
* @param {string} [params.postId] ID of the template if we want to access template editor.
* @param {'wp_template' | 'wp_template_part'} [params.postType='wp_template'] Type of template.
+ * @param {string} [params.path] Navigation path.
*/
export async function goToSiteEditor( params = {} ) {
await visitAdminPage( 'site-editor.php', addQueryArgs( '', params ) );
- // @todo Remove the Gutenberg guard clause in goToSiteEditor when WP 6.2 is released.
- if (
- GUTENBERG_EDITOR_CONTEXT === 'gutenberg' &&
- ( params?.postId || Object.keys( params ).length === 0 )
- ) {
+ if ( params?.postId || Object.keys( params ).length === 0 ) {
await enterEditMode();
}
}
@@ -198,7 +206,12 @@ export async function goToTemplatesList( {
postType = 'wp_template',
waitFor = 'list',
} = {} ) {
- await goToSiteEditor( { postType } );
+ await goToSiteEditor( {
+ postType,
+ // In WP 6.2, if postId is not defined, the route expects `path` instead
+ // of `postType`.
+ path: `/${ postType }/all`,
+ } );
if ( waitFor === 'actions' ) {
await page.waitForSelector(
@@ -441,3 +454,97 @@ export const waitForAllProductsBlockLoaded = async () => {
*/
export const describeOrSkip = ( condition ) =>
condition ? describe : describe.skip;
+
+/**
+ * Get all blocks in the document that match a certain slug.
+ *
+ * @param {string} slug Slug of the blocks to get.
+ *
+ * @return {Promise<{}>} Promise resolving with an array containing all blocks in
+ * the document that match a certain slug.
+ */
+export const getBlocksBySlug = async ( slug ) => {
+ const blocks = await getAllBlocks();
+ return blocks.filter( ( { name } ) => name === slug );
+};
+
+/**
+ * Insert the All Products block using the global inserter. This util is needed
+ * because inserting the All Products block using the `insertBlock()` util
+ * causes time outs.
+ */
+export const insertAllProductsBlock = async () => {
+ const searchTerm = 'All Products';
+
+ await searchForBlock( searchTerm );
+
+ // Wait for the default block list to disappear to prevent its items from
+ // being considered as search results. This is needed since we're debouncing
+ // search request.
+ await page.waitForSelector( '.block-editor-inserter__block-list', {
+ hidden: true,
+ } );
+
+ const insertButton = await page.waitForXPath(
+ `//*[@role='option' and contains(., '${ searchTerm }')]`
+ );
+ if ( ! insertButton ) {
+ throw new Error( `Could not find the "${ searchTerm }" block` );
+ }
+ insertButton?.click();
+};
+
+/**
+ * Clicks on the button in the header which opens Document Settings sidebar when it is closed.
+ * Based on https://github.com/WordPress/gutenberg/blob/trunk/packages/e2e-test-utils/src/open-document-settings-sidebar.js,
+ * but updates the selector so it works in WP 6.2 without GB.
+ */
+export async function openSettingsSidebar() {
+ const toggleButton = await page.waitForSelector(
+ '.edit-post-header__settings button[aria-label="Settings"]'
+ );
+
+ const isClosed = await page.evaluate(
+ ( element ) => element.getAttribute( 'aria-expanded' ) === 'false',
+ toggleButton
+ );
+
+ if ( isClosed ) {
+ await toggleButton.click();
+ await page.waitForSelector( '.edit-post-sidebar' );
+ }
+}
+
+/**
+ * Enables the `Show 'Apply filters' button` toggle.
+ */
+export const enableApplyFiltersButton = async () => {
+ await ensureSidebarOpened();
+ await switchBlockInspectorTab( 'Settings' );
+
+ await page.waitForXPath( SELECTORS.editor.filterButtonToggle );
+
+ const [ filterButtonToggle ] = await page.$x(
+ SELECTORS.editor.filterButtonToggle
+ );
+ if ( ! filterButtonToggle ) {
+ throw new Error( "'Apply filters' toggle not found via XPath." );
+ }
+ await filterButtonToggle.click();
+
+ // If for some reason click didn't work (it seems to happen intermittently),
+ // click on the toggle via JS.
+ await page.evaluate( () => {
+ const toggle = document.querySelector(
+ '.components-toggle-control:last-child .components-form-toggle__input'
+ );
+ if ( ! toggle ) {
+ throw new Error( "'Apply filters' toggle not found via CSS." );
+ }
+ if ( ! toggle.checked ) {
+ toggle.click();
+ }
+ } );
+
+ await canvas().waitForXPath( SELECTORS.frontend.XPathSubmitButton );
+};
diff --git a/tests/utils/index.js b/tests/utils/index.js
index 5093bacb05d..615bd8b98db 100644
--- a/tests/utils/index.js
+++ b/tests/utils/index.js
@@ -22,6 +22,4 @@ export { findToolsPanelWithTitle } from './find-tools-panel-with-title';
export { getFormElementIdByLabel } from './get-form-element-id-by-label';
export { getToggleIdByLabel } from './get-toggle-id-by-label';
export { insertBlockUsingQuickInserter } from './insert-block-using-quick-inserter';
-export { insertBlockUsingSlash } from './insert-block-using-slash';
export { insertShortcodeBlock } from './insert-shortcode-block';
-export { switchBlockInspectorTabWhenGutenbergIsInstalled } from './switch-block-inspector-tab-when-gutenberg-is-installed';
diff --git a/tests/utils/insert-block-using-slash.ts b/tests/utils/insert-block-using-slash.ts
deleted file mode 100644
index 11ce7b95fa7..00000000000
--- a/tests/utils/insert-block-using-slash.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * External dependencies
- */
-import { canvas, insertBlock } from '@wordpress/e2e-test-utils';
-
-/**
- * Internal dependencies
- */
-import SELECTORS from './selectors';
-
-export const insertBlockUsingSlash = async ( blockTitle: string ) => {
- await insertBlock( 'Paragraph' );
- await canvas().keyboard.type( `/${ blockTitle }` );
- await canvas().waitForSelector( SELECTORS.popover );
- await canvas().keyboard.press( 'Enter' );
-};
diff --git a/tests/utils/shopper.js b/tests/utils/shopper.js
index e1b969dce33..99855e58b3d 100644
--- a/tests/utils/shopper.js
+++ b/tests/utils/shopper.js
@@ -290,13 +290,18 @@ export const shopper = {
await expect( page ).toFill( '#billing-address_1', customerBillingDetails.addressfirstline );
await expect( page ).toFill( '#billing-address_2', customerBillingDetails.addresssecondline );
await expect( page ).toFill( '#billing-city', customerBillingDetails.city );
- await expect( page ).toFill( '#billing-state input', customerBillingDetails.state );
+
+ const stateInputField = await page.$( '#billing-state input' );
+ if ( stateInputField ) {
+ await expect( page ).toFill( '#billing-state input', customerBillingDetails.state );
+ }
await expect( page ).toFill( '#billing-postcode', customerBillingDetails.postcode );
await expect( page ).toFill( '#billing-phone', customerBillingDetails.phone );
await expect( page ).toFill( '#email', customerBillingDetails.email );
// Blur active field to trigger customer address update, then wait for requests to finish.
await page.evaluate( 'document.activeElement.blur()' );
await checkCustomerPushCompleted( 'billing', customerBillingDetails );
+
},
// prettier-ignore
@@ -313,7 +318,10 @@ export const shopper = {
await expect( page ).toFill( '#shipping-address_1', customerShippingDetails.addressfirstline );
await expect( page ).toFill( '#shipping-address_2', customerShippingDetails.addresssecondline );
await expect( page ).toFill( '#shipping-city', customerShippingDetails.city );
- await expect( page ).toFill( '#shipping-state input', customerShippingDetails.state );
+ const stateInputField = await page.$( '#shipping-state input' );
+ if ( stateInputField ) {
+ await expect( page ).toFill( '#shipping-state input', customerShippingDetails.state );
+ }
await expect( page ).toFill( '#shipping-postcode', customerShippingDetails.postcode );
await expect( page ).toFill( '#shipping-phone', customerShippingDetails.phone );
// Blur active field to customer address update, then wait for requests to finish.
diff --git a/tests/utils/switch-block-inspector-tab-when-gutenberg-is-installed.ts b/tests/utils/switch-block-inspector-tab-when-gutenberg-is-installed.ts
deleted file mode 100644
index ba399795e85..00000000000
--- a/tests/utils/switch-block-inspector-tab-when-gutenberg-is-installed.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * External dependencies
- */
-import { switchBlockInspectorTab } from '@wordpress/e2e-test-utils';
-
-/**
- * Internal dependencies
- */
-import { GUTENBERG_EDITOR_CONTEXT } from '../e2e/utils';
-
-// @todo Remove this function when WP 6.2 is released. We can use the "switchBlockInspectorTab" function directly.
-export const switchBlockInspectorTabWhenGutenbergIsInstalled = async (
- tabName: string
-) => {
- if ( GUTENBERG_EDITOR_CONTEXT === 'core' ) {
- return;
- }
- await switchBlockInspectorTab( tabName );
-};
diff --git a/woocommerce-gutenberg-products-block.php b/woocommerce-gutenberg-products-block.php
index 1dcbb065f16..7d4b46be358 100644
--- a/woocommerce-gutenberg-products-block.php
+++ b/woocommerce-gutenberg-products-block.php
@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Blocks
* Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block
* Description: WooCommerce blocks for the Gutenberg editor.
- * Version: 9.9.0-dev
+ * Version: 10.0.0-dev
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woo-gutenberg-products-block