Fixed erroneous variables

This commit is contained in:
Rodel Calasagsag 2021-06-07 18:46:40 +08:00
parent 21d037900a
commit 179bad04b8
1 changed files with 13 additions and 12 deletions

View File

@ -18,9 +18,7 @@ const simpleProductName = config.get( 'products.simple.name' );
let simplePostIdValue; let simplePostIdValue;
// Variables for variable product // Variables for variable product
const variableProductName = config.get( 'products.variable.name' ); const defaultVariableProduct = config.get( 'products.variable' );
const variations = config.get( 'products.variations' );
const attributes = variations[0].attributes;
let variableProductId; let variableProductId;
// Variables for grouped product // Variables for grouped product
@ -59,26 +57,29 @@ const runSingleProductPageTest = () => {
it('should be able to add variation products to the cart', async () => { it('should be able to add variation products to the cart', async () => {
// Add a product with one set of variations to cart // Add a product with one set of variations to cart
await shopper.goToProduct( variableProductId ); await shopper.goToProduct(variableProductId);
for( const attr of attributes ){ for (const attr of defaultVariableProduct.attributes) {
const selectElem = `#${attr.name.toLowerCase()}`; const { name, options } = attr;
const value = attr.option; const selectElem = `#${name.toLowerCase()}`;
const value = options[0];
await expect(page).toSelect(selectElem, value); await expect(page).toSelect(selectElem, value);
} }
await shopper.addToCart(); await shopper.addToCart();
await expect(page).toMatchElement('.woocommerce-message', {text: 'has been added to your cart.'}); await expect(page).toMatchElement('.woocommerce-message', {
text: 'has been added to your cart.'
});
// Verify cart contents // Verify cart contents
await shopper.goToCart(); await shopper.goToCart();
await shopper.productIsInCart(variableProductName); await shopper.productIsInCart(defaultVariableProduct.name);
}); });
it('should be able to remove variation products from the cart', async () => { it('should be able to remove variation products from the cart', async () => {
// Remove items from cart // Remove items from cart
await shopper.removeFromCart(variableProductName); await shopper.removeFromCart(defaultVariableProduct.name);
await uiUnblocked(); await uiUnblocked();
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
}); });