wip: added variable and grouped products
This commit is contained in:
parent
ec994501ab
commit
8614134887
|
@ -6,37 +6,41 @@ const {
|
||||||
merchant,
|
merchant,
|
||||||
verifyPublishAndTrash,
|
verifyPublishAndTrash,
|
||||||
createSimpleProduct,
|
createSimpleProduct,
|
||||||
createSimpleProductWithCategory,
|
createVariableProduct,
|
||||||
|
createGroupedProduct,
|
||||||
uiUnblocked
|
uiUnblocked
|
||||||
} = require('@woocommerce/e2e-utils');
|
} = require('@woocommerce/e2e-utils');
|
||||||
const faker = require('faker');
|
const faker = require('faker');
|
||||||
|
const config = require('config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create different product types
|
* Create different product types
|
||||||
*/
|
*/
|
||||||
const setupProducts = async () => {
|
const setupProducts = async () => {
|
||||||
const generateProductName = () => faker.commerce.productName();
|
|
||||||
const generatePrice = () => faker.commerce.price(1, 999);
|
|
||||||
const simpleProduct = {
|
const simpleProduct = {
|
||||||
name: generateProductName(),
|
name: faker.commerce.productName(),
|
||||||
price: generatePrice(),
|
price: faker.commerce.price(1, 999),
|
||||||
id: null
|
id: null
|
||||||
}
|
}
|
||||||
const simpleProductWithCategory = {
|
const variableProduct = {
|
||||||
name: generateProductName(),
|
name: 'Variable Product with Three Variations',
|
||||||
price: generatePrice(),
|
prices: [9.99, 11.99, 20.00],
|
||||||
category: faker.commerce.productMaterial(),
|
id: null
|
||||||
|
}
|
||||||
|
const groupedProduct = {
|
||||||
|
name: config.get('products.simple.name'),
|
||||||
|
simpleProductPrice: config.has('products.simple.price') ? config.get('products.simple.price') : '9.99',
|
||||||
id: null
|
id: null
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleProduct.id = await createSimpleProduct(simpleProduct.name, simpleProduct.price)
|
simpleProduct.id = await createSimpleProduct(simpleProduct.name, simpleProduct.price)
|
||||||
simpleProductWithCategory.id = await createSimpleProductWithCategory(simpleProductWithCategory.name, simpleProductWithCategory.price);
|
variableProduct.id = await createVariableProduct();
|
||||||
// todo variable and grouped products
|
groupedProduct.id = await createGroupedProduct()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
simpleProduct,
|
simpleProduct,
|
||||||
simpleProductWithCategory
|
variableProduct,
|
||||||
// todo variable and grouped products
|
groupedProduct
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +73,6 @@ const runCreateOrderTest = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo remove .only
|
// todo remove .only
|
||||||
// todo complete this
|
|
||||||
it('can create new complex order with multiple product types & tax classes', async () => {
|
it('can create new complex order with multiple product types & tax classes', async () => {
|
||||||
// todo setup products and tax classes
|
// todo setup products and tax classes
|
||||||
const products = await setupProducts();
|
const products = await setupProducts();
|
||||||
|
@ -77,7 +80,7 @@ const runCreateOrderTest = () => {
|
||||||
// Go to "add order" page
|
// Go to "add order" page
|
||||||
await merchant.openNewOrder();
|
await merchant.openNewOrder();
|
||||||
|
|
||||||
// Add products to the order
|
// Add products (line items) to the order
|
||||||
await expect(page).toClick('button.add-line-item');
|
await expect(page).toClick('button.add-line-item');
|
||||||
await expect(page).toClick('button.add-order-item');
|
await expect(page).toClick('button.add-order-item');
|
||||||
await page.waitForSelector('.wc-backbone-modal-header');
|
await page.waitForSelector('.wc-backbone-modal-header');
|
||||||
|
@ -95,11 +98,10 @@ const runCreateOrderTest = () => {
|
||||||
|
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
|
||||||
// Verify the product we added shows as a line item now
|
// Verify the products we added show as line items now
|
||||||
for (const { name } of products) {
|
for (const { name } of products) {
|
||||||
await expect(page).toMatchElement('.wc-order-item-name', { text: name });
|
await expect(page).toMatchElement('.wc-order-item-name', { text: name });
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue