woocommerce-paypal-payments/tests/qa-legacy-ui
2026-04-20 17:27:35 +02:00
..
.github/workflows Migrate tests for legacy UI 2025-04-30 06:48:12 +02:00
resources Add more setup scripts and projects for separate test exec. 2026-03-25 13:32:03 +01:00
tests Fix test sets 2026-04-20 17:27:35 +02:00
utils Add more setup scripts and projects for separate test exec. 2026-03-25 13:32:03 +01:00
.env.example Add auto env setup scripts 2026-03-17 13:22:05 +01:00
.eslintignore Add eslingignore, update gitignore 2025-10-01 12:57:37 +02:00
.gitignore Add PCP-plugin update functionality 2026-03-13 10:21:33 +01:00
.npmrc Migrate tests for legacy UI 2025-04-30 06:48:12 +02:00
global-setup.ts Update pcp.setup scripts, add timeline comments to utils 2026-03-19 08:35:20 +01:00
package-lock.json Fix test sets 2026-04-20 17:27:35 +02:00
package.json Fix test sets 2026-04-20 17:27:35 +02:00
playwright.config.ts Add more setup scripts and projects for separate test exec. 2026-03-25 13:32:03 +01:00
README.md Fix for setup scripts on Mac, cleanup package.json 2026-03-27 10:02:24 +01:00
tsconfig.json Migrate tests for legacy UI 2025-04-30 06:48:12 +02:00

PCP Tests (legacy UI)

Depends on @inpsyde/playwright-utils package.

