2019-09-24 11:56:02 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-04-20 11:33:17 +00:00
|
|
|
import {
|
|
|
|
CustomerFlow,
|
|
|
|
StoreOwnerFlow,
|
|
|
|
createSimpleProduct,
|
|
|
|
uiUnblocked
|
|
|
|
} from '@woocommerce/e2e-utils';
|
2019-09-24 11:56:02 +00:00
|
|
|
|
|
|
|
describe( 'Cart page', () => {
|
|
|
|
beforeAll( async () => {
|
2019-12-02 17:54:45 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-09-24 11:56:02 +00:00
|
|
|
await createSimpleProduct();
|
|
|
|
await StoreOwnerFlow.logout();
|
|
|
|
} );
|
|
|
|
|
2019-12-11 17:15:37 +00:00
|
|
|
it( 'should display no item in the cart', async () => {
|
2019-09-24 11:56:02 +00:00
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
|
|
} );
|
|
|
|
|
2019-12-02 17:54:45 +00:00
|
|
|
it( 'should add the product to the cart when "Add to cart" is clicked', async () => {
|
2019-09-24 11:56:02 +00:00
|
|
|
await CustomerFlow.goToShop();
|
|
|
|
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
|
|
|
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await CustomerFlow.productIsInCart( 'Simple product' );
|
|
|
|
} );
|
|
|
|
|
2019-12-02 17:54:45 +00:00
|
|
|
it( 'should increase item qty when "Add to cart" of the same product is clicked', async () => {
|
2019-09-24 11:56:02 +00:00
|
|
|
await CustomerFlow.goToShop();
|
|
|
|
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
|
|
|
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await CustomerFlow.productIsInCart( 'Simple product', 2 );
|
|
|
|
} );
|
|
|
|
|
2019-12-02 17:54:45 +00:00
|
|
|
it( 'should update qty when updated via qty input', async () => {
|
2019-09-24 11:56:02 +00:00
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await CustomerFlow.setCartQuantity( 'Simple product', 4 );
|
|
|
|
await expect( page ).toClick( 'button', { text: 'Update cart' } );
|
|
|
|
await uiUnblocked();
|
|
|
|
|
|
|
|
await CustomerFlow.productIsInCart( 'Simple product', 4 );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should remove the item from the cart when remove is clicked', async () => {
|
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await CustomerFlow.removeFromCart( 'Simple product' );
|
|
|
|
await uiUnblocked();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should update subtotal in cart totals when adding product to the cart', async () => {
|
|
|
|
await CustomerFlow.goToShop();
|
|
|
|
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
|
|
|
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await CustomerFlow.productIsInCart( 'Simple product', 1 );
|
|
|
|
await expect( page ).toMatchElement( '.cart-subtotal .amount', { text: '$9.99' } );
|
|
|
|
|
|
|
|
await CustomerFlow.setCartQuantity( 'Simple product', 2 );
|
|
|
|
await expect( page ).toClick( 'button', { text: 'Update cart' } );
|
|
|
|
await uiUnblocked();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.cart-subtotal .amount', { text: '$19.98' } );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should go to the checkout page when "Proceed to Checkout" is clicked', async () => {
|
|
|
|
await CustomerFlow.goToCart();
|
|
|
|
await Promise.all( [
|
|
|
|
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
|
|
expect( page ).toClick( '.checkout-button', { text: 'Proceed to checkout' } ),
|
|
|
|
] );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '#order_review' );
|
|
|
|
} );
|
|
|
|
} );
|