Merge pull request #30184 from woocommerce/add/e2e-merchant-batch-create-orders
Use API package to create orders by batch
This commit is contained in:
commit
504b96d7e4
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
- Checkout create account test would fail if configuration value `addresses.customer.billing.email` was not `john.doe@example.com`
|
- Checkout create account test would fail if configuration value `addresses.customer.billing.email` was not `john.doe@example.com`
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
- The e2e test `order-status-filters.test.js` now uses the API to create orders
|
||||||
|
|
||||||
# 0.1.3
|
# 0.1.3
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
|
import config from 'config';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
merchant,
|
merchant,
|
||||||
createSimpleOrder,
|
withRestApi,
|
||||||
clickFilter,
|
clickFilter,
|
||||||
moveAllItemsToTrash,
|
moveAllItemsToTrash,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
@ -42,22 +43,28 @@ const orderStatus = {
|
||||||
description: { text: 'Failed' },
|
description: { text: 'Failed' },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const defaultOrder = config.get('orders.basicPaidOrder');
|
||||||
|
|
||||||
|
|
||||||
const runOrderStatusFiltersTest = () => {
|
const runOrderStatusFiltersTest = () => {
|
||||||
describe('WooCommerce Orders > Filter Orders by Status', () => {
|
describe('WooCommerce Orders > Filter Orders by Status', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// First, let's login
|
// First, let's create some orders we can filter against
|
||||||
await merchant.login();
|
const orders = Object.entries(orderStatus).map((entryPair) => {
|
||||||
|
const statusName = entryPair[1].name.replace('wc-', '');
|
||||||
|
|
||||||
// Next, let's create some orders we can filter against
|
return {
|
||||||
await createSimpleOrder(orderStatus.pending.description.text);
|
...defaultOrder,
|
||||||
await createSimpleOrder(orderStatus.processing.description.text);
|
status: statusName,
|
||||||
await createSimpleOrder(orderStatus.onHold.description.text);
|
};
|
||||||
await createSimpleOrder(orderStatus.completed.description.text);
|
});
|
||||||
await createSimpleOrder(orderStatus.cancelled.description.text);
|
|
||||||
await createSimpleOrder(orderStatus.refunded.description.text);
|
// Create the orders using the API
|
||||||
await createSimpleOrder(orderStatus.failed.description.text);
|
await withRestApi.batchCreateOrders(orders);
|
||||||
}, 60000);
|
|
||||||
|
// Next, let's login
|
||||||
|
await merchant.login();
|
||||||
|
});
|
||||||
|
|
||||||
afterAll( async () => {
|
afterAll( async () => {
|
||||||
// Make sure we're on the all orders view and cleanup the orders we created
|
// Make sure we're on the all orders view and cleanup the orders we created
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
- Factories for variable product, variation, and grouped product
|
- Factories for variable product, variation, and grouped product
|
||||||
|
- New function to create orders by batch using the orders API
|
||||||
- Added new constant for WordPress update page `WP_ADMIN_WP_UPDATES`
|
- Added new constant for WordPress update page `WP_ADMIN_WP_UPDATES`
|
||||||
- Added new merchant flow for `openWordPressUpdatesPage()`
|
- Added new merchant flow for `openWordPressUpdatesPage()`
|
||||||
- Added new merchant flows:
|
- Added new merchant flows:
|
||||||
|
|
|
@ -147,6 +147,7 @@ This package provides support for enabling retries in tests:
|
||||||
| `deleteAllShippingClasses` | Permanently delete all shipping classes |
|
| `deleteAllShippingClasses` | Permanently delete all shipping classes |
|
||||||
| `deleteCustomerByEmail` | `emailAddress` | Delete customer user account. Posts are reassigned to user ID 1 |
|
| `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 |
|
| `resetSettingsGroupToDefault` | `settingsGroup` | Reset settings in settings group to default except `select` fields |
|
||||||
|
| `batchCreateOrders` | `orders` | Create a batch of orders using the "Batch Create Order" API endpoint |
|
||||||
| `deleteAllOrders` | | Permanently delete all orders |
|
| `deleteAllOrders` | | Permanently delete all orders |
|
||||||
|
|
||||||
### Page Utilities
|
### Page Utilities
|
||||||
|
|
|
@ -251,5 +251,19 @@ export const withRestApi = {
|
||||||
expect( response.value ).toBe( defaultSetting.value );
|
expect( response.value ).toBe( defaultSetting.value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a batch of orders using the "Batch Create Order" API endpoint.
|
||||||
|
*
|
||||||
|
* @param orders Array of orders to be created
|
||||||
|
*/
|
||||||
|
batchCreateOrders : async (orders) => {
|
||||||
|
const path = '/wc/v3/orders/batch';
|
||||||
|
const payload = { create: orders };
|
||||||
|
|
||||||
|
const { statusCode } = await client.post(path, payload);
|
||||||
|
|
||||||
|
expect(statusCode).toEqual(200);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue