Merge branch 'trunk' into fix/e2e-checkout-page-failures

This commit is contained in:
Greg 2021-08-31 08:17:50 -06:00 committed by GitHub
commit a1648e5d60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 4 deletions

View File

@ -20,7 +20,7 @@ const runInitiateWccomConnectionTest = () => {
await merchant.login();
});
it('can initiate WCCOM connection', async () => {
it.skip('can initiate WCCOM connection', async () => {
await merchant.openHelper();
// Click on Connect button to initiate a WCCOM connection

View File

@ -5,6 +5,7 @@ const {
shopper,
createSimpleProductWithCategory,
utils,
getEnvironmentContext,
} = require( '@woocommerce/e2e-utils' );
/**
@ -15,7 +16,6 @@ const {
describe,
beforeAll,
} = require( '@jest/globals' );
const { WORDPRESS_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( WORDPRESS_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);

View File

@ -21,6 +21,7 @@
- Updated `addShippingZoneAndMethod` to use the API instead of UI to create shipping zones
- Added `updateSettingOption` to use the API to update a setting option
- Added `updatePaymentGateway` to use the API to update a payment gateway
- Added `getSystemEnvironment()` that gets the current environment from the WooCommerce API.
# 0.1.5

View File

@ -151,6 +151,7 @@ This package provides support for enabling retries in tests:
| `deleteAllOrders` | | Permanently delete all orders |
| `updateSettingOption` | `settingsGroup`, `settingID`, `payload` | Update a settings group |
| `updatePaymentGateway`| `paymentGatewayId`, `payload` | Update a payment gateway |
| `getSystemEnvironment` | | Get the current environment from the WooCommerce system status API.
### Page Utilities

View File

@ -6,6 +6,7 @@ const onboardingProfileEndpoint = '/wc-admin/onboarding/profile';
const shippingZoneEndpoint = '/wc/v3/shipping/zones';
const shippingClassesEndpoint = '/wc/v3/products/shipping_classes';
const userEndpoint = '/wp/v2/users';
const systemStatusEndpoint = '/wc/v3/system_status';
/**
* Utility function to delete all merchant created data store objects.
@ -278,12 +279,27 @@ export const withRestApi = {
*
* @param orders Array of orders to be created
*/
batchCreateOrders : async (orders) => {
batchCreateOrders: async (orders) => {
const path = '/wc/v3/orders/batch';
const payload = { create: orders };
const { statusCode } = await client.post(path, payload);
expect(statusCode).toEqual(200);
},
/**
* 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 () => {
const response = await client.get( systemStatusEndpoint );
if ( response.data.environment ) {
return response.data.environment;
} else {
return;
}
}
};

View File

@ -11,3 +11,4 @@ export * from './flows';
export * from './old-flows';
export * from './components';
export * from './page-utils';
export * from './system-environment';

View File

@ -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.
}
}