Merge branch 'master' into fix/25664-2
This commit is contained in:
commit
27b5210fdf
|
@ -63,6 +63,7 @@ before_script:
|
|||
else
|
||||
echo "xdebug.ini does not exist"
|
||||
fi
|
||||
- nvm install 10
|
||||
- npm install
|
||||
- composer install --no-dev
|
||||
- |
|
||||
|
|
|
@ -121,7 +121,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
|||
array(
|
||||
'title' => __( 'Personal data removal', 'woocommerce' ),
|
||||
'desc' => __( 'Allow personal data to be removed in bulk from orders', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Adds an option to the orders screen for removing personal in bulk. Note that removing personal data cannot be undone.', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Adds an option to the orders screen for removing personal data in bulk. Note that removing personal data cannot be undone.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_allow_bulk_remove_personal_data',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
|
|
|
@ -305,7 +305,9 @@ class WC_Structured_Data {
|
|||
'@type' => 'Review',
|
||||
'reviewRating' => array(
|
||||
'@type' => 'Rating',
|
||||
'bestRating' => '5',
|
||||
'ratingValue' => get_comment_meta( $comment->comment_ID, 'rating', true ),
|
||||
'worstRating' => '1',
|
||||
),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
|
@ -350,7 +352,9 @@ class WC_Structured_Data {
|
|||
if ( $rating ) {
|
||||
$markup['reviewRating'] = array(
|
||||
'@type' => 'Rating',
|
||||
'bestRating' => '5',
|
||||
'ratingValue' => $rating,
|
||||
'worstRating' => '1',
|
||||
);
|
||||
} elseif ( $comment->comment_parent ) {
|
||||
return;
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
* @since 3.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -299,11 +297,11 @@ final class WooCommerce {
|
|||
case 'admin':
|
||||
return is_admin();
|
||||
case 'ajax':
|
||||
return Constants::is_defined( 'DOING_AJAX' );
|
||||
return defined( 'DOING_AJAX' );
|
||||
case 'cron':
|
||||
return Constants::is_defined( 'DOING_CRON' );
|
||||
return defined( 'DOING_CRON' );
|
||||
case 'frontend':
|
||||
return ( ! is_admin() || Constants::is_defined( 'DOING_AJAX' ) ) && ! Constants::is_defined( 'DOING_CRON' ) && ! $this->is_rest_api_request();
|
||||
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! $this->is_rest_api_request();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +450,7 @@ final class WooCommerce {
|
|||
*/
|
||||
include_once WC_ABSPATH . 'packages/action-scheduler/action-scheduler.php';
|
||||
|
||||
if ( Constants::is_true( 'WP_CLI' ) ) {
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
include_once WC_ABSPATH . 'includes/class-wc-cli.php';
|
||||
}
|
||||
|
||||
|
|
|
@ -2063,6 +2063,7 @@ function wc_update_390_move_maxmind_database() {
|
|||
$uploads_dir = wp_upload_dir();
|
||||
$new_path = trailingslashit( $uploads_dir['basedir'] ) . 'woocommerce_uploads/' . $prefix . '-GeoLite2-Country.mmdb';
|
||||
$new_path = apply_filters( 'woocommerce_geolocation_local_database_path', $new_path, 2 );
|
||||
$new_path = apply_filters( 'woocommerce_maxmind_geolocation_database_path', $new_path );
|
||||
|
||||
@rename( $old_path, $new_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -61,6 +61,7 @@
|
|||
"node-sass": "4.13.0",
|
||||
"prettier": "github:automattic/calypso-prettier#c56b4251",
|
||||
"puppeteer": "2.0.0",
|
||||
"puppeteer-utils": "github:Automattic/puppeteer-utils#0f3ec50",
|
||||
"stylelint": "12.0.1",
|
||||
"stylelint-config-wordpress": "16.0.0",
|
||||
"wp-textdomain": "^1.0.1"
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
# WooCommerce Unit Tests
|
||||
# WooCommerce Tests
|
||||
|
||||
## Initial Setup
|
||||
## Table of contents
|
||||
|
||||
- [WooCommerce Unit Tests](#woocommerce-unit-tests)
|
||||
- [Initial Setup](#initial-setup)
|
||||
- [Running Tests](#running-tests)
|
||||
- [Writing Tests](#writing-tests)
|
||||
- [Automated Tests](#automated-tests)
|
||||
- [Code Coverage](#code-coverage)
|
||||
- [WooCommerce E2E Tests](#woocommerce-e2e-tests)
|
||||
|
||||
## WooCommerce Unit Tests
|
||||
|
||||
### Initial Setup
|
||||
|
||||
From the WooCommerce root directory (if you are using VVV you might need to `vagrant ssh` first), run the following:
|
||||
|
||||
|
@ -24,7 +36,7 @@ Example:
|
|||
|
||||
**Important**: The `<db-name>` database will be created if it doesn't exist and all data will be removed during testing.
|
||||
|
||||
## Running Tests
|
||||
### Running Tests
|
||||
|
||||
Change to the plugin root directory and type:
|
||||
|
||||
|
@ -40,7 +52,7 @@ A text code coverage summary can be displayed using the `--coverage-text` option
|
|||
|
||||
$ vendor/bin/phpunit --coverage-text
|
||||
|
||||
## Writing Tests
|
||||
### Writing Tests
|
||||
|
||||
* Each test file should roughly correspond to an associated source file, e.g. the `formatting/functions.php` test file covers code in the `wc-formatting-functions.php` file
|
||||
* Each test method should cover a single method or function with one or more assertions
|
||||
|
@ -53,10 +65,14 @@ A text code coverage summary can be displayed using the `--coverage-text` option
|
|||
* Filters persist between test cases so be sure to remove them in your test method or in the `tearDown()` method.
|
||||
* Use data providers where possible. Be sure that their name is like `data_provider_function_to_test` (i.e. the data provider for `test_is_postcode` would be `data_provider_test_is_postcode`). Read more about data providers [here](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers).
|
||||
|
||||
## Automated Tests
|
||||
### Automated Tests
|
||||
|
||||
Tests are automatically run with [Travis-CI](https://travis-ci.org/woocommerce/woocommerce) for each commit and pull request.
|
||||
|
||||
## Code Coverage
|
||||
### Code Coverage
|
||||
|
||||
Code coverage is available on [Scrutinizer](https://scrutinizer-ci.com/g/woocommerce/woocommerce/) and [Codecov](https://codecov.io/gh/woocommerce/woocommerce/) which receives updated data after each Travis build.
|
||||
Code coverage is available on [Codecov](https://codecov.io/gh/woocommerce/woocommerce/) which receives updated data after each Travis build.
|
||||
|
||||
## WooCommerce E2E Tests
|
||||
|
||||
See [e2e-tests README](https://github.com/woocommerce/woocommerce/tree/master/tests/e2e-tests) to learn how to setup testing environment for running e2e tests and run them.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
const { spawnSync } = require( 'child_process' );
|
||||
const program = require( 'commander' );
|
||||
const { useJestPuppeteerConfig } = require( 'puppeteer-utils' );
|
||||
|
||||
program
|
||||
.usage( '<file ...> [options]' )
|
||||
|
@ -15,7 +16,11 @@ const testEnvVars = {
|
|||
};
|
||||
|
||||
if ( program.dev ) {
|
||||
testEnvVars.JEST_PUPPETEER_CONFIG = 'tests/e2e-tests/config/jest-puppeteer.dev.config.js';
|
||||
testEnvVars.PUPPETEER_HEADLESS = 'false';
|
||||
testEnvVars.PUPPETEER_SLOWMO = '50';
|
||||
|
||||
delete testEnvVars.JEST_PUPPETEER_CONFIG;
|
||||
useJestPuppeteerConfig();
|
||||
}
|
||||
|
||||
const envVars = Object.assign( {}, process.env, testEnvVars );
|
||||
|
|
|
@ -8,7 +8,7 @@ Automated end-to-end tests for WooCommerce.
|
|||
- [Install NodeJS](#install-nodejs)
|
||||
- [Install Docker](#install-docker)
|
||||
- [Configuration](#configuration)
|
||||
- [Test Environment Configuration](#test-environment-configuration)
|
||||
- [Test Environment](#test-environment)
|
||||
- [Environment Variables](#environment-variables)
|
||||
- [Jest test sequencer](#jest-test-sequencer)
|
||||
- [Running tests](#running-tests)
|
||||
|
@ -44,13 +44,15 @@ Once installed, you should see `Docker Desktop is running` message with the gree
|
|||
|
||||
Note, that if you install docker through other methods such as homebrew, for example, your steps to set it up will be different. The commands listed in steps below may also vary.
|
||||
|
||||
### Configuration
|
||||
## Configuration
|
||||
|
||||
#### Test Environment Configuration
|
||||
This section explains how e2e tests are working behind the scenes. These are not instructions on how to build environment for running e2e tests and run them. If you are looking for instructions on how to run e2e tests, jump to [Running tests](#running-tests).
|
||||
|
||||
### Test Environment
|
||||
|
||||
We recommend using Docker for running tests locally in order for the test environment to match the setup on Travis CI (where Docker is also used for running tests). [An official WordPress Docker image](https://github.com/docker-library/docs/blob/master/wordpress/README.md) is used to build the site. Once the site using the WP Docker image is built, the current WooCommerce dev branch is being copied to the `plugins` folder of that newly built test site. No WooCommerce Docker image is being built or needed.
|
||||
|
||||
#### Environment Variables
|
||||
### Environment Variables
|
||||
|
||||
During the process of Docker building a container with test site for running tests, site URL is being set. Admin and customer users are also being created in advance with details specified in the `docker-compose.yaml` file. As a result, there is `./tests/e2e-tests/config/default.json` file that contains pre-set variables needed to run the test:
|
||||
|
||||
|
@ -72,7 +74,7 @@ During the process of Docker building a container with test site for running tes
|
|||
|
||||
If you changed either site URL or one of the users details in the `docker-compose.yaml` file, you'd need to copy the content of the `default.json`, paste it to `test:e2e.json` and edit it further there to match your own setup.
|
||||
|
||||
## Jest test sequencer
|
||||
### Jest test sequencer
|
||||
|
||||
[Jest](https://jestjs.io/) is being used to run e2e tests. By default, jest runs tests ordered by the time it takes to run the test (the test that takes longer to run will be run first, the test that takes less time to run will run last). Jest sequencer introduces tools that can be used to specify the order in which the tests are being run. In our case, they are being run in alphabetical order of the directories where tests are located. This way, tests in the new directory `activate-and-setup` will run first.
|
||||
|
||||
|
@ -82,7 +84,9 @@ Setup Wizard e2e test (located in `activate-and-setup` directory) will run befor
|
|||
|
||||
### Prep work for running tests
|
||||
|
||||
- Checkout the branch to test and stay on this branch.
|
||||
- `cd` to the WooCommerce plugin folder
|
||||
|
||||
- `git checkout master` or checkout the branch where you need to run tests
|
||||
|
||||
- Run `npm install`
|
||||
|
||||
|
@ -101,6 +105,8 @@ woocommerce_wordpress-cli_1 exited with code 0
|
|||
woocommerce_wordpress-cli_1 exited with code 0
|
||||
```
|
||||
|
||||
For more Docker commands, scroll down to [Docker basics](#docker-basics).
|
||||
|
||||
- Open new terminal window and `cd` to the current branch again.
|
||||
|
||||
- Run the following command to make sure the containers were built and running: `docker ps`. You should see the 2 following containers:
|
||||
|
@ -126,7 +132,7 @@ Tests are being run headless by default. However, sometimes it's useful to obser
|
|||
npm run test:e2e-dev
|
||||
```
|
||||
|
||||
The dev mode also enables SlowMo mode. SlowMo slows down Puppeteer’s operations so we can better see what is happening in the browser. You can adjust the SlowMo value by editing `PUPPETEER_SLOWMO` variable in `./tests/e2e-tests/config/jest-puppeteer.dev.config.js` file. The default `PUPPETEER_SLOWMO=50` means test actions will be slowed down by 50 milliseconds.
|
||||
The dev mode also enables SlowMo mode. SlowMo slows down Puppeteer’s operations so we can better see what is happening in the browser. You can adjust the SlowMo value by editing `PUPPETEER_SLOWMO` variable in `./tests/bin/e2e-test-integration.js` file. The default `PUPPETEER_SLOWMO=50` means test actions will be slowed down by 50 milliseconds.
|
||||
|
||||
### How to run an individual test
|
||||
|
||||
|
@ -194,7 +200,8 @@ Tests are kept in `tests/e2e-tests/specs` folder.
|
|||
|
||||
The following packages are being used to write tests:
|
||||
|
||||
- `e2e-test-utils` - End-To-End (E2E) test utils for WordPress. You can find the full list of utils [here](https://github.com/WordPress/gutenberg/tree/master/packages/e2e-test-utils).
|
||||
- `e2e-test-utils` - End-To-End (E2E) test utils for WordPress. You can find the full list of utils [here](https://github.com/WordPress/gutenberg/tree/master/packages/e2e-test-utils);
|
||||
- `puppeteer-utils` - Utilities and configuration for running puppeteer against WordPress. See details in the [package's repository](https://github.com/Automattic/puppeteer-utils).
|
||||
|
||||
## Debugging tests
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/** @format */
|
||||
|
||||
module.exports = {
|
||||
launch: {
|
||||
slowMo: process.env.PUPPETEER_SLOWMO ? false : 50,
|
||||
headless: process.env.PUPPETEER_HEADLESS || false,
|
||||
ignoreHTTPSErrors: true,
|
||||
args: [
|
||||
'--window-size=1920,1080',
|
||||
'--user-agent=puppeteer-debug',
|
||||
],
|
||||
devtools: true,
|
||||
defaultViewport: {
|
||||
width: 1280,
|
||||
height: 800,
|
||||
},
|
||||
// Required for the logged out and logged in tests so they don't share app state/token.
|
||||
browserContext: 'incognito',
|
||||
}
|
||||
};
|
|
@ -1,34 +1,14 @@
|
|||
/**
|
||||
* @flow strict
|
||||
* @format
|
||||
* External dependencies
|
||||
*/
|
||||
const { jestConfig } = require( 'puppeteer-utils' );
|
||||
const modifiedConfig = jestConfig;
|
||||
const afterEnvSetup = modifiedConfig.setupFilesAfterEnv;
|
||||
|
||||
// https://jestjs.io/docs/en/configuration.html
|
||||
|
||||
module.exports = {
|
||||
// Automatically clear mock calls and instances between every test
|
||||
clearMocks: true,
|
||||
|
||||
// An array of file extensions your modules use
|
||||
moduleFileExtensions: [ 'js' ],
|
||||
|
||||
preset: 'jest-puppeteer',
|
||||
|
||||
// Where to look for test files
|
||||
roots: [ '<rootDir>/tests/e2e-tests/specs' ],
|
||||
|
||||
//setupFiles: [ '<rootDir>/.node_modules/regenerator-runtime/runtime' ],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework
|
||||
// before each test
|
||||
setupFilesAfterEnv: [
|
||||
'<rootDir>/tests/e2e-tests/config/jest.setup.js',
|
||||
'expect-puppeteer',
|
||||
],
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
testMatch: [ '**/*.(test|spec).js' ],
|
||||
afterEnvSetup.push( '<rootDir>/tests/e2e-tests/config/jest.setup.js');
|
||||
modifiedConfig.setupFilesAfterEnv = afterEnvSetup;
|
||||
|
||||
// Sort test path alphabetically. This is needed so that `activate-and-setup` tests run first
|
||||
testSequencer: '<rootDir>/tests/e2e-tests/config/jest-custom-sequencer.js',
|
||||
};
|
||||
modifiedConfig.testSequencer = '<rootDir>/tests/e2e-tests/config/jest-custom-sequencer.js';
|
||||
|
||||
module.exports = modifiedConfig;
|
||||
|
|
|
@ -39,7 +39,7 @@ describe( 'Single Product Page', () => {
|
|||
} );
|
||||
} );
|
||||
|
||||
describe( 'Variable Product Page', () => {
|
||||
describe.skip( 'Variable Product Page', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
variablePostIdValue = await createVariableProduct();
|
||||
|
|
|
@ -60,7 +60,7 @@ describe( 'Add New Simple Product Page', () => {
|
|||
} );
|
||||
} );
|
||||
|
||||
describe( 'Add New Variable Product Page', () => {
|
||||
describe.skip( 'Add New Variable Product Page', () => {
|
||||
it( 'can create product with variations', async () => {
|
||||
// Go to "add product" page
|
||||
await StoreOwnerFlow.openNewProduct();
|
||||
|
|
Loading…
Reference in New Issue