diff --git a/tests/e2e/core-tests/specs/shopper/front-end-product-browse-search-sort.test.js b/tests/e2e/core-tests/specs/shopper/front-end-product-browse-search-sort.test.js index f18856a8fd1..73f2cefd042 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-product-browse-search-sort.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-product-browse-search-sort.test.js @@ -1,10 +1,10 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * Internal dependencies */ const { shopper, createSimpleProductWithCategory, + utils, } = require( '@woocommerce/e2e-utils' ); /** @@ -15,6 +15,7 @@ const { describe, beforeAll, } = require( '@jest/globals' ); +const { WORDPRESS_VERSION } = process.env; const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); @@ -27,7 +28,7 @@ const hardware = 'Hardware'; const productTitle = 'li.first > a > h2.woocommerce-loop-product__title'; const runProductBrowseSearchSortTest = () => { - describe('Search, browse by categories and sort items in the shop', () => { + utils.describeIf( WORDPRESS_VERSION >= '5.8' )( 'Search, browse by categories and sort items in the shop', () => { beforeAll(async () => { // Create 1st product with Clothing category await createSimpleProductWithCategory(simpleProductName + ' 1', singleProductPrice, clothing); diff --git a/tests/e2e/utils/src/flows/shopper.js b/tests/e2e/utils/src/flows/shopper.js index cc4749b9a99..940843e4cfa 100644 --- a/tests/e2e/utils/src/flows/shopper.js +++ b/tests/e2e/utils/src/flows/shopper.js @@ -171,9 +171,11 @@ const shopper = { await page.waitForSelector(searchFieldSelector, { timeout: 100000 }); await expect(page).toFill(searchFieldSelector, prouductName); await expect(page).toClick('.wp-block-search__button'); - await page.waitForSelector('h2.entry-title'); - await expect(page).toMatchElement('h2.entry-title', {text: prouductName}); - await expect(page).toClick('h2.entry-title', {text: prouductName}); + // Single search results may go directly to product page + if ( await page.waitForSelector('h2.entry-title') ) { + await expect(page).toMatchElement('h2.entry-title', {text: prouductName}); + await expect(page).toClick('h2.entry-title', {text: prouductName}); + } await page.waitForSelector('h1.entry-title'); await expect(page.title()).resolves.toMatch(prouductName); await expect(page).toMatchElement('h1.entry-title', prouductName);