From 1cd8d14ac42a2dc6ed70e52a3c8391c176c3acf4 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 27 Aug 2021 13:46:29 -0300 Subject: [PATCH] skip product search on WP versions < 5.8 --- .../shopper/front-end-product-browse-search-sort.test.js | 5 +++-- tests/e2e/utils/src/flows/shopper.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) 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);