Update CI to use wp-env for api, e2e and performance tests (#34311)

* Renamed e2e to e2e-legacy

* Moved e2e folder to tests/e2e

* Updated gitignore

* Updted init script to work with wp-env

* Updated readme

* Updated commands to match new test structure

* Updated workflow to work with new test structure

* Added changelog

* turned off alternate wp cron in test

* Fixed path to playwright config

* Renamed e2e to e2e-pw

* Renamed e2e-legacy to e2e

* Updated e2e-pw path

* Fixed workflow

* Fixed csv test

* Updated .gitignore

* Removed puppeteer specific step
This commit is contained in:
Jamel Noel Reid 2022-08-15 13:47:53 -05:00 committed by GitHub
parent 7021d442bd
commit 40dbc1f924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 318 additions and 174 deletions

View File

@ -7,9 +7,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
E2E_PLAYWRIGHT: true
jobs:
e2e-tests-run:
name: Runs E2E tests.
@ -31,50 +28,24 @@ jobs:
- name: Load docker images and start containers.
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
- name: Run Puppeteer E2E tests.
if: fromJSON(env.E2E_PLAYWRIGHT) != true
id: run-puppeteer-e2e-tests
working-directory: plugins/woocommerce
env:
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
run: pnpm exec wc-e2e test:e2e
- name: Archive Puppeteer E2E test results
if: |
always() &&
fromJSON(env.E2E_PLAYWRIGHT) != true &&
(
steps.run-puppeteer-e2e-tests.conclusion != 'cancelled' ||
steps.run-puppeteer-e2e-tests.conclusion != 'skipped'
)
uses: actions/upload-artifact@v3
with:
name: pptr-e2e-test-results
path: plugins/woocommerce/tests/e2e/test-results.json
if-no-files-found: ignore
retention-days: 5
run: pnpm env:test --filter=woocommerce
- name: Download and install Chromium browser.
if: fromJSON(env.E2E_PLAYWRIGHT)
working-directory: plugins/woocommerce
run: pnpx playwright install chromium
- name: Run Playwright E2E tests.
timeout-minutes: 60
id: run_playwright_e2e_tests
if: fromJSON(env.E2E_PLAYWRIGHT)
env:
USE_WP_ENV: 1
working-directory: plugins/woocommerce
run: pnpx playwright test --config=e2e/playwright.config.js
run: pnpx playwright test --config=tests/e2e-pw/playwright.config.js
- name: Generate Playwright E2E Test report.
id: generate_e2e_report
if: |
always() &&
fromJSON(env.E2E_PLAYWRIGHT) &&
(
steps.run_playwright_e2e_tests.conclusion != 'cancelled' ||
steps.run_playwright_e2e_tests.conclusion != 'skipped'
@ -85,7 +56,6 @@ jobs:
- name: Archive Playwright E2E test report
if: |
always() &&
fromJSON(env.E2E_PLAYWRIGHT) &&
steps.generate_e2e_report.conclusion == 'success'
uses: actions/upload-artifact@v3
with:
@ -96,19 +66,6 @@ jobs:
if-no-files-found: ignore
retention-days: 5
- name: Archive Puppeteer E2E test screenshots
uses: actions/upload-artifact@v3
if: |
always() &&
(
fromJSON(env.E2E_PLAYWRIGHT) != true
)
with:
name: E2E Screenshots
path: plugins/woocommerce/tests/e2e/screenshots
if-no-files-found: ignore
retention-days: 5
api-tests-run:
name: Runs API tests.
runs-on: ubuntu-20.04
@ -131,7 +88,7 @@ jobs:
- name: Load docker images and start containers.
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
run: pnpm env:test --filter=woocommerce
- name: Run tests command.
working-directory: plugins/woocommerce
@ -169,14 +126,11 @@ jobs:
- name: Install and Build
uses: ./.github/actions/install-build
- name: Workaround to use initialization file with prepopulated data.
working-directory: plugins/woocommerce/tests/e2e/docker
run: |
cp init-sample-products.sh initialize.sh
- name: Load docker images and start containers.
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
run: |
pnpm env:dev --filter=woocommerce
pnpm env:performance-init --filter=woocommerce
- name: Install k6
run: |
@ -217,19 +171,11 @@ jobs:
path: artifacts/api
- name: Download Playwright E2E test report artifact
if: fromJSON(env.E2E_PLAYWRIGHT)
uses: actions/download-artifact@v3
with:
name: e2e-test-report---pr-${{ github.event.number }}
path: artifacts/e2e
- name: Download Puppeteer E2E test report artifact
if: fromJSON(env.E2E_PLAYWRIGHT) != true
uses: actions/download-artifact@v3
with:
name: pptr-e2e-test-results
path: artifacts/e2e
- name: Prepare test summary
id: prepare-test-summary
uses: actions/github-script@v6
@ -278,22 +224,7 @@ jobs:
RUN_ID: ${{ github.run_id }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
steps:
- name: Publish API test report
if: fromJSON(env.E2E_PLAYWRIGHT) != true
env:
ARTIFACT_NAME: api-test-report---pr-${{ github.event.number }}
run: |
gh workflow run publish-report.yml \
-f test_workflow=pr \
-f test_type=api \
-f run_id=$RUN_ID \
-f artifact_name=$ARTIFACT_NAME \
-f pr_number=$PR_NUMBER \
-f commit_sha=$COMMIT_SHA \
--repo woocommerce/woocommerce-test-reports
- name: Publish test reports
if: fromJSON(env.E2E_PLAYWRIGHT)
env:
API_ARTIFACT: api-test-report---pr-${{ github.event.number }}
E2E_ARTIFACT: e2e-test-report---pr-${{ github.event.number }}

8
.gitignore vendored
View File

@ -89,10 +89,10 @@ allure-results
changes.json
# Playwright output & working files
/plugins/woocommerce/e2e/output
/plugins/woocommerce/e2e/report
/plugins/woocommerce/e2e/storage
/plugins/woocommerce/e2e/test-results.json
/plugins/woocommerce/tests/e2e-pw/output
/plugins/woocommerce/tests/e2e-pw/report
/plugins/woocommerce/tests/e2e-pw/storage
/plugins/woocommerce/tests/e2e-pw/test-results.json
# Turborepo
.turbo

View File

@ -28,13 +28,13 @@ module.exports = {
},
overrides: [
{
files: ["e2e/tests/**/*.spec.js", "e2e/*.js"],
files: ["tests/e2e-pw/**/*.spec.js", "tests/e2e/**/*.spec.js"],
rules: {
"jest/no-test-callback": "off",
"@wordpress/no-unsafe-wp-apis": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off"
}
}
},
]
};

View File

@ -18,8 +18,6 @@ tests/cli/vendor
/tests/bin/tmp
/tests/e2e/config/local-*.json
/tests/e2e/config/local.json
/tests/e2e/config/default.json
/tests/e2e/docker
/tests/e2e/screenshots
/tests/e2e/plugins
.phpunit.result.cache

View File

@ -11,7 +11,10 @@
"env": {
"development": {},
"tests": {
"port": 8086
"port": 8086,
"config": {
"ALTERNATE_WP_CRON": false
}
}
}
}

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Updating e2e, api and performance tests against a wp-env environment

