wip: relocated product setup function

This commit is contained in:
rodel 2021-03-23 05:00:56 -07:00
parent 56bd958dde
commit 4f861c9b7a
1 changed files with 35 additions and 29 deletions

View File

@ -16,38 +16,13 @@ const { HTTPClientFactory,
ExternalProduct ExternalProduct
} = require('@woocommerce/api'); } = require('@woocommerce/api');
let variations;
let products;
const runCreateOrderTest = () => { const runCreateOrderTest = () => {
describe('WooCommerce Orders > Add new order', () => { describe('WooCommerce Orders > Add new order', () => {
beforeAll(async () => { beforeAll(async () => {
await merchant.login();
});
it('can create new order', async () => {
// Go to "add order" page
await merchant.openNewOrder();
// Make sure we're on the add order page
await expect(page.title()).resolves.toMatch('Add new order');
// Set order data
await expect(page).toSelect('#order_status', 'Processing');
await expect(page).toFill('input[name=order_date]', '2018-12-13');
await expect(page).toFill('input[name=order_date_hour]', '18');
await expect(page).toFill('input[name=order_date_minute]', '55');
// Create order, verify that it was created. Trash order, verify that it was trashed.
await verifyPublishAndTrash(
'.order_actions li .save_order',
'#message',
'Order updated.',
'1 order moved to the Trash.'
);
});
// todo remove .only
it('can create new complex order with multiple product types & tax classes', async () => {
// Initialize products for each product type // Initialize products for each product type
const variations = config.get('products.variations');;
const initProducts = async () => { const initProducts = async () => {
// Initialize HTTP client // Initialize HTTP client
const apiUrl = config.get('url'); const apiUrl = config.get('url');
@ -65,6 +40,7 @@ const runCreateOrderTest = () => {
}; };
const initVariableProduct = async () => { const initVariableProduct = async () => {
const prodProps = config.get('products.variable'); const prodProps = config.get('products.variable');
variations = config.get('products.variations');;
const productRepo = VariableProduct.restRepository(httpClient); const productRepo = VariableProduct.restRepository(httpClient);
const variationRepo = ProductVariation.restRepository(httpClient); const variationRepo = ProductVariation.restRepository(httpClient);
const variableProduct = await productRepo.create(prodProps); const variableProduct = await productRepo.create(prodProps);
@ -98,7 +74,37 @@ const runCreateOrderTest = () => {
externalProduct externalProduct
]; ];
}; };
const products = await initProducts(); products = await initProducts();
// Login
await merchant.login();
});
it('can create new order', async () => {
// Go to "add order" page
await merchant.openNewOrder();
// Make sure we're on the add order page
await expect(page.title()).resolves.toMatch('Add new order');
// Set order data
await expect(page).toSelect('#order_status', 'Processing');
await expect(page).toFill('input[name=order_date]', '2018-12-13');
await expect(page).toFill('input[name=order_date_hour]', '18');
await expect(page).toFill('input[name=order_date_minute]', '55');
// Create order, verify that it was created. Trash order, verify that it was trashed.
await verifyPublishAndTrash(
'.order_actions li .save_order',
'#message',
'Order updated.',
'1 order moved to the Trash.'
);
});
// todo remove .only
it('can create new complex order with multiple product types & tax classes', async () => {
// Go to "add order" page // Go to "add order" page
await merchant.openNewOrder(); await merchant.openNewOrder();