REfactor first 2 tests

This commit is contained in:
Rodel Calasagsag 2021-06-05 20:49:43 +08:00
parent 81e05acdd6
commit ef90dc7ea3
1 changed files with 46 additions and 12 deletions

View File

@ -4,13 +4,14 @@
*/
const {
shopper,
merchant,
createVariableProduct,
} = require( '@woocommerce/e2e-utils' );
const config = require('config');
let variablePostIdValue;
const cartDialogMessage = 'Please select some product options before adding this product to your cart.';
const attributes = config.get( 'products.variable.attributes' )
const runVariableProductUpdateTest = () => {
describe('Shopper > Update variable product',() => {
@ -20,25 +21,58 @@ const runVariableProductUpdateTest = () => {
it('shopper can change variable attributes to the same value', async () => {
await shopper.goToProduct(variablePostIdValue);
await expect(page).toSelect('#attr-1', 'val1');
await expect(page).toSelect('#attr-2', 'val1');
await expect(page).toSelect('#attr-3', 'val1');
await expect(page).toMatchElement('.woocommerce-variation-price', { text: '9.99' });
for (const a of attributes) {
const { name, options } = a;
const attrHTMLId = `#${name.toLowerCase()}`;
await expect(page).toSelect(attrHTMLId, options[0]);
}
await expect(page).toMatchElement('.woocommerce-variation-price', {
text: '9.99'
});
});
it('shopper can change attributes to combination with dimensions and weight', async () => {
await shopper.goToProduct(variablePostIdValue);
await expect(page).toSelect('#attr-1', 'val1');
await expect(page).toSelect('#attr-2', 'val2');
await expect(page).toSelect('#attr-3', 'val1');
await expect(page).toSelect(
`#${attributes[0].name.toLowerCase()}`,
attributes[0].options[0]
);
await expect(page).toSelect(
`#${attributes[1].name.toLowerCase()}`,
attributes[1].options[1]
);
await expect(page).toSelect(
`#${attributes[2].name.toLowerCase()}`,
attributes[2].options[0]
);
await expect(page).toMatchElement('.woocommerce-variation-price', { text: '20.00' });
await expect(page).toMatchElement('.woocommerce-variation-availability', { text: 'Out of stock' });
await expect(page).toMatchElement('.woocommerce-product-attributes-item--weight', { text: '200 kg' });
await expect(page).toMatchElement('.woocommerce-product-attributes-item--dimensions', { text: '10 × 20 × 15 cm' });
await expect(page).toMatchElement('.woocommerce-variation-price', {
text: '20.00'
});
await expect(page).toMatchElement(
'.woocommerce-variation-availability',
{
text: 'Out of stock'
}
);
await expect(page).toMatchElement(
'.woocommerce-product-attributes-item--weight',
{
text: '200 kg'
}
);
await expect(
page
).toMatchElement(
'.woocommerce-product-attributes-item--dimensions',
{ text: '10 × 20 × 15 cm' }
);
});
// mytodo continue transforming from here
it('shopper can change variable product attributes to variation with a different price', async () => {
await shopper.goToProduct(variablePostIdValue);
await expect(page).toSelect('#attr-1', 'val1');