woocommerce/packages/js/e2e-core-tests
Gabriel Manussakis 532f1beb02
[Accessibility] Fix misspelling in inline documentation in packages/js/* (#48640)
* Fix "colleciton" typo

* Fix "fomatting" typo

* Fix "elments" typo

* Fix "actuall" typo

* Fix "witth" typo

* Fix "varation" typo

* Fix "procesing" typo

* Fix "neigbouring" typo

* Fix "staticly" typo

* Fix "Curreny" typo

* Fix "addd" typo

* Fix "accessibile" typo

* Fix "avaiable" typo

* Fix "Resurce" typo

* Fix "curent" typo

* Fix "flakyness" typo

* Fix "flakyness" typo

* Fix "Shiping" typo

* Fix "specfically" and "Shiping" typos

* Fix "flakyness" typo

* Fix "avaliable" typo

* Fix "availble" typo

* Fix "oject" typo

* Fix "explict" typo

* Fix "sumary" typo

* Fix "whn" typo

* Fix "normaly" typo

* Add changelog files
2024-06-21 10:28:54 -07:00
..
bin add e2e-core-tests build script (#31221) 2021-11-23 12:57:56 +01:00
changelog Update/unify jest@27 across all packages (#34322) 2022-09-06 09:29:45 -05:00
installFiles Added EOF Newlines 2022-05-10 13:35:31 -07:00
src [Accessibility] Fix misspelling in inline documentation in packages/js/* (#48640) 2024-06-21 10:28:54 -07:00
test-data Updating references to old album-1 image 2022-05-19 16:05:23 -07:00
.eslintrc.js Update the @woocommerce/eslint-plugin and fix bugs (#36988) 2023-03-02 11:36:38 +13:00
.gitignore Move back test-data 2021-12-29 13:26:55 -03:00
CHANGELOG.md Add e2e tests to check shipping costs consistency in cart and checkout (#33208) 2022-06-03 10:01:04 -06:00
NEXT_CHANGELOG.md js packages next changelogs 2021-11-11 16:34:50 +13:00
README.md Update Woo.com references to WooCommerce.com (#46259) 2024-04-09 09:50:15 +01:00
core-tests-root.js Fix app root fetching when using PNPM version 7 (#33929) 2022-07-27 14:13:17 -06:00
package.json Update to pnpm 9.1 (#47385) 2024-05-13 10:57:39 -03:00

README.md

WooCommerce Core End to End Test Suite

This package contains the automated end-to-end tests for WooCommerce.

Table of contents

Pre-requisites

Setting up the test environment

Follow E2E setup instructions.

Setting up core tests

Version 0.2.0 or newer

Version 0.2.0 added a test installer that will populate the tests/e2e/specs folder with test scripts for all the current core test suite. It also creates sample configuration files including all the configuration data needed to run the core tests.

  • Install the e2e-environment npm install @woocommerce/e2e-environment --save-dev
  • Run the installer npx wc-e2e install @woocommerce/e2e-core-tests
  • Merge the sample configuration files:
    • tests/e2e/docker/woocommerce.e2e-core-tests.sh => initialize.sh
    • tests/e2e/config/default-woocommerce.e2e-core-tests.json => default.json

Version 0.1.X or other test runner

  • Create the folder tests/e2e/specs in your repository if it does not exist.
  • To add a core test to your test suite, create a new .test.js file within tests/e2e/specs . Example code to run all the shopper tests:

const { runShopperTests } = require( '@woocommerce/e2e-core-tests' );

runShopperTests();

Retrying/Re-running tests

On a new site, the setup and activation tests prepare the site for the remainder of the tests. To retry/rerun the test suite on a site where setup/onboarding test have already run use the environment variable E2E_RETEST=1.

Test functions

The functions to access the core tests are:

Activation and setup

  • runSetupOnboardingTests - Run all setup and onboarding tests
    • runActivationTest - Merchant can activate WooCommerce
    • runOnboardingFlowTest - Merchant can complete onboarding flow
    • runTaskListTest - Merchant can complete onboarding task list
    • runInitialStoreSettingsTest - Merchant can complete initial settings

Merchant

  • runMerchantTests - Run all merchant tests
    • runAddShippingClassesTest - Merchant can create shipping classes and let shopper test them
    • runAddNewShippingZoneTest - Merchant can create shipping zones and let shopper test them
    • runAddSimpleProductTest - Merchant can create a simple product
    • runAddVariableProductTest - Merchant can create a variable product
    • runCreateCouponTest - Merchant can create coupon
    • runCreateOrderTest - Merchant can create order
    • runMerchantOrdersCustomerPaymentPage - Merchant can visit the customer payment page
    • runMerchantOrderEmailsTest - Merchant can receive order emails and resend emails by Order Actions
    • runEditOrderTest - Merchant can edit an order in the dashboard
    • runOrderStatusFilterTest - Merchant can filter orders by order status
    • runOrderRefundTest - Merchant can refund an order
    • runOrderApplyCouponTest - Merchant can apply a coupon to an order
    • runOrderSearchingTest - Merchant can search for order via different terms
    • runProductEditDetailsTest - Merchant can edit an existing product
    • runProductSearchTest - Merchant can search for a product and view it
    • runProductSettingsTest - Merchant can update product settings
    • runTaxSettingsTest - Merchant can update tax settings
    • runUpdateGeneralSettingsTest - Merchant can update general settings
    • runMerchantOrderEmailsTest - Merchant can receive order emails and resend emails by Order Actions
    • runAnalyticsPageLoadsTest - Merchant can load and see all pages in Analytics
    • runImportProductsTest - Merchant can import products via CSV file
    • runInitiateWccomConnectionTest - Merchant can initiate connection to WooCommerce.com
    • runAdminPageLoadTests - Merchant can load pages from the WP Admin sidebar

Shopper

  • runShopperTests - Run all shopper tests
    • runCartApplyCouponsTest - Shopper can use coupons on cart
    • runCartPageTest - Shopper can view and update cart
    • runCheckoutApplyCouponsTest - Shopper can use coupons on checkout
    • runCheckoutPageTest - Shopper can complete checkout
    • runMyAccountPageTest - Shopper can access my account page
    • runMyAccountPayOrderTest - Shopper can pay for their order in My Account
    • runProductBrowseSearchSortTest - Shopper can browse, search & sort products
    • runSingleProductPageTest - Shopper can view single product page in many variations (simple, variable, grouped)
    • runVariableProductUpdateTest - Shopper can view and update variations on a variable product
    • runCheckoutCreateAccountTest - Shopper can create an account during checkout
    • runCheckoutLoginAccountTest - Shopper can login to an account during checkout
    • runMyAccountCreateAccountTest - Shopper can create an account via my account page
    • runCartCalculateShippingTest - Shopper can calculate shipping in the cart
    • runCartRedirectionTest - Shopper is redirected to the cart page after adding to cart
    • runOrderEmailReceivingTest - Shopper can receive an email for his order
    • runCartAndCheckoutConsistentShippingTest - Shopper gets consistent shipping information on cart and checkout pages

REST API

  • runApiTests - Run all API tests
    • runExternalProductAPITest - Can create, read, and delete an external product
    • runGroupedProductAPITest - Can create, read, and delete a grouped product
    • runVariableProductAPITest - Can create, read, and delete a variable product and its variations
    • runCouponApiTest - Can create, read, and delete a coupon
    • runOrderApiTest - Can create, read, and delete an order

Contributing a new test

  • In your branch create a new example-test-name.test.js under the appropriate folder in the specs directory.
  • Jest does not allow its global functions to be accessed outside the jest environment. To allow the test code to be published in a package import any jest global functions used in your test.
const {
	it,
	describe,
	beforeAll,
} = require( '@jest/globals' );
  • Wrap your test in a function and export it
const runExampleTestName = () => {
	describe('Example test', () => {
		beforeAll(async () => {
			// ...
		});

		it('do some example action', async () => {
            // ...
		});
        // ...
    });
});

module.exports = runExampleTestName;
const runExampleTestName = require( './grouping/example-test-name.test' );
// ...
module.exports = {
// ...
    runExampleTestName,
}