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

Commit

Permalink
Migrate translation tests to Playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
nielslange committed Dec 7, 2023
1 parent 0af87c6 commit 9c19253
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 99 deletions.
99 changes: 0 additions & 99 deletions tests/e2e-jest/specs/shopper/cart-checkout/translations.test.js

This file was deleted.

7 changes: 7 additions & 0 deletions tests/e2e/bin/scripts/parallel/translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

wp language core install nl_NL
wp language core activate nl_NL
wp language plugin install woo-gutenberg-products-block nl_NL
wp language plugin update woo-gutenberg-products-block
wp language core activate en_US
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* External dependencies
*/
import { expect, test as base } from '@woocommerce/e2e-playwright-utils';
import { cli } from '@woocommerce/e2e-utils';

/**
* Internal dependencies
*/
import { REGULAR_PRICED_PRODUCT_NAME } from '../checkout/constants';
import { CheckoutPage } from '../checkout/checkout.page';

const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
checkoutPageObject: async ( { page }, use ) => {
const pageObject = new CheckoutPage( {
page,
} );
await use( pageObject );
},
} );

test.describe( 'Shopper → Translations', () => {
test.beforeAll( async () => {
await cli(
`npm run wp-env run tests-cli -- wp language core activate nl_NL`
);
} );

test.afterAll( async () => {
await cli(
`npm run wp-env run tests-cli -- wp language core activate en_US`
);
} );

test( 'User can view translated Cart block', async ( {
frontendUtils,
page,
} ) => {
await frontendUtils.goToShop();
await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
await frontendUtils.goToCart();

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

const productHeader = page
.locator( '.wc-block-cart-items .wc-block-cart-items__header span' )
.first();
await expect( productHeader ).toHaveText( 'Product' );

const removeLink = page
.locator( '.wc-block-cart-item__remove-link' )
.first();
await expect( removeLink ).toHaveText( 'Verwijder item' );

const submitButton = page
.locator( '.wc-block-cart__submit-button' )
.first();
await expect( submitButton ).toHaveText( 'Ga naar afrekenen' );

const orderSummary = page.locator(
'.wp-block-woocommerce-cart-order-summary-block'
);
await expect( orderSummary ).toHaveText( /Subtotaal/ );
await expect( orderSummary ).toHaveText( /Een waardebon toevoegen/ );
await expect( orderSummary ).toHaveText( /Totaal/ );
} );

test( 'User can view translated Checkout block', async ( {
frontendUtils,
page,
} ) => {
await frontendUtils.goToShop();
await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
await frontendUtils.goToCart();
await frontendUtils.goToCheckout();

const contactHeading = page.locator(
'#contact-fields .wc-block-components-checkout-step__title'
);
await expect( contactHeading ).toHaveText( 'Contactgegevens' );

const shippingHeading = page.locator(
'#shipping-fields .wc-block-components-checkout-step__title'
);
await expect( shippingHeading ).toHaveText( 'Verzendadres' );

const shippingOptionsHeading = page.locator(
'#shipping-option .wc-block-components-checkout-step__title'
);
await expect( shippingOptionsHeading ).toHaveText( 'Verzendopties' );

const paymentMethodHeading = page.locator(
'#payment-method .wc-block-components-checkout-step__title'
);
await expect( paymentMethodHeading ).toHaveText( 'Betaalopties' );

const returnToCart = page.locator(
'.wc-block-components-checkout-return-to-cart-button'
);
await expect( returnToCart ).toHaveText( 'Ga terug naar winkelwagen' );

const submitButton = page.locator(
'.wc-block-components-checkout-place-order-button'
);
await expect( submitButton ).toHaveText( 'Plaats bestelling' );

const orderSummary = page.locator(
'.wp-block-woocommerce-checkout-order-summary-block'
);
await expect( orderSummary ).toHaveText( /Besteloverzicht/ );
await expect( orderSummary ).toHaveText( /Subtotaal/ );
await expect( orderSummary ).toHaveText( /Verzending/ );
await expect( orderSummary ).toHaveText( /Totaal/ );
} );
} );

0 comments on commit 9c19253

Please sign in to comment.