woocommerce/packages/js/e2e-core-tests
Christopher Allford c91dda177d
Fix E2E Tests (#31205)
* Removed Changlogger Autoload

* Changed Jetpack Changelogger Formatter Loading

Rather than using the Composer autoload, we should use the
changelogger's "filename" option to point directly at the file.
This keeps the file out of the autoloads, since it's possible that
plugins or packages may be symlinked and break the relative
path to the plugin.
2021-11-16 15:01:50 +13:00
..
changelog Add Jetpack Changelogger 2021-11-11 16:28:10 +13:00
specs fix merge conflicts 2021-11-15 13:03:14 -04:00
test-data Update e2e package locations and add PNPM (#30977) 2021-10-29 08:32:31 +13:00
CHANGELOG.md Update e2e package locations and add PNPM (#30977) 2021-10-29 08:32:31 +13:00
NEXT_CHANGELOG.md js packages next changelogs 2021-11-11 16:34:50 +13:00
README.md Update links to moved e2e READMEs. 2021-11-04 12:58:11 +01:00
composer.json Fix E2E Tests (#31205) 2021-11-16 15:01:50 +13:00
composer.lock update to 3.0.2 of changelogger 2021-11-11 17:03:44 +13:00
core-tests-root.js Update e2e package locations and add PNPM (#30977) 2021-10-29 08:32:31 +13:00
index.js Update e2e package locations and add PNPM (#30977) 2021-10-29 08:32:31 +13:00
package.json Update links to moved e2e READMEs. 2021-11-04 12:58:11 +01:00
project.json Revert "add nx composer-install targets" 2021-11-11 16:47:50 +13: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

  • 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

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

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 tests/e2e/core-tests/specs folder.
  • 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;
  • Add your test to tests/e2e/core-tests/specs/index.js
const runExampleTestName = require( './grouping/example-test-name.test' );
// ...
module.exports = {
// ...
    runExampleTestName,
}