Merge pull request #30361 from woocommerce/add/e2e-shipping-classes-cleanup

Added shipping classes cleanup to retest flow
This commit is contained in:
Greg 2021-08-05 14:42:30 -06:00 committed by GitHub
commit 33521dd4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -1,5 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
@ -37,6 +35,10 @@ const runOnboardingFlowTest = () => {
await withRestApi.deleteAllShippingZones();
});
it('can reset shipping classes', async () => {
await withRestApi.deleteAllShippingClasses();
})
it('can reset to default settings', async () => {
await withRestApi.resetSettingsGroupToDefault('general');
await withRestApi.resetSettingsGroupToDefault('products');
@ -55,7 +57,7 @@ const runTaskListTest = () => {
beforeAll(async () => {
await merchant.login();
});
it('can setup shipping', async () => {
await page.evaluate(() => {
document.querySelector('.woocommerce-list__item-title').scrollIntoView();

View File

@ -12,6 +12,7 @@
- Added `describeIf()` to conditionally run a test suite
- Added `itIf()` to conditionally run a test case.
- Added merchant workflows around plugins: `uploadAndActivatePlugin()`, `activatePlugin()`, `deactivatePlugin()`, `deletePlugin()`
- Added `deleteAllShippingClasses()` which permanently deletes all shipping classes using the API
# 0.1.5

View File

@ -143,6 +143,7 @@ This package provides support for enabling retries in tests:
| `deleteAllCoupons` | | Permanently delete all coupons |
| `deleteAllProducts` | | Permanently delete all products |
| `deleteAllShippingZones` | | Permanently delete all shipping zones except the default |
| `deleteAllShippingClasses` | Permanently delete all shipping classes |
| `deleteCustomerByEmail` | `emailAddress` | Delete customer user account. Posts are reassigned to user ID 1 |
| `resetSettingsGroupToDefault` | `settingsGroup` | Reset settings in settings group to default except `select` fields |

View File

@ -4,6 +4,7 @@ import {Coupon, Setting, SimpleProduct} from '@woocommerce/api';
const client = factories.api.withDefaultPermalinks;
const onboardingProfileEndpoint = '/wc-admin/onboarding/profile';
const shippingZoneEndpoint = '/wc/v3/shipping/zones';
const shippingClassesEndpoint = '/wc/v3/products/shipping_classes';
const userEndpoint = '/wp/v2/users';
/**
@ -99,6 +100,20 @@ export const withRestApi = {
}
}
},
/**
* Use api package to delete shipping classes.
*
* @return {Promise} Promise resolving once shipping classes have been deleted.
*/
deleteAllShippingClasses: async () => {
const shippingClasses = await client.get( shippingClassesEndpoint );
if ( shippingClasses.data && shippingClasses.data.length ) {
for ( let c = 0; c < shippingClasses.data.length; c++ ) {
const response = await client.delete( shippingClassesEndpoint + `/${shippingClasses.data[c].id}?force=true` );
expect( response.statusCode ).toBe( 200 );
}
}
},
/**
* Delete a customer account by their email address if the user exists.
*