Add constants for C & C pages in our E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/5938)

* Add constants for C & C pages in our E2E tests

Inspired by WC E2E this will avoid going to admin to find out the links for these pages.

* Select C & C pages by using the main navigation links

* Fix function calls

* Revert back to using constants for C & C block pages' URLs

reverts 9587a0bd5efa5d97b484cd8d1bf927ff50f8e014 and bd7e2f996792d887756c0a0f4a10e6886574e77b
This commit is contained in:
Raluca Stan 2022-02-25 10:44:16 +01:00 committed by GitHub
parent 5a3c7be9a4
commit e01592e736
2 changed files with 21 additions and 6 deletions

View File

@ -0,0 +1,13 @@
/**
* External dependencies
*/
const config = require( 'config' );
const baseUrl = config.get( 'url' );
/**
* Shop pages.
*
* @type {string}
*/
export const SHOP_CART_BLOCK_PAGE = baseUrl + 'cart-block';
export const SHOP_CHECKOUT_BLOCK_PAGE = baseUrl + 'checkout-block';

View File

@ -7,19 +7,21 @@ import { shopper as wcShopper } from '@woocommerce/e2e-utils';
* Internal dependencies
*/
import { getBlockPagePermalink } from './get-block-page-permalink';
import { SHOP_CART_BLOCK_PAGE, SHOP_CHECKOUT_BLOCK_PAGE } from './constants';
export const shopper = {
...wcShopper,
goToCheckoutBlock: async () => {
const checkoutBlockPermalink = await getBlockPagePermalink(
`Checkout Block`
);
await page.goto( checkoutBlockPermalink, {
await page.goto( SHOP_CHECKOUT_BLOCK_PAGE, {
waitUntil: 'networkidle0',
} );
},
goToCartBlock: async () => {
await page.goto( SHOP_CART_BLOCK_PAGE, {
waitUntil: 'networkidle0',
} );
await expect( page ).toMatchElement( 'h1', { text: 'Checkout' } );
},
productIsInCheckoutBlock: async ( productTitle, quantity, total ) => {