diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 0000000000..b3a468d175 --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -0,0 +1,134 @@ +name: E2E Tests + +on: + workflow_dispatch: + inputs: + update-workflows: + description: 'Weather generate new snapshots' + type: boolean + default: false + wp-rc-version: + description: 'WordPress version for Release Candidate (i.e. 6.3-RC3)' + wc-rc-version: + description: 'WooCommerce version for Release Candidate (i.e. 8.0.0-rc.1)' + test-suite: + description: 'Test suite to run' + required: true + default: 'critical' + type: choice + options: + - critical + - onboarding + - all + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build package + uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@a9af34f34e95cbe18703198c7e972e97ebcd7473 + with: + PHP_VERSION: 7.4 + NODE_VERSION: 22 + PLUGIN_MAIN_FILE: ./woocommerce-paypal-payments.php + PLUGIN_VERSION: 3.0.0 + PLUGIN_FOLDER_NAME: woocommerce-paypal-payments + ARCHIVE_NAME: woocommerce-paypal-payments + COMPILE_ASSETS_ARGS: '-vv --env=root' + + E2ETests: + name: E2E Tests + needs: build + runs-on: ubuntu-latest + env: + FORCE_COLOR: 2 + steps: + - uses: actions/checkout@v2 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: woocommerce-paypal-payments + path: ./tests/qa/resources/files + + - name: Create and upload zip file + working-directory: ./tests/qa/resources/files + run: | + zip -r ./woocommerce-paypal-payments.zip ./woocommerce-paypal-payments + rm -rf woocommerce-paypal-payments + + - name: Configure npm for GitHub Packages + working-directory: ./tests/qa + run: | + # Create clean .npmrc + echo "@inpsyde:registry=https://npm.pkg.github.com" > .npmrc + echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_SYDE }}" >> .npmrc + + - name: Install Environment + working-directory: ./tests/qa + run: npm run setup:env + + - name: Install WP release candidate (optional) + if: github.event.inputs.wp-rc-version != '' + working-directory: ./tests/qa + env: + INPUT_WP_RC_VERSION: ${{ github.event.inputs.wp-rc-version }} + run: | + npm run -- wp-env run tests-cli -- wp core update --version="${INPUT_WP_RC_VERSION}" + npm run -- wp-env run tests-cli -- wp core update-db + + - name: Install WC release candidate (optional) + if: github.event.inputs.wc-rc-version != '' + working-directory: ./tests/qa + env: + INPUT_WC_RC_VERSION: ${{ github.event.inputs.wc-rc-version }} + run: | + npm run -- wp-env run tests-cli -- wp plugin update woocommerce --version="${INPUT_WC_RC_VERSION}" + npm run -- wp-env run tests-cli -- wp wc update + + - name: Install Tests + working-directory: ./tests/qa + run: npm run setup:tests + + - name: Create .env file + working-directory: ./tests/qa + run: | + echo "${{ secrets.QA_ENV_FILE }}" > .env + + - name: Run E2E tests + working-directory: ./tests/qa + run: | + if [ "${{ github.event.inputs.update_snapshots }}" == "true" ]; then + npm run tests:${{ github.event.inputs.test-suite }} -- --update-snapshots + else + npm run tests:${{ github.event.inputs.test-suite }} + fi + + - name: Archive updated snapshots + if: github.event.inputs.update_snapshots == 'true' + uses: actions/upload-artifact@v4 + with: + name: snapshots + path: tests/qa/snapshots + if-no-files-found: warn + retention-days: 5 + + - name: Archive Playwright Report + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: playwright-test-results + path: tests/qa/playwright-report + if-no-files-found: ignore + retention-days: 5 + + - name: Archive Test Results + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: test-results + path: tests/qa/test-results/ + if-no-files-found: ignore + retention-days: 5 diff --git a/tests/inc/inpsyde/.gitignore b/tests/inc/inpsyde/.gitignore new file mode 100644 index 0000000000..f7a6ed3134 --- /dev/null +++ b/tests/inc/inpsyde/.gitignore @@ -0,0 +1,4 @@ +* +!composer.json +!composer.lock +!.gitignore diff --git a/tests/inc/inpsyde/composer.json b/tests/inc/inpsyde/composer.json new file mode 100644 index 0000000000..4d5b9d0781 --- /dev/null +++ b/tests/inc/inpsyde/composer.json @@ -0,0 +1,20 @@ +{ + "name": "woocommerce-paypal-payments/tests", + "description": "Private test dependencies for WooCommerce PayPal Payments tests", + "type": "project", + "repositories": { + "packagist.org": false, + "private-packagist": { + "type": "composer", + "url": "https://repo.packagist.com/inpsyde/" + } + }, + "require": { + "inpsyde-mirror/woocommerce-subscriptions": "^7.9" + }, + "config": { + "allow-plugins": { + "composer/installers": true + } + } +} diff --git a/tests/inc/inpsyde/composer.lock b/tests/inc/inpsyde/composer.lock new file mode 100644 index 0000000000..295f210714 --- /dev/null +++ b/tests/inc/inpsyde/composer.lock @@ -0,0 +1,199 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6ad1aceb7a63df87161c924efd379cc4", + "packages": [ + { + "name": "composer/installers", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "12fb2dfe5e16183de69e784a7b84046c43d97e8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/12fb2dfe5e16183de69e784a7b84046c43d97e8e", + "reference": "12fb2dfe5e16183de69e784a7b84046c43d97e8e", + "shasum": "", + "mirrors": [ + { + "url": "https://repo.packagist.com/inpsyde/dists/%package%/%version%/r%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "composer/composer": "^1.10.27 || ^2.7", + "composer/semver": "^1.7.2 || ^3.4.0", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-phpunit": "^1", + "symfony/phpunit-bridge": "^7.1.1", + "symfony/process": "^5 || ^6 || ^7" + }, + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-main": "2.x-dev" + }, + "plugin-modifies-install-path": true + }, + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://repo.packagist.com/inpsyde/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "MantisBT", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Starbug", + "Thelia", + "Whmcs", + "WolfCMS", + "agl", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "concreteCMS", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "known", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "matomo", + "mediawiki", + "miaoxing", + "modulework", + "modx", + "moodle", + "osclass", + "pantheon", + "phpbb", + "piwik", + "ppi", + "processwire", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "sylius", + "tastyigniter", + "wordpress", + "yawik", + "zend", + "zikula" + ], + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/v2.3.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-06-24T20:46:46+00:00" + }, + { + "name": "inpsyde-mirror/woocommerce-subscriptions", + "version": "7.9.0", + "dist": { + "type": "zip", + "url": "https://packagist.inpsyde.com/satispress/woocommerce-subscriptions/7.9.0", + "shasum": "b18c72ed8041267e08298f3bfbed3956bdd3cc3c", + "mirrors": [ + { + "url": "https://repo.packagist.com/inpsyde/dists/%package%/%version%/r%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer/installers": "^1.0 || ^2.0" + }, + "type": "wordpress-plugin", + "notification-url": "https://repo.packagist.com/inpsyde/downloads/", + "authors": [ + { + "name": "WooCommerce", + "homepage": "https://woocommerce.com/" + } + ], + "description": "Sell products and services with recurring payments in your WooCommerce Store.", + "homepage": "https://www.woocommerce.com/products/woocommerce-subscriptions/" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/tests/qa/.env.example b/tests/qa/.env.example index 283d4e1cfa..f90513958f 100644 --- a/tests/qa/.env.example +++ b/tests/qa/.env.example @@ -1,31 +1,60 @@ # JDoe test single site, PHP x.x # playwright-utils config -WP_BASE_URL='https://test.com' # baseUrl without trailing slash -WP_USERNAME=*** -WP_PASSWORD=*** -WP_BASIC_AUTH_USER=*** -WP_BASIC_AUTH_PASS=*** +WP_BASE_URL='http://localhost:8889' # WP ENV URL -- You can replace this with any URL +WP_USERNAME=admin +WP_PASSWORD=password +WP_BASIC_AUTH_USER=admin +WP_BASIC_AUTH_PASS=password STORAGE_STATE_PATH='./storage-states' STORAGE_STATE_PATH_ADMIN='./storage-states/admin.json' +WORDPRESS_DB_USER=root +WORDPRESS_DB_PASSWORD=passsword # WooCommerce -WC_API_KEY=*** -WC_API_SECRET=*** -# WC_DEFAULT_COUNTRY=usa -# WC_DEFAULT_CURRENCY=usa +# If WC_API_KEY and WC_API_SECRET are empty and WooCommerce has not set any keys, they will be populated automatically. +WC_API_KEY= +WC_API_SECRET= +WC_DEFAULT_COUNTRY=usa +WC_DEFAULT_CURRENCY=USD # Xray in Jira XRAY_CLIENT_ID= XRAY_CLIENT_SECRET= # TEST_EXEC_KEY='' -# MERCHANT_USA_EMAIL= -# MERCHANT_USA_CLIENT_ID= -# MERCHANT_USA_CLIENT_SECRET= -# MERCHANT_USA_ACCOUNT_ID= +PAYPAL_PERSONAL_EMAIL_DE= +PAYPAL_PERSONAL_PASS_DE= -# PAYPAL_PERSONAL_EMAIL_US= -# PAYPAL_PERSONAL_PASS_US= +PAYPAL_PERSONAL_EMAIL_US= +PAYPAL_PERSONAL_PASS_US= + +PAYPAL_PERSONAL_EMAIL_MX= +PAYPAL_PERSONAL_PASS_MX= + +MERCHANT_USA_EMAIL= +MERCHANT_USA_CLIENT_ID= +MERCHANT_USA_CLIENT_SECRET= +MERCHANT_USA_ACCOUNT_ID= + +MERCHANT_DE_EMAIL= +MERCHANT_DE_CLIENT_ID= +MERCHANT_DE_CLIENT_SECRET= +MERCHANT_DE_ACCOUNT_ID= + +MERCHANT_MX_EMAIL= +MERCHANT_MX_CLIENT_ID= +MERCHANT_MX_CLIENT_SECRET= +MERCHANT_MX_ACCOUNT_ID= + +MERCHANT_INVALID_EMAIL= +MERCHANT_INVALID_CLIENT_ID= +MERCHANT_INVALID_CLIENT_SECRET= +MERCHANT_INVALID_ACCOUNT_ID= + +MERCHANT_USA_NOREF_EMAIL='' +MERCHANT_USA_NOREF_CLIENT_ID='' +MERCHANT_USA_NOREF_CLIENT_SECRET='' +MERCHANT_USA_NOREF_ACCOUNT_ID='' # FASTLANE_EMAIL_RYAN= diff --git a/tests/qa/.gitignore b/tests/qa/.gitignore index 3cd9c982b2..55cc63d1ef 100644 --- a/tests/qa/.gitignore +++ b/tests/qa/.gitignore @@ -7,9 +7,10 @@ playwright/.cache storage-states test-results package-lock.json - .env* !.env.example .DS_Store +/resources/files/woocommerce-subscriptions.zip + + -woocommerce-subscriptions.zip diff --git a/tests/qa/.wp-env.json b/tests/qa/.wp-env.json new file mode 100644 index 0000000000..e06c0643f6 --- /dev/null +++ b/tests/qa/.wp-env.json @@ -0,0 +1,14 @@ +{ + "phpVersion": "8.0", + "plugins": [ + "https://downloads.wordpress.org/plugin/wp-debugging.2.12.2.zip", + "./resources/e2e-snippets" + ], + "mappings": { + "wp-cli.yml": "./wp-cli.yml" + }, + "lifecycleScripts": { + "afterStart": "node bin/test-env-setup.js", + "afterClean": "node bin/test-env-clean.js" + } +} diff --git a/tests/qa/README.md b/tests/qa/README.md index ba1e6087d2..a9fec897a8 100644 --- a/tests/qa/README.md +++ b/tests/qa/README.md @@ -19,79 +19,39 @@ Detailed information about current test project can be found in [docs](./docs/RE ## Local installation -1. In VSCode open the terminal and clone PCP repository to your local PC: +1. Clone repository locally: ```bash git clone https://github.com/woocommerce/woocommerce-paypal-payments.git ``` -2. Change directory to newly cloned repo: - - ```bash - cd woocommerce-paypal-payments - ``` - -3. (Temporary, till autotests are not yet merged into main branch) Switch to `qa` branch: - - ```bash - git fetch origin - git checkout qa - ``` - -4. Change directory to `./tests/qa/`: - - ```bash - cd tests/qa - ``` - -## Installation of `node_modules` +## Installation of `wp env, PlayWright and PayPal plugin` > See also [@inpsyde/playwright-utils documentation](https://github.com/inpsyde/playwright-utils?tab=readme-ov-file#installation). 1. Make sure you're logged in the [Syde npm package registry](https://inpsyde.atlassian.net/wiki/spaces/AT/pages/3112894465/GitHub+Package+Registry+for+npm). -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: +2. In the terminal change directory to `./tests/qa` and run following command: ```bash - npm run setup:tests + npm run setup:all ``` -## Installation of `playwright-utils` for local development +This will run the next scripts: -> See also [@inpsyde/playwright-utils documentation](https://github.com/inpsyde/playwright-utils?tab=readme-ov-file#development). +- `setup:env` -- Setup `wp env` and required plugins for running tests in http://localhost:8889 +- `setup:plugin` -- Compile WooCommerce PayPal Payments plugin, generates a ZIP and moves it into resources/files to be used in tests +- `setup:tests` -- Setup required PlayWright libraries and utils -1. Add `"workspaces": [ "playwright-utils" ]` to `./tests/qa/package.json`. +## Project configuration (Devs) -2. Delete `@inpsyde/playwright-utils` from `./tests/qa/node_modules`. - -3. In the terminal change directory to `./tests/qa` and run following command: - - ```bash - git clone https://github.com/inpsyde/playwright-utils.git - ``` - - [`@inpsyde/playwright-utils`](https://github.com/inpsyde/playwright-utils) repository should be cloned as `playwright-utils` right inside the root directory of monorepo. - -4. Restart VSCode editor. This will create `playwright-utils` instance in the source control tab of VSCode editor. - -5. Run following command: - - ```bash - 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: - - ```bash - 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. +1. In the test project directory (`./tests/qa/`) create and configure `.env` file: +2. Set general variables following [these steps](https://github.com/inpsyde/playwright-utils?tab=readme-ov-file#env-variables). + +3. Set PayPal API keys and test credentials. See `.env.example`. The `.env` content with actual test users' credentials is [stored in 1Password](https://start.1password.com/open/i?a=UL7QZZ6P6JDVBI422AOVJXMEGU&v=uthlbcp4jkori6w6rhgxvsvfoe&i=klejf7rgcip76c7auhsnhvxcbi&h=inpsyde.1password.eu). -## Project configuration +## Project configuration (QA team) 1. [SSE setup](https://inpsyde.atlassian.net/wiki/spaces/AT/pages/3175907370/Self+Service+WordPress+Environment) - will be deprecated in Q1 of 2025. @@ -109,13 +69,11 @@ Detailed information about current test project can be found in [docs](./docs/RE 6. Additional website and WooCommerce configuration is done automatically via `setup-woocommerce` dependency project (see [`/tests/_setup/woocommerce.setup.ts`](./tests/_setup/woocommerce.setup.ts)). -## Run tests +## Running tests -To execute tests, in the terminal, navigate to the __qa__ directory of the project (e.g. `cd tests/qa`) and run following command: - -```bash -npx playwright test --project=all -``` +- `npm run tests:all` -- Runs all the tests +- `npm run tests:critical` -- Runs all the critical tests +- `npm run tests:onboarding` -- Runs all the onboarding tests ### Additional options to run tests from command line diff --git a/tests/qa/bin/test-env-clean.js b/tests/qa/bin/test-env-clean.js new file mode 100644 index 0000000000..0ddd50435f --- /dev/null +++ b/tests/qa/bin/test-env-clean.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node +const { execSync } = require('child_process'); + +const commands = [ + { + description: 'Activate storefront theme', + command: 'wp-env run tests-cli wp theme deactivate storefront' + }, + { + description: 'Uninstall WooCommerce Payments', + command: 'wp-env run tests-cli -- wp plugin delete woocommerce-payments' + }, + { + description: 'Uninstall WooCommerce', + command: 'wp-env run tests-cli -- wp plugin delete woocommerce' + }, +]; + +console.log('Cleaning test environment...\n'); + +commands.forEach((item, index) => { + try { + console.log(`${index + 1}. ${item.description}`); + execSync(item.command, { stdio: 'inherit' }); + console.log('โœ… Success\n'); + } catch (error) { + console.error(`โŒ Failed: ${item.description}`); + console.error(`Command: ${item.command}`); + console.error(`Error: ${error.message}\n`); + process.exit(1); + } +}); + +console.log('๐Ÿงน Test environment clean complete!'); diff --git a/tests/qa/bin/test-env-setup.js b/tests/qa/bin/test-env-setup.js new file mode 100644 index 0000000000..d26b28bc08 --- /dev/null +++ b/tests/qa/bin/test-env-setup.js @@ -0,0 +1,61 @@ +#!/usr/bin/env node +const { execSync } = require('child_process'); + +const commands = [ + { + description: 'Install storefront theme', + command: 'wp-env run tests-cli -- wp theme install storefront' + }, + { + description: 'Activate storefront theme', + command: 'wp-env run tests-cli -- wp theme activate storefront' + }, + { + description: 'Install WooCommerce', + command: 'wp-env run tests-cli -- wp plugin install woocommerce' + }, + { + description: 'Activate WooCommerce', + command: 'wp-env run tests-cli -- wp plugin activate woocommerce' + }, + { + description: 'Install WooCommerce Payments', + command: 'wp-env run tests-cli -- wp plugin install woocommerce-payments' + }, + { + description: 'Update URL structure', + command: 'wp-env run tests-cli -- wp rewrite structure "/%postname%/" --hard' + }, + { + description: 'Update Blog Name', + command: 'wp-env run tests-cli -- wp option update blogname "WooCommerce PayPal Payments E2E Test Suite"' + }, + { + description: 'Set the store as live', + command: 'wp-env run tests-cli -- wp option update woocommerce_coming_soon "no"' + }, + { + description: 'PayPal - Set new UI (merchant flag)', + command: 'wp-env run tests-cli -- wp option update woocommerce-ppcp-is-new-merchant "yes"' + }, + { + description: 'PayPal - Set new UI (disable old UI)', + command: 'wp-env run tests-cli -- wp option update woocommerce_ppcp-settings-should-use-old-ui "no"' + } +]; + +console.log('Starting test environment setup...\n'); + +commands.forEach((item, index) => { + try { + console.log(`${index + 1}. ${item.description}`); + execSync(item.command, { stdio: 'inherit' }); + console.log('โœ… Success\n'); + } catch (error) { + console.error(`โŒ Failed: ${item.description}`); + console.error(`Command: ${item.command}`); + console.error(`Error: ${error.message}\n`); + } +}); + +console.log('๐ŸŽ‰ Test environment setup complete!'); diff --git a/tests/qa/package.json b/tests/qa/package.json index 2b387df265..a76efa0339 100644 --- a/tests/qa/package.json +++ b/tests/qa/package.json @@ -1,62 +1,75 @@ { - "name": "woocommerce-paypal-payments-tests", - "version": "1.0.0", - "description": "WooCommerce Paypal Payments Playwright tests", - "main": "index.js", - "repository": "https://github.com/woocommerce/woocommerce-paypal-payments", - "author": { - "name": "Syde GmbH", - "email": "hello@syde.com", - "url": "https://syde.com/" - }, - "license": "GPL-3.0-or-later", - "bugs": { - "url": "https://github.com/woocommerce/woocommerce-paypal-payments/issues" - }, - "homepage": "https://github.com/woocommerce/woocommerce-paypal-payments#readme", - "dependencies": { - "@inpsyde/playwright-utils": "^2.7.3", - "dotenv": "^16.3.1", - "dotenv-cli": "^7.3.0", - "playwright": "^1.49.1", - "yarn": "^1.22.21" - }, - "devDependencies": { - "@percy/cli": "^1.30.6", - "@percy/playwright": "^1.0.4", - "@playwright/test": "^1.50.0", - "@types/node": "^20.8.4", - "@wordpress/scripts": "^25.0.0" - }, - "scripts": { - "setup:tests": "npm install && npx playwright install", - "setup:utils": "npm run setup:tests && cd ./playwright-utils && yarn devLocal", - "lint:md": "wp-scripts lint-md-docs ./**/*.md README.md", - "lint:md:fix": "wp-scripts lint-md-docs --fix ./**/*.md README.md", - "lint:js": "wp-scripts lint-js --resolve-plugins-relative-to ./ **/*.{ts,tsx,mjs}", - "lint:js:fix": "wp-scripts lint-js --resolve-plugins-relative-to ./ --fix **/*.{ts,tsx,mjs}", - "all": "npx playwright test --workers=1 --project \"all\"", - "setup:store:default": "npx playwright test woocommerce.setup", - "setup:checkout:block": "npx playwright test --grep=\"setup:checkout:block;\"", - "setup:checkout:classic": "npx playwright test --grep=\"setup:checkout:classic;\"", - "setup:tax:inc": "npx playwright test --grep=\"setup:tax:inc;\"", - "setup:tax:exc": "npx playwright test --grep=\"setup:tax:exc;\"", - "setup:pcp:usa": "npx playwright test --grep=\"setup:pcp:usa;\"", - "setup:pcp:germany": "npx playwright test --grep \"setup:pcp:germany;\"", - "setup:pcp:mexico": "npx playwright test --grep \"setup:pcp:mexico;\"", - "setup:pcp:usa:vaulting": "npx playwright test --grep \"setup:pcp:usa:vaulting;\"", - "setup:pcp:usa:vaulting:classic": "npx playwright test --grep \"setup:pcp:usa:vaulting:classic;\"", - "setup:pcp:usa:vaulting:subscription": "npx playwright test --grep \"setup:pcp:usa:vaulting:subscription;\"", - "setup:pcp:usa:paypal:subscription": "npx playwright test --grep \"setup:pcp:usa:paypal:subscription;\"" - }, - "eslintConfig": { - "extends": [ - "plugin:@wordpress/eslint-plugin/recommended" - ], - "rules": { - "@wordpress/dependency-group": "error", - "@wordpress/no-unsafe-wp-apis": "off", - "no-console": "off" + "name": "woocommerce-paypal-payments-tests", + "version": "1.0.0", + "description": "WooCommerce Paypal Payments Playwright tests", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/inpsyde/playwright-tests.git" + }, + "author": { + "name": "Syde GmbH", + "email": "hello@syde.com", + "url": "https://syde.com/" + }, + "license": "GPL-3.0-or-later", + "bugs": { + "url": "https://github.com/woocommerce/woocommerce-paypal-payments/issues" + }, + "homepage": "https://github.com/woocommerce/woocommerce-paypal-payments#readme", + "dependencies": { + "@inpsyde/playwright-tests": "git+https://github.com/inpsyde/playwright-tests.git#main", + "@inpsyde/playwright-utils": "^2.7.3", + "dotenv": "^16.3.1", + "dotenv-cli": "^7.3.0", + "playwright": "^1.49.1", + "yarn": "^1.22.21" + }, + "devDependencies": { + "@percy/cli": "^1.30.6", + "@percy/playwright": "^1.0.4", + "@playwright/test": "^1.50.0", + "@types/node": "^20.8.4", + "@wordpress/env": "^10.30.0", + "@wordpress/scripts": "^25.0.0" + }, + "scripts": { + "setup:all": "npm run setup:env && npm run setup:plugin && npm run setup:tests", + "setup:tests": "npm install && npx playwright install", + "setup:env": "npm install && npm run setup:wc-subscriptions && wp-env destroy && wp-env start --update", + "setup:wc-subscriptions": "cd ../inc/inpsyde && composer install && cd wp-content/plugins && zip -r ./woocommerce-subscriptions.zip ./woocommerce-subscriptions && cp woocommerce-subscriptions.zip ../../../../qa/resources/files", + "setup:reset": "wp-env stop && wp-env destroy", + "setup:plugin": "cd ../.. && npm run build && mv woocommerce-paypal-payments.zip tests/qa/resources/files", + "setup:utils": "npm run setup:tests && cd ./playwright-utils && yarn devLocal", + "wp-env": "wp-env", + "lint:md": "wp-scripts lint-md-docs ./**/*.md README.md", + "lint:md:fix": "wp-scripts lint-md-docs --fix ./**/*.md README.md", + "lint:js": "wp-scripts lint-js --resolve-plugins-relative-to ./ **/*.{ts,tsx,mjs}", + "lint:js:fix": "wp-scripts lint-js --resolve-plugins-relative-to ./ --fix **/*.{ts,tsx,mjs}", + "tests:all": "npx playwright test --workers=1 --project \"all\"", + "tests:onboarding": "npx playwright test 02-onboarding/", + "tests:critical": "npx playwright test --grep=\"@Critical\"", + "setup:store:default": "npx playwright test woocommerce.setup", + "setup:checkout:block": "npx playwright test --grep=\"setup:checkout:block;\"", + "setup:checkout:classic": "npx playwright test --grep=\"setup:checkout:classic;\"", + "setup:tax:inc": "npx playwright test --grep=\"setup:tax:inc;\"", + "setup:tax:exc": "npx playwright test --grep=\"setup:tax:exc;\"", + "setup:pcp:usa": "npx playwright test --grep=\"setup:pcp:usa;\"", + "setup:pcp:germany": "npx playwright test --grep \"setup:pcp:germany;\"", + "setup:pcp:mexico": "npx playwright test --grep \"setup:pcp:mexico;\"", + "setup:pcp:usa:vaulting": "npx playwright test --grep \"setup:pcp:usa:vaulting;\"", + "setup:pcp:usa:vaulting:classic": "npx playwright test --grep \"setup:pcp:usa:vaulting:classic;\"", + "setup:pcp:usa:vaulting:subscription": "npx playwright test --grep \"setup:pcp:usa:vaulting:subscription;\"", + "setup:pcp:usa:paypal:subscription": "npx playwright test --grep \"setup:pcp:usa:paypal:subscription;\"" + }, + "eslintConfig": { + "extends": [ + "plugin:@wordpress/eslint-plugin/recommended" + ], + "rules": { + "@wordpress/dependency-group": "error", + "@wordpress/no-unsafe-wp-apis": "off", + "no-console": "off" + } } - } } diff --git a/tests/qa/resources/e2e-snippets/e2e-snippets.php b/tests/qa/resources/e2e-snippets/e2e-snippets.php new file mode 100644 index 0000000000..ca081ea351 --- /dev/null +++ b/tests/qa/resources/e2e-snippets/e2e-snippets.php @@ -0,0 +1,42 @@ +