Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Jun 7, 2023
1 parent 17816e9 commit 6e5bd01
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"Mini-Cart Block","pageContent":"<!-- wp:woocommerce/mini-cart {\"addToCartBehaviour\":\"open_drawer\"} /--><!-- wp:woocommerce/all-products {\"columns\":3,\"rows\":3,\"alignButtons\":false,\"contentVisibility\":{\"orderBy\":true},\"orderby\":\"date\",\"layoutConfig\":[[\"woocommerce/product-image\"],[\"woocommerce/product-title\"],[\"woocommerce/product-price\"],[\"woocommerce/product-rating\"],[\"woocommerce/product-button\"]]} -->\n<div class=\"wp-block-woocommerce-all-products wc-block-all-products\" data-attributes=\"{&quot;alignButtons&quot;:false,&quot;columns&quot;:3,&quot;contentVisibility&quot;:{&quot;orderBy&quot;:true},&quot;isPreview&quot;:false,&quot;layoutConfig&quot;:[[&quot;woocommerce/product-image&quot;],[&quot;woocommerce/product-title&quot;],[&quot;woocommerce/product-price&quot;],[&quot;woocommerce/product-rating&quot;],[&quot;woocommerce/product-button&quot;]],&quot;orderby&quot;:&quot;date&quot;,&quot;rows&quot;:3}\"></div>\n<!-- /wp:woocommerce/all-products -->"}
{"title":"Mini-Cart Block","pageContent":"<!-- wp:woocommerce/mini-cart {\"addToCartBehaviour\":\"open_drawer\"} /-->"}
48 changes: 46 additions & 2 deletions tests/e2e/specs/shopper/mini-cart.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/**
* External dependencies
*/
import {
createNewPost,
insertBlock,
publishPost,
switchUserToAdmin,
} from '@wordpress/e2e-test-utils';
import { setDefaultOptions, getDefaultOptions } from 'expect-puppeteer';
import { default as WooCommerceRestApi } from '@woocommerce/woocommerce-rest-api';
import { SHOP_PAGE, SHOP_CART_PAGE } from '@woocommerce/e2e-utils';
Expand All @@ -11,7 +17,12 @@ import { SHOP_PAGE, SHOP_CART_PAGE } from '@woocommerce/e2e-utils';
import { shopper } from '../../../utils';
import { merchant } from '../../../utils/merchant';
import { getTextContent } from '../../page-utils';
import { SHOP_CHECKOUT_BLOCK_PAGE, useTheme } from '../../utils';
import {
insertAllProductsBlock,
SHOP_CHECKOUT_BLOCK_PAGE,
useTheme,
waitForAllProductsBlockLoaded,
} from '../../utils';

const block = {
name: 'Mini-Cart',
Expand Down Expand Up @@ -196,6 +207,37 @@ describe( 'Shopper → Mini-Cart', () => {
expect( shopLink ).toMatch( SHOP_PAGE );
} );
} );
} );

describe( 'Shopper → Mini-Cart with the All Products block', () => {
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 } );

await switchUserToAdmin();
await createNewPost( {
postType: 'post',
title: block.name + ' with All Products',
} );

await insertBlock( block.name );
await insertAllProductsBlock();
await publishPost();

const link = await page.evaluate( () =>
wp.data.select( 'core/editor' ).getPermalink()
);
await page.goto( link );
await waitForAllProductsBlockLoaded();
} );

afterAll( async () => {
// Reset default options.
setDefaultOptions( options );
} );

describe( 'Filled Mini-Cart', () => {
beforeAll( async () => {
Expand Down Expand Up @@ -552,7 +594,9 @@ describe( 'Shopper → Mini-Cart', () => {

await page.goto( checkoutUrl, { waitUntil: 'networkidle0' } );

await expect( page ).toMatchElement( 'h1', { text: 'Checkout' } );
await expect( page ).toMatchElement( 'h1', {
text: 'Checkout',
} );

const orderSummaryToggle = await page.$(
selectors.frontend.checkoutOrderSummary.toggle
Expand Down

0 comments on commit 6e5bd01

Please sign in to comment.