2019-09-24 09:47:47 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-04-20 11:33:17 +00:00
|
|
|
import {
|
|
|
|
CustomerFlow,
|
|
|
|
StoreOwnerFlow,
|
|
|
|
createSimpleProduct,
|
|
|
|
createVariableProduct,
|
|
|
|
uiUnblocked
|
|
|
|
} from '@woocommerce/e2e-utils';
|
|
|
|
|
2019-11-06 22:17:44 +00:00
|
|
|
let simplePostIdValue;
|
|
|
|
let variablePostIdValue;
|
2019-12-06 15:06:48 +00:00
|
|
|
const config = require( 'config' );
|
|
|
|
const simpleProductName = config.get( 'products.simple.name' );
|
2019-11-06 22:17:44 +00:00
|
|
|
|
2019-09-24 09:47:47 +00:00
|
|
|
describe( 'Single Product Page', () => {
|
|
|
|
beforeAll( async () => {
|
2019-11-24 13:08:48 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-11-06 22:17:44 +00:00
|
|
|
simplePostIdValue = await createSimpleProduct();
|
2019-09-24 10:39:24 +00:00
|
|
|
await StoreOwnerFlow.logout();
|
2019-09-24 09:47:47 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should be able to add simple products to the cart', async () => {
|
|
|
|
// Add 5 simple products to cart
|
2019-11-06 22:17:44 +00:00
|
|
|
await CustomerFlow.goToProduct( simplePostIdValue );
|
2019-09-24 09:47:47 +00:00
|
|
|
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 );
|
2019-09-24 09:47:47 +00:00
|
|
|
|
|
|
|
// Remove items from cart
|
2019-12-06 15:06:48 +00:00
|
|
|
await CustomerFlow.removeFromCart( simpleProductName );
|
2019-09-24 09:47:47 +00:00
|
|
|
await uiUnblocked();
|
|
|
|
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
|
|
} );
|
2019-11-06 22:17:44 +00:00
|
|
|
} );
|
|
|
|
|
2020-02-13 18:32:41 +00:00
|
|
|
describe.skip( 'Variable Product Page', () => {
|
2019-11-06 22:17:44 +00:00
|
|
|
beforeAll( async () => {
|
2019-11-24 13:08:48 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-11-06 22:17:44 +00:00
|
|
|
variablePostIdValue = await createVariableProduct();
|
|
|
|
await StoreOwnerFlow.logout();
|
|
|
|
} );
|
2019-09-24 09:47:47 +00:00
|
|
|
|
|
|
|
it( 'should be able to add variation products to the cart', async () => {
|
|
|
|
// Add a product with one set of variations to cart
|
2019-11-06 22:17:44 +00:00
|
|
|
await CustomerFlow.goToProduct( variablePostIdValue );
|
2019-09-24 09:47:47 +00:00
|
|
|
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();
|
2019-11-06 22:17:44 +00:00
|
|
|
await CustomerFlow.productIsInCart( 'Variable Product with Three Variations' );
|
2019-09-24 09:47:47 +00:00
|
|
|
|
|
|
|
// Remove items from cart
|
2019-11-06 22:17:44 +00:00
|
|
|
await CustomerFlow.removeFromCart( 'Variable Product with Three Variations' );
|
2019-09-24 09:47:47 +00:00
|
|
|
await uiUnblocked();
|
|
|
|
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
|
|
} );
|
|
|
|
} );
|