Code review feedback
This commit is contained in:
parent
7276a4e489
commit
b1990cfb85
|
@ -35,15 +35,6 @@ async function trashExistingPosts() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the WooCommerce API to set the environment context.
|
||||
*/
|
||||
async function setEnvironmentContext() {
|
||||
const environment = await withRestApi.getSystemEnvironment();
|
||||
process.env.WP_VERSION = environment.wp_version;
|
||||
process.env.WC_VERSION = environment.version;
|
||||
}
|
||||
|
||||
// Before every test suite run, delete all content created by the test. This ensures
|
||||
// other posts/comments/etc. aren't dirtying tests and tests don't depend on
|
||||
// each other's side-effects.
|
||||
|
@ -55,8 +46,6 @@ beforeAll(async () => {
|
|||
}
|
||||
|
||||
try {
|
||||
await setEnvironmentContext();
|
||||
|
||||
// Update the ready page to prevent concurrent test runs
|
||||
await updateReadyPageStatus('draft');
|
||||
await trashExistingPosts();
|
||||
|
|
|
@ -5,6 +5,7 @@ const {
|
|||
shopper,
|
||||
createSimpleProductWithCategory,
|
||||
utils,
|
||||
getEnvironmentContext,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
|
@ -15,7 +16,6 @@ const {
|
|||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
const { WP_VERSION } = process.env;
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
@ -27,8 +27,13 @@ const audio = 'Audio';
|
|||
const hardware = 'Hardware';
|
||||
const productTitle = 'li.first > a > h2.woocommerce-loop-product__title';
|
||||
|
||||
const getWordPressVersion = async () => {
|
||||
const context = await getEnvironmentContext();
|
||||
return context.wpVersion;
|
||||
}
|
||||
|
||||
const runProductBrowseSearchSortTest = () => {
|
||||
utils.describeIf( WP_VERSION >= '5.8' )( 'Search, browse by categories and sort items in the shop', () => {
|
||||
utils.describeIf( getWordPressVersion() >= 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);
|
||||
|
|
|
@ -271,6 +271,8 @@ export const withRestApi = {
|
|||
/**
|
||||
* Get the current environment from the WooCommerce system status API.
|
||||
*
|
||||
* For more details, see: https://woocommerce.github.io/woocommerce-rest-api-docs/#system-status-environment-properties
|
||||
*
|
||||
* @returns {Promise<object>} The environment object from the API response.
|
||||
*/
|
||||
getSystemEnvironment: async () => {
|
||||
|
|
|
@ -11,3 +11,4 @@ export * from './flows';
|
|||
export * from './old-flows';
|
||||
export * from './components';
|
||||
export * from './page-utils';
|
||||
export * from './system-environment';
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { withRestApi } from './flows';
|
||||
|
||||
/**
|
||||
* Uses the WooCommerce API to get the environment context.
|
||||
*/
|
||||
export const getEnvironmentContext = async () => {
|
||||
try {
|
||||
const environment = await withRestApi.getSystemEnvironment();
|
||||
return {
|
||||
wpVersion: environment.wp_version,
|
||||
wcVersion: environment.version,
|
||||
}
|
||||
} catch ( error ) {
|
||||
// Prevent an error here causing tests to fail.
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue