2022-03-01 11:25:13 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { setDefaultOptions, getDefaultOptions } from 'expect-puppeteer';
|
2022-03-22 01:54:06 +00:00
|
|
|
import { default as WooCommerceRestApi } from '@woocommerce/woocommerce-rest-api';
|
2022-10-10 10:42:59 +00:00
|
|
|
import { SHOP_PAGE, SHOP_CART_PAGE } from '@woocommerce/e2e-utils';
|
2022-03-01 11:25:13 +00:00
|
|
|
|
2022-02-24 14:02:24 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { shopper } from '../../../utils';
|
2022-04-13 11:51:13 +00:00
|
|
|
import { merchant } from '../../../utils/merchant';
|
2022-03-04 09:57:34 +00:00
|
|
|
import { getTextContent } from '../../page-utils';
|
2022-10-10 10:42:59 +00:00
|
|
|
import { SHOP_CHECKOUT_BLOCK_PAGE, useTheme } from '../../utils';
|
2022-02-24 14:02:24 +00:00
|
|
|
|
|
|
|
const block = {
|
2022-03-09 10:16:24 +00:00
|
|
|
name: 'Mini Cart',
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors: {
|
|
|
|
frontend: {
|
|
|
|
productWithAddToCartButton:
|
|
|
|
'.wc-block-grid__product:nth-child(2) .add_to_cart_button',
|
|
|
|
productTitle:
|
|
|
|
'.wc-block-grid__product:nth-child(2) .wc-block-components-product-name',
|
|
|
|
productPrice:
|
|
|
|
'.wc-block-grid__product:nth-child(2) .wc-block-grid__product-price',
|
|
|
|
addToCartButton: 'button.add_to_cart_button',
|
2022-11-16 01:52:51 +00:00
|
|
|
checkoutOrderSummary: {
|
|
|
|
content: '.wc-block-components-order-summary__content',
|
|
|
|
toggle: '.wc-block-components-order-summary button[aria-expanded="false"]',
|
|
|
|
},
|
2022-05-13 09:11:02 +00:00
|
|
|
},
|
|
|
|
},
|
2022-02-24 14:02:24 +00:00
|
|
|
};
|
|
|
|
|
2022-05-13 09:11:02 +00:00
|
|
|
const { selectors } = block;
|
|
|
|
|
2022-03-01 11:25:13 +00:00
|
|
|
const options = getDefaultOptions();
|
|
|
|
|
|
|
|
const clickMiniCartButton = async () => {
|
|
|
|
await page.hover( '.wc-block-mini-cart__button' );
|
|
|
|
|
|
|
|
await page.waitForSelector( '.wc-block-mini-cart__drawer.is-loading', {
|
|
|
|
hidden: true,
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.click( '.wc-block-mini-cart__button' );
|
|
|
|
};
|
|
|
|
|
2022-03-22 01:54:06 +00:00
|
|
|
const closeMiniCartDrawer = async () => {
|
|
|
|
await page.keyboard.press( 'Escape' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ConsumerKey and ConsumerSecret are not used, we use basic auth, but
|
|
|
|
* not providing them will throw an error.
|
|
|
|
*/
|
|
|
|
const WooCommerce = new WooCommerceRestApi( {
|
|
|
|
url: `${ process.env.WORDPRESS_BASE_URL }/`,
|
|
|
|
consumerKey: 'consumer_key',
|
|
|
|
consumerSecret: 'consumer_secret',
|
|
|
|
version: 'wc/v3',
|
|
|
|
axiosConfig: {
|
|
|
|
auth: {
|
|
|
|
username: process.env.WORDPRESS_LOGIN,
|
|
|
|
password: process.env.WORDPRESS_PASSWORD,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
|
2022-05-05 08:19:38 +00:00
|
|
|
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
|
|
|
|
// Skips all the tests if it's a WooCommerce Core process environment.
|
2022-05-23 12:05:30 +00:00
|
|
|
// eslint-disable-next-line jest/no-focused-tests, jest/expect-expect
|
2022-04-11 10:52:33 +00:00
|
|
|
test.only( `Skipping ${ block.name } tests`, () => {} );
|
2022-02-24 14:02:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
describe( 'Shopper → Mini Cart', () => {
|
2022-03-01 11:25:13 +00:00
|
|
|
beforeAll( async () => {
|
|
|
|
/**
|
|
|
|
* Mini Cart takes time to open. Sometimes, on slow machines, 500ms
|
|
|
|
* is not enough. So, we increase the default timeout to 5 seconds.
|
|
|
|
*/
|
|
|
|
setDefaultOptions( { ...options, timeout: 5000 } );
|
|
|
|
} );
|
|
|
|
|
|
|
|
afterAll( async () => {
|
|
|
|
// Reset default options.
|
|
|
|
setDefaultOptions( options );
|
|
|
|
} );
|
|
|
|
|
2022-02-24 14:02:24 +00:00
|
|
|
beforeEach( async () => {
|
2022-03-09 10:16:24 +00:00
|
|
|
await shopper.block.goToBlockPage( block.name );
|
2022-02-24 14:02:24 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Icon', () => {
|
|
|
|
it( 'Shopper can see the Mini Cart icon and it badge on the front end', async () => {
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart' );
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__button'
|
|
|
|
);
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__quantity-badge'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Make sure the initial quantity is 0.
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__amount',
|
|
|
|
{
|
|
|
|
text: '$0',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__badge', {
|
|
|
|
text: '0',
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Drawer', () => {
|
|
|
|
it( 'The drawer opens when shopper clicks on the mini cart icon', async () => {
|
2022-03-01 11:25:13 +00:00
|
|
|
await clickMiniCartButton();
|
2022-02-24 14:02:24 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'The drawer closes when shopper clicks on the drawer close button', async () => {
|
2022-03-01 11:25:13 +00:00
|
|
|
await clickMiniCartButton();
|
2022-02-24 14:02:24 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-03-01 11:25:13 +00:00
|
|
|
// Wait for the drawer to fully open.
|
|
|
|
await page.waitForTimeout( 500 );
|
|
|
|
|
2022-02-24 14:02:24 +00:00
|
|
|
await page.click(
|
|
|
|
'.wc-block-mini-cart__drawer .components-modal__header button'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).not.toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'The drawer closes when shopper clicks outside the drawer', async () => {
|
2022-03-01 11:25:13 +00:00
|
|
|
await clickMiniCartButton();
|
2022-02-24 14:02:24 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.mouse.click( 50, 200 );
|
|
|
|
|
|
|
|
await expect( page ).not.toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
2022-03-01 11:25:13 +00:00
|
|
|
|
2022-03-08 10:01:27 +00:00
|
|
|
describe( 'Empty mini cart', () => {
|
|
|
|
it( 'When the cart is empty, the Mini Cart Drawer show empty cart message and start shopping button', async () => {
|
|
|
|
await clickMiniCartButton();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Your cart is currently empty!',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Start shopping',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const shopLink = await page.$eval(
|
2023-03-03 09:55:28 +00:00
|
|
|
'a.wc-block-mini-cart__shopping-button',
|
2022-03-08 10:01:27 +00:00
|
|
|
( el ) => el.href
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( shopLink ).toMatch( SHOP_PAGE );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-03-01 11:25:13 +00:00
|
|
|
describe( 'Filled mini cart', () => {
|
|
|
|
beforeAll( async () => {
|
2022-03-07 15:23:31 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-01 11:25:13 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
afterEach( async () => {
|
2022-03-07 15:23:31 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-01 11:25:13 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'The Mini Cart title shows correct amount', async () => {
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-01 11:25:13 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
2022-03-22 01:54:06 +00:00
|
|
|
await closeMiniCartDrawer();
|
2022-03-01 11:25:13 +00:00
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-grid__product:last-child .add_to_cart_button'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (2 items)',
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'The Mini Cart products table show added products', async () => {
|
|
|
|
const products = await page.$$(
|
|
|
|
'.wc-block-all-products .wc-block-grid__product'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( products.length === 0 ) {
|
|
|
|
throw new Error(
|
|
|
|
'No products found on the Mini Cart Block page.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-05-13 09:11:02 +00:00
|
|
|
const product = products[ 1 ];
|
2022-03-22 01:54:06 +00:00
|
|
|
const [ productTitle ] = await getTextContent(
|
|
|
|
'.wc-block-components-product-name',
|
|
|
|
product
|
2022-03-01 11:25:13 +00:00
|
|
|
);
|
|
|
|
const addToCartButton = await product.$( '.add_to_cart_button' );
|
|
|
|
|
|
|
|
await addToCartButton.click();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__products-table',
|
|
|
|
{
|
|
|
|
text: productTitle,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Filled Mini Cart footer contains subtotal, view cart button, and go to checkout buttons', async () => {
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.addToCartButton );
|
2022-03-01 11:25:13 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__footer',
|
|
|
|
{
|
|
|
|
text: 'Subtotal',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__footer-cart',
|
|
|
|
{
|
|
|
|
text: 'View my cart',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__footer-checkout',
|
|
|
|
{
|
|
|
|
text: 'Go to checkout',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
2022-03-03 01:24:30 +00:00
|
|
|
|
2022-03-04 10:40:13 +00:00
|
|
|
describe( 'Update quantity', () => {
|
|
|
|
beforeAll( async () => {
|
2022-03-07 23:09:20 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-04 10:40:13 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
afterEach( async () => {
|
2022-03-07 23:09:20 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-04 10:40:13 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'The quantity of a product can be updated using plus and minus button', async () => {
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-04 10:40:13 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.waitForSelector(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (2 items)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (5 items)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--minus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (4 items)',
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Minus button is disabled if product quantity is 1', async () => {
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-04 10:40:13 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.waitForTimeout( 500 );
|
|
|
|
|
|
|
|
expect(
|
|
|
|
await page.$(
|
|
|
|
'button.wc-block-components-quantity-selector__button--minus[disabled]'
|
|
|
|
)
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--plus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (2 items)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
expect(
|
|
|
|
await page.$(
|
|
|
|
'button.wc-block-components-quantity-selector__button--minus[disabled]'
|
|
|
|
)
|
|
|
|
).toBeFalsy();
|
|
|
|
|
|
|
|
await page.click(
|
|
|
|
'.wc-block-components-quantity-selector__button--minus'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
expect(
|
|
|
|
await page.$(
|
|
|
|
'button.wc-block-components-quantity-selector__button--minus[disabled]'
|
|
|
|
)
|
|
|
|
).toBeTruthy();
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-03-22 01:54:06 +00:00
|
|
|
describe( 'Tax included', () => {
|
|
|
|
let taxSettings;
|
|
|
|
beforeAll( async () => {
|
|
|
|
taxSettings = ( await WooCommerce.get( 'settings/tax' ) ).data;
|
|
|
|
/**
|
|
|
|
* Set the tax display settings to show prices including tax during
|
|
|
|
* cart and checkout. The price displayed in the product loop are
|
|
|
|
* tax excluded.
|
|
|
|
*/
|
|
|
|
await WooCommerce.post( 'settings/tax/batch', {
|
|
|
|
update: [
|
|
|
|
{
|
|
|
|
id: 'woocommerce_tax_display_shop',
|
|
|
|
value: 'excl',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'woocommerce_tax_display_cart',
|
|
|
|
value: 'incl',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
} );
|
|
|
|
await shopper.block.emptyCart();
|
|
|
|
} );
|
|
|
|
|
|
|
|
afterAll( async () => {
|
|
|
|
const displayShop = taxSettings.find(
|
|
|
|
( setting ) => setting.id === 'woocommerce_tax_display_shop'
|
|
|
|
);
|
|
|
|
const displayCart = taxSettings.find(
|
|
|
|
( setting ) => setting.id === 'woocommerce_tax_display_cart'
|
|
|
|
);
|
|
|
|
await WooCommerce.post( 'settings/tax/batch', {
|
|
|
|
update: [
|
|
|
|
{
|
|
|
|
id: 'woocommerce_tax_display_shop',
|
|
|
|
value: displayShop.value,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'woocommerce_tax_display_cart',
|
|
|
|
value: displayCart.value,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
} );
|
|
|
|
await shopper.block.emptyCart();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Mini Cart show tax label and price including tax', async () => {
|
|
|
|
const [ priceInLoop ] = await getTextContent(
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors.frontend.productPrice
|
2022-03-22 01:54:06 +00:00
|
|
|
);
|
|
|
|
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-22 01:54:06 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.waitForSelector( '.wc-block-cart-item__prices' );
|
|
|
|
const [ priceInCart ] = await getTextContent(
|
|
|
|
'.wc-block-cart-item__prices'
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( priceInLoop ).not.toMatch( priceInCart );
|
|
|
|
|
|
|
|
await closeMiniCartDrawer();
|
|
|
|
|
|
|
|
const [ priceInMiniCartButton ] = await getTextContent(
|
|
|
|
'.wc-block-mini-cart__amount'
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( priceInLoop ).not.toMatch( priceInMiniCartButton );
|
|
|
|
expect( priceInCart ).toMatch( priceInMiniCartButton );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__button',
|
|
|
|
{
|
|
|
|
text: '(incl.',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-03-24 15:37:17 +00:00
|
|
|
describe( 'Remove product', () => {
|
|
|
|
beforeAll( async () => {
|
2022-03-26 00:32:23 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-24 15:37:17 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
afterAll( async () => {
|
2022-03-26 00:32:23 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-24 15:37:17 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Can remove product from Mini Cart', async () => {
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.addToCartButton );
|
2022-03-24 15:37:17 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( '.wc-block-mini-cart__title', {
|
|
|
|
text: 'Your cart (1 item)',
|
|
|
|
} );
|
|
|
|
|
|
|
|
await page.waitForTimeout( 500 ); // Ensure the drawer is fully opened.
|
|
|
|
|
|
|
|
await page.click( '.wc-block-cart-item__remove-link' );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Your cart is currently empty!',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-03-04 09:57:34 +00:00
|
|
|
describe( 'Cart page', () => {
|
|
|
|
beforeAll( async () => {
|
2022-03-07 23:09:20 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-04 09:57:34 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Can go to cart page from the Mini Cart Footer', async () => {
|
|
|
|
const [ productTitle ] = await getTextContent(
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors.frontend.productTitle
|
2022-03-04 09:57:34 +00:00
|
|
|
);
|
|
|
|
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-04 09:57:34 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-03-03 01:24:30 +00:00
|
|
|
describe( 'Checkout page', () => {
|
|
|
|
beforeAll( async () => {
|
2022-03-07 23:09:20 +00:00
|
|
|
await shopper.block.emptyCart();
|
2022-03-03 01:24:30 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'Can go to checkout page from the Mini Cart Footer', async () => {
|
|
|
|
const productTitle = await page.$eval(
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors.frontend.productTitle,
|
2022-03-03 01:24:30 +00:00
|
|
|
( el ) => el.textContent
|
|
|
|
);
|
|
|
|
|
2022-05-13 09:11:02 +00:00
|
|
|
await page.click( selectors.frontend.productWithAddToCartButton );
|
2022-03-03 01:24:30 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__products-table',
|
|
|
|
{
|
|
|
|
text: productTitle,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const checkoutUrl = await page.$eval(
|
|
|
|
'.wc-block-mini-cart__footer-checkout',
|
|
|
|
( el ) => el.href
|
|
|
|
);
|
|
|
|
|
2022-10-10 10:42:59 +00:00
|
|
|
expect( checkoutUrl ).toMatch( SHOP_CHECKOUT_BLOCK_PAGE );
|
2022-03-03 01:24:30 +00:00
|
|
|
|
|
|
|
await page.goto( checkoutUrl, { waitUntil: 'networkidle0' } );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( 'h1', { text: 'Checkout' } );
|
|
|
|
|
2022-11-16 01:52:51 +00:00
|
|
|
const orderSummaryToggle = await page.$(
|
|
|
|
selectors.frontend.checkoutOrderSummary.toggle
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( orderSummaryToggle ) {
|
|
|
|
await orderSummaryToggle.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
selectors.frontend.checkoutOrderSummary.content,
|
|
|
|
{ text: productTitle }
|
|
|
|
);
|
2022-03-03 01:24:30 +00:00
|
|
|
} );
|
|
|
|
} );
|
2022-04-13 11:51:13 +00:00
|
|
|
|
|
|
|
describe( 'Translations', () => {
|
|
|
|
beforeAll( async () => {
|
|
|
|
await merchant.changeLanguage( 'nl_NL' );
|
|
|
|
await shopper.block.emptyCart();
|
|
|
|
} );
|
|
|
|
|
2022-10-10 10:42:59 +00:00
|
|
|
beforeEach( async () => {
|
|
|
|
await shopper.block.goToBlockPage( block.name );
|
|
|
|
} );
|
|
|
|
|
2022-04-13 11:51:13 +00:00
|
|
|
afterAll( async () => {
|
|
|
|
await merchant.changeLanguage( '' );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Classic Themes', () => {
|
|
|
|
afterAll( async () => {
|
|
|
|
await shopper.block.emptyCart();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'User can see translation in empty Mini Cart', async () => {
|
|
|
|
await clickMiniCartButton();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Begin met winkelen',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'User can see translation in filled Mini Cart', async () => {
|
|
|
|
await page.click(
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors.frontend.productWithAddToCartButton
|
2022-04-13 11:51:13 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
2022-05-23 14:58:13 +00:00
|
|
|
'.wc-block-mini-cart__footer-cart',
|
2022-04-13 11:51:13 +00:00
|
|
|
{
|
2022-05-23 14:58:13 +00:00
|
|
|
text: 'Bekijk mijn winkelwagen',
|
2022-04-13 11:51:13 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Block Themes', () => {
|
|
|
|
useTheme( 'twentytwentytwo' );
|
|
|
|
|
|
|
|
afterAll( async () => {
|
|
|
|
await shopper.block.emptyCart();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'User can see translation in empty Mini Cart', async () => {
|
|
|
|
await clickMiniCartButton();
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.wc-block-mini-cart__drawer',
|
|
|
|
{
|
|
|
|
text: 'Begin met winkelen',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'User can see translation in filled Mini Cart', async () => {
|
|
|
|
await page.click(
|
2022-05-13 09:11:02 +00:00
|
|
|
selectors.frontend.productWithAddToCartButton
|
2022-04-13 11:51:13 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement(
|
2022-05-23 14:58:13 +00:00
|
|
|
'.wc-block-mini-cart__footer-cart',
|
2022-04-13 11:51:13 +00:00
|
|
|
{
|
2022-05-23 14:58:13 +00:00
|
|
|
text: 'Bekijk mijn winkelwagen',
|
2022-04-13 11:51:13 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
2022-02-24 14:02:24 +00:00
|
|
|
} );
|