| .. | ||
| docs | ||
| resources | ||
| snapshots/02-onboarding | ||
| tests | ||
| utils | ||
| .env.example | ||
| .eslintignore | ||
| .gitignore | ||
| .npmrc | ||
| global-setup.ts | ||
| package.json | ||
| playwright.config.ts | ||
| README.md | ||
| tsconfig.json | ||
WooCommerce PayPal Payments Plugin Tests
Depends on @inpsyde/playwright-utils package.
Detailed information about current test project can be found in docs.
Table of Content
- Local installation
- Installation of
node_modules - Installation of
playwright-utilsfor local development - Project configuration
- Run tests
- Autotest Execution workflow
- Coding standards
- Automated env setup scripts
Local installation
-
In VSCode open the terminal and clone PCP repository to your local PC:
git clone https://github.com/woocommerce/woocommerce-paypal-payments.git -
Change directory to newly cloned repo:
cd woocommerce-paypal-payments -
(Temporary, till autotests are not yet merged into main branch) Switch to
qabranch:git fetch origin git checkout qa -
Change directory to
./tests/qa/:cd tests/qa
Installation of node_modules
See also @inpsyde/playwright-utils documentation.
-
Make sure you're logged in the Syde npm package registry.
-
Make sure that
"workspaces": [ "playwright-utils" ]node isn't present in./tests/qa/package.json. -
In the terminal change directory to
./tests/qaand run following command:npm run setup:tests
Installation of playwright-utils for local development
See also @inpsyde/playwright-utils documentation.
-
Add
"workspaces": [ "playwright-utils" ]to./tests/qa/package.json. -
Delete
@inpsyde/playwright-utilsfrom./tests/qa/node_modules. -
In the terminal change directory to
./tests/qaand run following command:git clone https://github.com/inpsyde/playwright-utils.git@inpsyde/playwright-utilsrepository should be cloned asplaywright-utilsright inside the root directory of monorepo. -
Restart VSCode editor. This will create
playwright-utilsinstance in the source control tab of VSCode editor. -
Run following command:
npm run setup:utils -
@inpsyde/playwright-utilsshould reappear in node_modules. Following message (coming fromtsc-watch) should be displayed in the terminal:10:00:00 - Found 0 errors. Watching for file changes. -
If you plan to make changes in
playwright-utilskeep current terminal window opened and create another instance of terminal.
Project configuration
-
SSE setup - will be deprecated in Q1 of 2025.
-
In the test project directory (
./tests/qa/) create and configure.envfile:2.1 Set general variables following these steps.
2.2 Set PayPal API keys and test credentials. See
.env.example. The.envcontent with actual test users' credentials is stored in 1Password. -
Configure
playwright.config.tsof the project following these steps. -
Configure reporting to Xray in Jira following these steps.
-
To avoid conflicts make sure any other payment plugins are deleted.
-
Additional website and WooCommerce configuration is done automatically via
setup-woocommercedependency project (see/tests/_setup/woocommerce.setup.ts).
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 --project=all
Additional options to run tests from command line
-
Add scripts to
package.jsonof 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 (on Windows, Powershell):
npx playwright test --grep --% "PCP-123^|PCP-124^|PCP-125"It may be required additionally to specify the project (if tests relate to more then one project):
npx playwright test --project "project-name" --grep --% "PCP-123^|PCP-124^|PCP-125"
Autotest Execution workflow
-
Create Test Execution ticket in Jira, named after the tested plugin version, for example "Test Execution for v2.3.4-rc1, PHP8.1".
Note: For autotest execution there's no need to manually add tests cases to the execution - the executed tests will be imported automatically after execution.
-
Link release ticket (via
tests: PCP-234) to test execution ticket. -
Set Test Execution ticket status
In progress. -
In
.envfile of the test project (/tests/qa/) add/update test execution ticket key (TEST_EXEC_KEY='PCP-234'). -
Download tested plugin
.zippackage (usually attached to release ticket) and add it to/tests/qa/resources/files. You may need to remove version number from the file name (expected name:woocommerce-paypal-payments.zip). -
Optional: delete previous version of tested plugin from the website if you don't execute plugin foundation tests.
-
Start autotest execution from command line for the defined scope of tests (see this section). You should see
Test execution Jira key: PCP-234in the terminal. -
When finished test results will be imported to the specified test execution ticket in Jira.
-
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" --debugNote: command for restarting failed/skipped tests is posted to the terminal after the execution.
-
Report bugs (if any) and attach them to the test-runs of failed tests (Click "Create defect" or "Add defect" on test execution screen).
-
If needed fix failing tests in a new branch, create a PR and assign it for review.
-
Set Test execution ticket status to
Done.
Coding standards
Before commiting changes run following command:
npm run lint:js:fix
Automated env setup scripts
Local usage of automated env setup scripts assumes that the following steps are fulfilled:
-
Your current terminal dir to run scripts is
./tests/qa. -
Dependencies and
node_modulesare installed (see this section).Note: for now the storage of .zip files is restricted in .gitignore. Please ask someone of QA to provide the content of
./tests/qa/resources/filesdir. -
.envfile is configured as per step 2 of this section (simply copy-paste it fromPCP .envvault of 1Password). -
(Optional) For DDEV setup add
IGNORE_HTTPS_ERRORS=trueto.envand remove the Basic Auth credentials:# playwright-utils config IGNORE_HTTPS_ERRORS=true WP_BASE_URL='https://woocommerce-paypal-payments.ddev.site' WP_USERNAME=admin WP_PASSWORD=admin WP_BASIC_AUTH_USER= WP_BASIC_AUTH_PASS= STORAGE_STATE_PATH='./storage-states' STORAGE_STATE_PATH_ADMIN='./storage-states/admin.json'
Reset SSE env
Note: see SSE setup don in Confluence (will be deprecated in 2025).
-
Connect via
ssh:ssh -l fname php_version.emp.pluginpsyde.com -
Reset SSE website:
rm -rf /var/www/html/* 2>/dev/null; wp core download --version=X.Y.Z && wp config create && mariadb -e "DROP DATABASE fname; CREATE DATABASE fname;" && wp core install
Setup store
- Installs WooCommerce, Storefront theme, additional plugins (WP Debugging, Disable Nonce, Subscriptions, etc.).
- Configures website permalinks (
%postname%). - Configures WooCommerce default settings (country, currency, taxes, shipping, API keys, emails).
- Creates classic pages, products, coupons, registered customer.
npm run setup:store:default
Setup block pages
npm run setup:checkout:block
Setup classic pages
npm run setup:checkout:classic
Setup taxes included
npm run setup:tax:inc
Setup taxes excluded
npm run setup:tax:exc
Setup US store and merchant (block pages)
npm run setup:pcp:usa
Setup German store and merchant (block pages)
npm run setup:pcp:germany
Setup Mexican store and merchant (block pages)
npm run setup:pcp:mexico
Setup US store and merchant with vaulting (PayPal, ACDC) enabled (block pages)
npm run setup:pcp:usa:vaulting
Setup US store and merchant with vaulting (PayPal, ACDC) enabled (classic pages)
npm run setup:pcp:usa:vaulting:classic
Setup US store and merchant for Vaulting subscription (WC Subscriptions plugin, products, block pages)
npm run setup:pcp:usa:vaulting:subscription
Setup US store and merchant for PayPal subscriptions (WC Subscriptions plugin, products, block pages)
npm run setup:pcp:usa:paypal:subscription