woocommerce/tests/e2e/specs/front-end/front-end-single-product.te...

72 lines
2.3 KiB
JavaScript
Raw Normal View History

/**
* @format
*/
/**
* Internal dependencies
*/
2020-04-20 11:33:17 +00:00
import {
CustomerFlow,
StoreOwnerFlow,
createSimpleProduct,
createVariableProduct,
uiUnblocked
} from '@woocommerce/e2e-utils';
let simplePostIdValue;
let variablePostIdValue;
2019-12-06 15:06:48 +00:00
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
describe( 'Single Product Page', () => {
beforeAll( async () => {
await StoreOwnerFlow.login();
simplePostIdValue = await createSimpleProduct();
2019-09-24 10:39:24 +00:00
await StoreOwnerFlow.logout();
} );
it( 'should be able to add simple products to the cart', async () => {
// Add 5 simple products to cart
await CustomerFlow.goToProduct( simplePostIdValue );
await expect( page ).toFill( 'div.quantity input.qty', '5' );
await CustomerFlow.addToCart();
await expect( page ).toMatchElement( '.woocommerce-message', { text: 'have been added to your cart.' } );
// Verify cart contents
await CustomerFlow.goToCart();
2019-12-06 15:06:48 +00:00
await CustomerFlow.productIsInCart( simpleProductName, 5 );
// Remove items from cart
2019-12-06 15:06:48 +00:00
await CustomerFlow.removeFromCart( simpleProductName );
await uiUnblocked();
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
} );
} );
describe.skip( 'Variable Product Page', () => {
beforeAll( async () => {
await StoreOwnerFlow.login();
variablePostIdValue = await createVariableProduct();
await StoreOwnerFlow.logout();
} );
it( 'should be able to add variation products to the cart', async () => {
// Add a product with one set of variations to cart
await CustomerFlow.goToProduct( variablePostIdValue );
await expect( page ).toSelect( '#attr-1', 'val1' );
await expect( page ).toSelect( '#attr-2', 'val1' );
await expect( page ).toSelect( '#attr-3', 'val1' );
await CustomerFlow.addToCart();
await expect( page ).toMatchElement( '.woocommerce-message', { text: 'has been added to your cart.' } );
// Verify cart contents
await CustomerFlow.goToCart();
await CustomerFlow.productIsInCart( 'Variable Product with Three Variations' );
// Remove items from cart
await CustomerFlow.removeFromCart( 'Variable Product with Three Variations' );
await uiUnblocked();
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
} );
} );