This commit is contained in:
Tung Du 2022-03-04 16:57:34 +07:00 committed by GitHub
parent 31b179eb49
commit 43529e5735
1 changed files with 38 additions and 1 deletions

View File

@ -2,12 +2,13 @@
* External dependencies
*/
import { setDefaultOptions, getDefaultOptions } from 'expect-puppeteer';
import { SHOP_CHECKOUT_PAGE } from '@woocommerce/e2e-utils';
import { SHOP_CART_PAGE, SHOP_CHECKOUT_PAGE } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
import { shopper } from '../../../utils';
import { getTextContent } from '../../page-utils';
const block = {
name: 'Mini Cart Block',
@ -220,6 +221,42 @@ describe( 'Shopper → Mini Cart', () => {
} );
} );
describe( 'Cart page', () => {
beforeAll( async () => {
await shopper.emptyCart();
} );
it( 'Can go to cart page from the Mini Cart Footer', async () => {
const [ productTitle ] = await getTextContent(
'.wc-block-grid__product:first-child .wc-block-components-product-name'
);
await page.click(
'.wc-block-grid__product:first-child .add_to_cart_button'
);
await expect( page ).toMatchElement(
'.wc-block-mini-cart__products-table',
{
text: productTitle,
}
);
const cartUrl = await page.$eval(
'.wc-block-mini-cart__footer-cart',
( el ) => el.href
);
expect( cartUrl ).toMatch( SHOP_CART_PAGE );
await page.goto( cartUrl, { waitUntil: 'networkidle0' } );
await expect( page ).toMatchElement( 'h1', { text: 'Cart' } );
await expect( page ).toMatch( productTitle );
} );
} );
describe( 'Checkout page', () => {
beforeAll( async () => {
await shopper.emptyCart();