View File

@ -33,8 +33,8 @@
"docker:ssh": "pnpm exec wc-e2e docker:ssh",
"docker:up": "pnpm exec wc-e2e docker:up",
"env:dev": "pnpm wp-env start",
"env:init-test": "./e2e/bin/env-setup.sh",
"env:test": "pnpm run env:dev && ./e2e/bin/test-env-setup.sh",
"env:test": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh",
"env:performance-init": "./tests/performance/bin/init-sample-products.sh",
"env:down": "pnpm wp-env stop",
"env:destroy": "pnpm wp-env destroy",
"test:api": "API_TEST_REPORT_DIR=\"$PWD/tests/api\" pnpm exec wc-api-tests test api",

View File

@ -44,9 +44,9 @@ To run the test again, re-create the environment to start with a fresh state:
Other ways of running tests:
- `pnpm env:test --filter=woocommerce` (headless)
- `cd plugin/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js --headed` (headed)
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js --debug` (debug)
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js ./e2e/tests/activate-and-setup/basic-setup.spec.js` (running a single test)
- `cd plugin/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js --headed` (headed)
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js --debug` (debug)
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js ./tests/e2e-pw/tests/activate-and-setup/basic-setup.spec.js` (running a single test)
To see all options, run `cd plugins/woocommerce && pnpm playwright test --help`
@ -85,11 +85,11 @@ The test environment uses the following test variables:
}
```
If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file.
If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file.
**Modiify the port wp-env**
Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/e2e/playwright.config.js).
Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js).
**Modiify port for e2e-environment**

View File

@ -0,0 +1,65 @@
{
"cookies": [
{
"sameSite": "Lax",
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6",
"domain": "localhost",
"path": "/wp-content/plugins",
"expires": -1,
"httpOnly": true,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6",
"domain": "localhost",
"path": "/wp-admin",
"expires": -1,
"httpOnly": true,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_test_cookie",
"value": "WP%20Cookie%20check",
"domain": "localhost",
"path": "/",
"expires": -1,
"httpOnly": false,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97",
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C6de27e0d8393de7715c07e144424d90733d53e65b8665c8a7db1ad94798c369c",
"domain": "localhost",
"path": "/",
"expires": -1,
"httpOnly": true,
"secure": false
},
{
"sameSite": "Lax",
"name": "tk_ai",
"value": "woo%3AT9QFbJmpuSGWcjApaONaBtSB",
"domain": "localhost",
"path": "/",
"expires": -1,
"httpOnly": false,
"secure": false
},
{
"sameSite": "Lax",
"name": "wp-settings-time-1",
"value": "1660233126",
"domain": "localhost",
"path": "/",
"expires": 1691769126.937059,
"httpOnly": false,
"secure": false
}
],
"origins": []
}

View File

@ -0,0 +1,45 @@
{
"cookies": [
{
"sameSite": "Lax",
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84",
"domain": "localhost",
"path": "/wp-content/plugins",
"expires": -1,
"httpOnly": true,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84",
"domain": "localhost",
"path": "/wp-admin",
"expires": -1,
"httpOnly": true,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_test_cookie",
"value": "WP%20Cookie%20check",
"domain": "localhost",
"path": "/",
"expires": -1,
"httpOnly": false,
"secure": false
},
{
"sameSite": "Lax",
"name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97",
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7C869a28fa8ef17799b6d097d84c8155c7d0dd18cd9967f7a18e3f49f41dd71226",
"domain": "localhost",
"path": "/",
"expires": -1,
"httpOnly": true,
"secure": false
}
],
"origins": []
}

View File

@ -1,9 +1,9 @@
const { test, expect } = require( '@playwright/test' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;
const path = require( 'path' );
const filePath = path.resolve( 'e2e/test-data/sample_products.csv' );
const filePath = path.resolve( 'tests/e2e-pw/test-data/sample_products.csv' );
const filePathOverride = path.resolve(
'e2e/test-data/sample_products_override.csv'
'tests/e2e-pw/test-data/sample_products_override.csv'
);
const productIds = [];

View File

@ -1,6 +1,7 @@
const path = require( 'path' );
const { useE2EJestConfig, getAppRoot } = require( '@woocommerce/e2e-environment' );
const { useE2EJestConfig } = require( '@woocommerce/e2e-environment' );
// eslint-disable-next-line
const jestConfig = useE2EJestConfig( {
roots: [ path.resolve( __dirname, '../specs' ) ],
} );

View File

@ -1,47 +1,58 @@
/* global page */
/**
* External dependencies
*/
import {
clearLocalStorage,
setBrowserViewport,
withRestApi,
WP_ADMIN_LOGIN
WP_ADMIN_LOGIN,
} from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
const config = require( 'config' );
const { HTTPClientFactory } = require( '@woocommerce/api' );
const { addConsoleSuppression, updateReadyPageStatus, setupJestRetries } = require( '@woocommerce/e2e-environment' );
const {
addConsoleSuppression,
updateReadyPageStatus,
setupJestRetries,
} = require( '@woocommerce/e2e-environment' );
const { DEFAULT_TIMEOUT_OVERRIDE } = process.env;
// @todo: remove this once https://github.com/woocommerce/woocommerce-admin/issues/6992 has been addressed
addConsoleSuppression('woocommerce_shared_settings', false);
addConsoleSuppression( 'woocommerce_shared_settings', false );
// @todo: remove this once https://github.com/woocommerce/woocommerce/issues/31867 has been addressed
addConsoleSuppression('wp.compose.withState', false);
addConsoleSuppression( 'wp.compose.withState', false );
/**
* Uses the WordPress API to delete all existing posts
*/
async function trashExistingPosts() {
const apiUrl = config.get('url');
const apiUrl = config.get( 'url' );
const wpPostsEndpoint = '/wp/v2/posts';
const adminUsername = config.get('users.admin.username');
const adminPassword = config.get('users.admin.password');
const client = HTTPClientFactory.build(apiUrl)
.withBasicAuth(adminUsername, adminPassword)
const adminUsername = config.get( 'users.admin.username' );
const adminPassword = config.get( 'users.admin.password' );
const client = HTTPClientFactory.build( apiUrl )
.withBasicAuth( adminUsername, adminPassword )
.create();
// List all existing posts
const response = await client.get(wpPostsEndpoint);
const response = await client.get( wpPostsEndpoint );
const posts = response.data;
// Delete each post
for (const post of posts) {
await client.delete(`${wpPostsEndpoint}/${post.id}`);
for ( const post of posts ) {
await client.delete( `${ wpPostsEndpoint }/${ post.id }` );
}
}
// Before every test suite run, delete all content created by the test. This ensures
// other posts/comments/etc. aren't dirtying tests and tests don't depend on
// each other's side-effects.
beforeAll(async () => {
beforeAll( async () => {
setupJestRetries( 2 );
if ( DEFAULT_TIMEOUT_OVERRIDE ) {
@ -51,7 +62,7 @@ beforeAll(async () => {
try {
// Update the ready page to prevent concurrent test runs
await updateReadyPageStatus('draft');
await updateReadyPageStatus( 'draft' );
await trashExistingPosts();
await withRestApi.deleteAllProducts();
await withRestApi.deleteAllCoupons();
@ -60,25 +71,25 @@ beforeAll(async () => {
// Prevent an error here causing tests to fail.
}
await page.goto(WP_ADMIN_LOGIN);
await page.goto( WP_ADMIN_LOGIN );
await clearLocalStorage();
await setBrowserViewport( {
width: 1280,
height: 800,
});
});
} );
} );
// Clear browser cookies and cache using DevTools.
// This is to ensure that each test ends with no user logged in.
afterAll(async () => {
afterAll( async () => {
// Reset the ready page to published to allow future test runs
try {
await updateReadyPageStatus('publish');
await updateReadyPageStatus( 'publish' );
} catch ( error ) {
// Prevent an error here causing tests to fail.
}
const client = await page.target().createCDPSession();
await client.send('Network.clearBrowserCookies');
await client.send('Network.clearBrowserCache');
});
await client.send( 'Network.clearBrowserCookies' );
await client.send( 'Network.clearBrowserCache' );
} );

View File

@ -1,7 +1,11 @@
/*
* Internal dependencies
*/
const { runActivationTest, runInitialStoreSettingsTest, runSetupOnboardingTests } = require( '@woocommerce/e2e-core-tests' );
const {
runActivationTest,
runInitialStoreSettingsTest,
runSetupOnboardingTests,
} = require( '@woocommerce/e2e-core-tests' );
runActivationTest();
runInitialStoreSettingsTest();

View File

@ -1,3 +1,5 @@
const { testAdminAnalyticsOverview } = require( '@woocommerce/admin-e2e-tests' );
const {
testAdminAnalyticsOverview,
} = require( '@woocommerce/admin-e2e-tests' );
testAdminAnalyticsOverview();

View File

@ -1,3 +1,5 @@
const { testAdminHomescreenActivityPanel } = require( '@woocommerce/admin-e2e-tests' );
const {
testAdminHomescreenActivityPanel,
} = require( '@woocommerce/admin-e2e-tests' );
testAdminHomescreenActivityPanel();

View File

@ -1,3 +1,5 @@
const { testAdminHomescreenTasklist } = require( '@woocommerce/admin-e2e-tests' );
const {
testAdminHomescreenTasklist,
} = require( '@woocommerce/admin-e2e-tests' );
testAdminHomescreenTasklist();

View File

@ -1,3 +1,5 @@
const { testAdminPurchaseSetupTask } = require( '@woocommerce/admin-e2e-tests' );
const {
testAdminPurchaseSetupTask,
} = require( '@woocommerce/admin-e2e-tests' );
testAdminPurchaseSetupTask();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runCartCalculateShippingTest } = require( '@woocommerce/e2e-core-tests' );
const {
runCartCalculateShippingTest,
} = require( '@woocommerce/e2e-core-tests' );
runCartCalculateShippingTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runCheckoutApplyCouponsTest } = require( '@woocommerce/e2e-core-tests' );
const {
runCheckoutApplyCouponsTest,
} = require( '@woocommerce/e2e-core-tests' );
runCheckoutApplyCouponsTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runCheckoutCreateAccountTest } = require( '@woocommerce/e2e-core-tests' );
const {
runCheckoutCreateAccountTest,
} = require( '@woocommerce/e2e-core-tests' );
runCheckoutCreateAccountTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runCheckoutLoginAccountTest } = require( '@woocommerce/e2e-core-tests' );
const {
runCheckoutLoginAccountTest,
} = require( '@woocommerce/e2e-core-tests' );
runCheckoutLoginAccountTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runMyAccountCreateAccountTest } = require( '@woocommerce/e2e-core-tests' );
const {
runMyAccountCreateAccountTest,
} = require( '@woocommerce/e2e-core-tests' );
runMyAccountCreateAccountTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runProductBrowseSearchSortTest } = require( '@woocommerce/e2e-core-tests' );
const {
runProductBrowseSearchSortTest,
} = require( '@woocommerce/e2e-core-tests' );
runProductBrowseSearchSortTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runVariableProductUpdateTest } = require( '@woocommerce/e2e-core-tests' );
const {
runVariableProductUpdateTest,
} = require( '@woocommerce/e2e-core-tests' );
runVariableProductUpdateTest();

View File

@ -3,15 +3,16 @@
*/
const { merchant, utils } = require( '@woocommerce/e2e-utils' );
const { getRemotePluginZip, getLatestReleaseZipUrl, deleteDownloadedPluginFiles } = require( '@woocommerce/e2e-environment' );
const {
getRemotePluginZip,
getLatestReleaseZipUrl,
deleteDownloadedPluginFiles,
} = require( '@woocommerce/e2e-environment' );
/**
* External dependencies
*/
const {
it,
beforeAll,
} = require( '@jest/globals' );
const { it, beforeAll } = require( '@jest/globals' );
const { UPDATE_WC, TEST_RELEASE } = process.env;
@ -20,35 +21,39 @@ const pluginName = 'WooCommerce';
let pluginPath;
utils.describeIf( UPDATE_WC )( 'WooCommerce plugin can be uploaded and activated', () => {
beforeAll( async () => {
utils.describeIf( UPDATE_WC )(
'WooCommerce plugin can be uploaded and activated',
() => {
beforeAll( async () => {
if ( TEST_RELEASE ) {
zipUrl = await getLatestReleaseZipUrl(
'woocommerce/woocommerce'
);
} else {
zipUrl =
'https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip';
}
if ( TEST_RELEASE ) {
zipUrl = await getLatestReleaseZipUrl( 'woocommerce/woocommerce' );
} else {
zipUrl = 'https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip';
}
pluginPath = await getRemotePluginZip( zipUrl );
await merchant.login();
} );
pluginPath = await getRemotePluginZip( zipUrl );
await merchant.login();
});
afterAll( async () => {
await merchant.logout();
await deleteDownloadedPluginFiles();
} );
afterAll( async () => {
await merchant.logout();
await deleteDownloadedPluginFiles();
});
it( 'can upload and activate the WooCommerce plugin', async () => {
await merchant.uploadAndActivatePlugin( pluginPath, pluginName );
} );
it( 'can upload and activate the WooCommerce plugin', async () => {
await merchant.uploadAndActivatePlugin( pluginPath, pluginName );
});
it( 'can run the database update', async () => {
// Check for, and run, the database upgrade if needed
await merchant.runDatabaseUpdate();
} );
it( 'can run the database update', async () => {
// Check for, and run, the database upgrade if needed
await merchant.runDatabaseUpdate();
});
it( 'can remove downloaded plugin zip', async () => {
await deleteDownloadedPluginFiles();
} );
});
it( 'can remove downloaded plugin zip', async () => {
await deleteDownloadedPluginFiles();
} );
}
);

View File

@ -3,17 +3,19 @@
*/
const { merchant, utils } = require( '@woocommerce/e2e-utils' );
const { getRemotePluginZip, getLatestReleaseZipUrl, deleteDownloadedPluginFiles } = require( '@woocommerce/e2e-environment' );
const {
getRemotePluginZip,
getLatestReleaseZipUrl,
deleteDownloadedPluginFiles,
} = require( '@woocommerce/e2e-environment' );
/**
* External dependencies
*/
const {
it,
beforeAll,
} = require( '@jest/globals' );
const { it, beforeAll } = require( '@jest/globals' );
const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN, PLUGIN_REPOSITORY } = process.env;
const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN, PLUGIN_REPOSITORY } =
process.env;
// allows us to upload plugins from different repositories.
const pluginName = PLUGIN_NAME ? PLUGIN_NAME : 'WooCommerce';
@ -37,10 +39,12 @@ utils.describeIf( repository )(
await merchant.logout();
} );
/* eslint-disable jest/expect-expect */
it( 'can upload and activate the provided plugin', async () => {
await merchant.uploadAndActivatePlugin( pluginPath, PLUGIN_NAME );
} );
/* eslint-disable jest/expect-expect */
it( 'can remove downloaded plugin zip', async () => {
await deleteDownloadedPluginFiles();
} );

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runMerchantOrdersCustomerPaymentPage } = require( '@woocommerce/e2e-core-tests' );
const {
runMerchantOrdersCustomerPaymentPage,
} = require( '@woocommerce/e2e-core-tests' );
runMerchantOrdersCustomerPaymentPage();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runUpdateGeneralSettingsTest } = require( '@woocommerce/e2e-core-tests' );
const {
runUpdateGeneralSettingsTest,
} = require( '@woocommerce/e2e-core-tests' );
runUpdateGeneralSettingsTest();

View File

@ -1,6 +1,8 @@
/*
* Internal dependencies
*/
const { runInitiateWccomConnectionTest } = require( '@woocommerce/e2e-core-tests' );
const {
runInitiateWccomConnectionTest,
} = require( '@woocommerce/e2e-core-tests' );
runInitiateWccomConnectionTest();

View File

@ -54,9 +54,12 @@ Alternatively the k6 docker image can be used to execute tests.
Before using the tests a test environment is needed to run against.
In the WooCommerce e2e tests there is a Docker Initialization Script [`init-sample-products.sh`](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e/docker/init-sample-products.sh) that will set up a shop with sample products imported and the shop settings (payment method, permalinks, address etc) needed for the tests already set. It is recommended using this to just see the tests in action.
We first spin up an environment using `wp-env` and configure that environment with the necessary plugins and data using the Initialization Script [`init-sample-products.sh`](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/performance/bin/init-sample-products.sh) that will set up a shop with sample products imported and the shop settings (payment method, permalinks, address etc) needed for the tests already set. It is recommended using this to just see the tests in action.
`npx wc-e2e docker:up ./tests/e2e/docker/init-sample-products.sh`
```sh
pnpm run env:dev --filter=woocommerce
pnpm run env:performance-init --filter=woocommerce
```
If using a different environment the details can be changed in `config.js`.

View File

@ -0,0 +1,42 @@
#!/bin/bash
echo "Initializing WooCommerce E2E"
wp-env run tests-cli "wp plugin activate woocommerce"
wp-env run tests-cli "wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=subscriber --path=/var/www/html"
# we cannot create API keys for the API, so we using basic auth, this plugin allows that.
wp-env run tests-cli "wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate"
# update permalinks to `pretty` to make it easier for testing APIs with k6
wp-env run tests-cli "wp option update permalink_structure /%postname%/"
# install the WP Mail Logging plugin to test emails
wp-env run tests-cli "wp plugin install wp-mail-logging --activate"
# Installing and activating the WordPress Importer plugin to import sample products"
wp-env run tests-cli "wp plugin install wordpress-importer --activate"
# Adding basic WooCommerce settings"
wp-env run tests-cli "wp option set woocommerce_store_address 'Example Address Line 1'"
wp-env run tests-cli "wp option set woocommerce_store_address_2 'Example Address Line 2'"
wp-env run tests-cli "wp option set woocommerce_store_city 'Example City'"
wp-env run tests-cli "wp option set woocommerce_default_country 'US:CA'"
wp-env run tests-cli "wp option set woocommerce_store_postcode '94110'"
wp-env run tests-cli "wp option set woocommerce_currency 'USD'"
wp-env run tests-cli "wp option set woocommerce_product_type 'both'"
wp-env run tests-cli "wp option set woocommerce_allow_tracking 'no'"
wp-env run tests-cli "wp option set woocommerce_enable_checkout_login_reminder 'yes'"
wp-env run tests-cli "wp option set --format=json woocommerce_cod_settings '{\"enabled\":\"yes\"}'"
# WooCommerce shop pages
wp-env run tests-cli "wp wc --user=admin tool run install_pages"
# Importing WooCommerce sample products"
wp-env run tests-cli "wp import wp-content/plugins/woocommerce/sample-data/sample_products.xml --authors=skip"
# install Storefront
wp-env run tests-cli "wp theme install storefront --activate"
echo "Success! Your E2E Test Environment is now ready."