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

Commit

Permalink
Fix/e2e tests timeout issue (#6165)
Browse files Browse the repository at this point in the history
* Increase timeout of translations test to 30000

* Wait for network idle in goToCart and goToCheckout

* Increase timeout to 30000

* fix E2E tests

* try fix

* test

* test

* test

* another test

* fix test

* 60s timeout

* test

* Update product constants

* Simplify orderSummary check

* Go back to page.$

Co-authored-by: Luigi <[email protected]>
  • Loading branch information
alexflorisca and gigitux authored Apr 8, 2022
1 parent fbd4126 commit c7e41d6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/specs/shopper/cart-checkout-payments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { shopper } from '../../../utils';
import { SIMPLE_PRODUCT_NAME } from '../../../utils/constants';
import { SIMPLE_VIRTUAL_PRODUCT_NAME } from '../../../utils/constants';

if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
// eslint-disable-next-line jest/no-focused-tests
Expand All @@ -12,7 +12,7 @@ if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
describe( 'Shopper → Cart/Checkout → Can use express checkout', () => {
it( 'Express Payment button is available on both Cart & Checkout pages', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME );
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCart();
await shopper.block.mockExpressPaymentMethod();
// We need to re-render the cart for the express payments block to be updated,
Expand Down
21 changes: 13 additions & 8 deletions tests/e2e/specs/shopper/cart-checkout-translations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,31 @@ describe( 'Shopper → Cart → Can view translated cart & checkout blocks', ()
await shopper.goToShop();
await shopper.addToCartFromShopPage( '128GB USB Stick' );
await shopper.block.goToCart();
const productHeader = await page.$(

await page.waitForSelector( '.wp-block-woocommerce-filled-cart-block' );

const productHeader = await page.waitForSelector(
'.wc-block-cart-items .wc-block-cart-items__header span'
);
await expect( productHeader ).toMatch( 'Produit', { timeout: 2000 } );
await expect( productHeader ).toMatch( 'Produit' );

const removeLink = await page.$( '.wc-block-cart-item__remove-link' );
const removeLink = await page.waitForSelector(
'.wc-block-cart-item__remove-link'
);
await expect( removeLink ).toMatch( 'Retirer l’élément' );

const submitButton = await page.$( '.wc-block-cart__submit-button' );
const submitButton = await page.waitForSelector(
'.wc-block-cart__submit-button'
);
await expect( submitButton ).toMatch( 'Procéder au paiement' );

const orderSummary = await page.$(
'.wp-block-woocommerce-cart-order-summary-block'
);

await expect( orderSummary ).toMatch( 'Total panier' );
await expect( orderSummary ).toMatch( 'Sous-total' );
await expect( orderSummary ).toMatch( 'Coupon code' );
await expect( orderSummary ).toMatch( 'Appliquer un code promo' );
} );

it( 'should be able to view translated Checkout block', async () => {
Expand All @@ -72,9 +79,7 @@ describe( 'Shopper → Cart → Can view translated cart & checkout blocks', ()
const contactHeading = await page.$(
'#contact-fields .wc-block-components-checkout-step__title'
);
await expect( contactHeading ).toMatch( 'Coordonnées', {
timeout: 2000,
} );
await expect( contactHeading ).toMatch( 'Coordonnées' );

const shippingHeading = await page.$(
'#shipping-fields .wc-block-components-checkout-step__title'
Expand Down
9 changes: 6 additions & 3 deletions tests/e2e/specs/shopper/checkout-different-addresses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import {
reactivateCompatibilityNotice,
} from '../../../utils';

import { BILLING_DETAILS, SHIPPING_DETAILS } from '../../../utils/constants';
const SIMPLE_PRODUCT_NAME = '128GB USB Stick';
import {
BILLING_DETAILS,
SHIPPING_DETAILS,
SIMPLE_PHYSICAL_PRODUCT_NAME,
} from '../../../utils/constants';

if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 )
// eslint-disable-next-line jest/no-focused-tests
Expand Down Expand Up @@ -71,7 +74,7 @@ describe( 'Shopper → Checkout → Can have different shipping and billing addr

it( 'allows customer to have different shipping and billing addresses', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME );
await shopper.addToCartFromShopPage( SIMPLE_PHYSICAL_PRODUCT_NAME );
await shopper.block.goToCheckout();
await unsetCheckbox( '#checkbox-control-0' );
await shopper.block.fillShippingDetails( SHIPPING_DETAILS );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/shopper/checkout-form-warnings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { shopper } from '../../../utils';
import {
SIMPLE_PRODUCT_NAME,
SIMPLE_VIRTUAL_PRODUCT_NAME,
CUSTOMER_USERNAME,
CUSTOMER_PASSWORD,
} from '../../../utils/constants';
Expand Down Expand Up @@ -48,7 +48,7 @@ describe( 'Shopper → Checkout → Can see warnings when form is incomplete', (

it( 'Shows warnings when form is incomplete', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME );
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCheckout();

// Click on "Place Order" button
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/specs/shopper/checkout-single-use-coupon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { withRestApi } from '@woocommerce/e2e-utils';
*/
import { shopper } from '../../../utils';
import { createCoupon } from '../../utils';
import { SIMPLE_PRODUCT_NAME } from '../../../utils/constants';
import { SIMPLE_VIRTUAL_PRODUCT_NAME } from '../../../utils/constants';

if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 )
// eslint-disable-next-line jest/no-focused-tests
Expand All @@ -29,7 +29,7 @@ afterAll( async () => {
describe( 'Shopper → Checkout → Can apply single-use coupon once', () => {
it( 'allows checkout to apply single-use coupon once', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME );
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCheckout();
await shopper.block.applyCouponFromCheckout( coupon.code );

Expand Down Expand Up @@ -63,7 +63,7 @@ describe( 'Shopper → Checkout → Can apply single-use coupon once', () => {

it( 'Prevents checkout applying single-use coupon twice', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME );
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCheckout();
await shopper.block.applyCouponFromCheckout( coupon.code );
await expect( page ).toMatch( 'Coupon usage limit has been reached.' );
Expand Down

0 comments on commit c7e41d6

Please sign in to comment.