Project structure

  • resources - files with test-data, images, project related installation packages, types, etc.

  • tests - test specifications. For payment plugins contains following folders:

    • 01-plugin-foundation - general tests for plugin installation, uninstallation, activation, deactivation, display of plugin in WooCommerce -> Settings -> Payments.

    • 02-merchant-setup - tests for connection of current plugin instance to the payment system provider API via merchant (seller) credentials.

    • 03-plugin-settings - tests for various plugin settings, may include assertions of settings effect on frontend.

    • 04-frontend-ui - tests for plugin UI on frontend: display of payment buttons, display of payment methods depending on customer's country, etc.

    • 05-transaction - tests of payment process. Typically include: adding products to cart as precondition, payment (transaction) process, assertions on order received page, dashboard order edit page, payment via payment system provider API.

    • 06-refund - tests for refund transactions. Typically include: finished transaction as precondition, refund via payment system provider API on dashboard order edit page, assertion of refund statuses.

    • 07-vaulting - tests for transactions with enabled vaulting (saved payment methods for registered customers). Ability to remember payment methods and use them for transactions.

    • 08-subscriptions - tests for transactions for subscription products. Requires WooCommerce Subscriptions plugin. Usually available to registered customers and also includes vaulting and renewal of subscription (with automatic payment). WooCommerce Subscriptions plugin (can be downloaded here, login credentials in 1Password).

    • 09-compatibility - tests for compatibility with other themes, plugins, etc.

    * - folders are numerated on purpose, to force correct sequence of tests - from basic to advanced. Although each test should be independent and work separately, it is better to start testing from plugin-foundation and move to more complex tests.

    ** - folders and numeration can be different, based on project requirements.

  • utils - project related utility files, built on top of @inpsyde/playwright-utils.

    • admin - functionality for operating dashboard pages.

    • frontend - functionality for operating frontend pages, hosted checkout pages (payment system provider's pages).

    • test.ts - declarations of project related test fixtures.

    • other project related functionality, like helpers, APIs, urls.

  • .env, playwright.config.ts, package.json - see below.

Setup @inpsyde/playwright-utils as a node package

See also @inpsyde/playwright-utils documentation.

  1. Make sure you're logged in the Syde npm package registry.

  2. Make sure that "workspaces": [ "playwright-utils" ] node isn't present in ./tests/qa/package.json.

  3. In the terminal change directory to ./tests/qa and run following command:

    npm run setup:tests
    

Setup @inpsyde/playwright-utils for local development

See also @inpsyde/playwright-utils documentation.

  1. Add "workspaces": [ "playwright-utils" ] to ./tests/qa/package.json.

  2. Delete @inpsyde/playwright-utils from ./tests/qa/node_modules.

  3. In the terminal change directory to ./tests/qa and run following command:

    git clone https://github.com/inpsyde/playwright-utils.git
    

    @inpsyde/playwright-utils repository should be cloned as playwright-utils right inside the root directory of project.

  4. Restart VSCode editor. This will create playwright-utils instance in the source control tab of VSCode editor.

  5. Run following command:

    npm run setup:utils
    
  6. @inpsyde/playwright-utils should reappear in node_modules. Following message (coming from tsc-watch) should be displayed in the terminal:

    10:00:00 - Found 0 errors. Watching for file changes.
    
  7. If you plan to make changes in playwright-utils keep current terminal window opened and create another instance of terminal for other commands.

Project configuration

  1. SSE setup - will be deprecated in Q1 of 2025.

  2. Configure .env file following these steps. See also /tests/qa/.env.example. The .env content with actual test users' credentials is in 1Password in Legacy UI section.

  3. Configure playwright.config.ts of the project following these steps.

  4. Additional website and WooCommerce configuration is done automatically via setup-woocommerce dependency project (see /tests/_setup/woocommerce.setup.ts).

  5. To avoid conflicts make sure any other payment plugins are deleted.

  6. Reporting to Xray in Jira is configured this way.

Run tests

To execute tests, in the terminal, navigate to the qa directory of the project (e.g. cd tests/qa) and run following command:

npx playwright test

Additional options to run tests from command line

  • Add scripts to package.json of the project (eligible for Windows, not tested on other OS):

    "scripts": {
    	"test:smoke":  "npx playwright test --grep \"@Smoke\"",
    	"test:critical": "npx playwright test --grep \"@Critical\"",
    	"test:ui": "npx playwright test --grep \"UI\"",
    	"test:functional": "npx playwright test --grep \"Functional\"",
    	"test:all": "npm run test:ui & npm run test:functional"
    },
    

    Run script with the following command:

    npm run test:critical
    
  • Run several tests by test ID

    npx playwright test --project project-name --grep "PCP-123|PCP-124|PCP-125"
    

Autotest Execution workflow

  1. Create Test Execution ticket in Jira, named after the tested plugin version, for example "Test Execution for v2.3.4-rc1, PHP8.1".

  2. Link release ticket (via tests: PCP-234).

  3. Set Test Execution ticket status In progress.

  4. Add/update test execution ticket key in .env file of the project (TEST_EXEC_KEY).

  5. Download tested plugin .zip package (usually attached to release ticket) and add it to /project/<project-name>/resources/files. You may need to remove version number from the file name.

  6. Optional: delete previous version of tested plugin from the website if you don't execute plugin foundation tests.

  7. Start autotest execution from command line for the defined scope of tests (e.g. all, Critical, etc.). You should see Test execution Jira key: PCP-234 in the terminal.

  8. When finished test results should be exported to the specified test execution ticket in Jira.

  9. Analyze failed tests (if any). Restart execution for failed tests, possibly in debug mode (for Windows):

    npx playwright test --grep "PCP-123|PCP-124|PCP-125" --debug
    
  10. Report bugs (if any) and attach them to the test-runs of failed tests (Click "Create defect" or "Add defect" on test execution screen).

  11. If needed fix failing tests in a new branch, create a PR and assign it for review.

  12. Set Test execution ticket status to Done.

Coding standards

Before commiting changes run following command:

npm run lint:js:fix

Reset Kinsta env

Find SSH data in Kinsta dashboard for your tested env. Replace data in the following one-line command and run it in the terminal to reset the env:

ssh <your-ssh-username>@<your-ssh-host> -p <your-ssh-port> '${HOME}/bin/reset-wp.sh --wp-version=6.9 --wp-type=single && exit'

Automated env setup scripts for migration

Preconditions

Local usage of automated env setup scripts assumes that the following steps are fulfilled:

Note: the staging env on Kinsta should be created and the script to reset env provided by devops (if not - create a ticket on SDO board).

  1. Clone PayPal repo to your local machine:

    git clone https://github.com/woocommerce/woocommerce-paypal-payments.git
    

    Note: temporary, for migration testing change branch to dev/qa/migration-tests: git checkout dev/qa/migration-tests.

  2. Copy following packages into /tests/qa-legacy-ui/resources/files:

    • Legacy PayPal plugin package (e.g. v2.9.6) named as woocommerce-paypal-payments.zip

    • Tested RC version (v4.0.0+) as woocommerce-paypal-payments-update.zip.

    • WooCommerce Subscriptions package named as woocommerce-subscriptions.zip

  3. In the terminal open the cloned repo and navigate to /tests/qa-legacy-ui dir:

    cd tests/qa-legacy-ui
    
  4. Install Node dependencies and Playwright:

    npm run setup:tests
    
  5. In the /tests/qa-legacy-ui directory create a .env file and copy-paste content from PCP .env vault of 1Password replacing all the data for your test env. Alternatively use .env.example.

  6. Run the scripts described below.

Reset env and WooCommerce

  • Resets the Kinsta staging env.
  • Configures website permalinks (%postname%).
  • Installs plugins and themes:
    • WooCommerce
    • Storefront theme
    • Additional plugins (Disable Nonce, WC Subscriptions, etc.)
  • Configures WooCommerce for default country (USA):
    • API keys
    • Country/currency: USA/USD
    • Taxes: included, 10% rate
    • Shipping: flat rate/10 USD and free
    • Emails: disabled
  • Creates test entities:
    • Classic cart and checkout
    • Tested products
    • Coupons
    • Registered US customer
npm run env:reset

Setup PCP for specific country

  • Runs reset env and WooCommerce script (for specific country).
  • Installs PCP plugin (woocommerce-paypal-payments.zip)
  • Connects merchant from specified country

For USA

  1. PCP + connected US merchant (PayPal and all PMs disabled)

    npm run env:setup:pcp:usa
    
  2. PCP + connected US merchant + enabled PayPal, Pay Later, ACDC and disabled Venmo + button orientation

    npm run env:setup:pcp:usa:classic:horizontal:paypal-paylater-acdc
    npm run env:setup:pcp:usa:classic:vertical:paypal-paylater-acdc
    env:setup:pcp:usa:classic:acdc
    env:setup:pcp:usa:classic:bcdc
    env:setup:pcp:usa:classic:bcdc-paypal
    

For Germany & PUI (disabled by default)

npm run env:setup:pcp:germany

For Mexico & OXXO (disabled by default)

npm run env:setup:pcp:mexico

Upgrade PCP (without env reload)

npm run env:setup:pcp:update

Upgrade checkout pages (without env reload)

Enable classic cart/chekcout

npm run env:setup:classic:pages

Enable block cart/chekcout

npm run env:setup:block:pages