fix composer.lock conflict

This commit is contained in:
Ron Rennick 2020-02-25 15:00:55 -04:00
commit 25ab5596a2
17 changed files with 1760 additions and 165 deletions

View File

@ -63,6 +63,7 @@ before_script:
else
echo "xdebug.ini does not exist"
fi
- nvm install 10
- npm install
- composer install --no-dev
- |

View File

@ -39,10 +39,3 @@ find ./packages/woocommerce-admin -iname '*.js' -exec sed -i.bak -e "s/, 'woocom
# Cleanup backup files
find ./packages -name "*.bak" -type f -delete
output 2 "Done!"
# Apply patches
output 2 "Applying patch #450 to Action Schduler"
cd packages/action-scheduler
curl -O https://patch-diff.githubusercontent.com/raw/woocommerce/action-scheduler/pull/450.patch
patch -p1 < 450.patch
output 2 "Done!"

View File

@ -13,8 +13,8 @@
"composer/installers": "1.7.0",
"maxmind-db/reader": "1.6.0",
"pelago/emogrifier": "^3.1",
"woocommerce/action-scheduler": "3.0.1",
"woocommerce/woocommerce-blocks": "2.5.12",
"woocommerce/action-scheduler": "3.1.1",
"woocommerce/woocommerce-blocks": "2.5.13",
"woocommerce/woocommerce-rest-api": "1.0.7",
"woocommerce/woocommerce-admin": "0.26"
},

20
composer.lock generated
View File

@ -383,16 +383,16 @@
},
{
"name": "woocommerce/action-scheduler",
"version": "3.0.1",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/action-scheduler.git",
"reference": "3847b7c97032ca92abed6c6f154e548437dc5803"
"reference": "ca6f65cca0aa6bdc02e6939c93fd439c5a552b76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/3847b7c97032ca92abed6c6f154e548437dc5803",
"reference": "3847b7c97032ca92abed6c6f154e548437dc5803",
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/ca6f65cca0aa6bdc02e6939c93fd439c5a552b76",
"reference": "ca6f65cca0aa6bdc02e6939c93fd439c5a552b76",
"shasum": ""
},
"require-dev": {
@ -414,7 +414,7 @@
],
"description": "Action Scheduler for WordPress and WooCommerce",
"homepage": "https://actionscheduler.org/",
"time": "2020-01-14T01:30:08+00:00"
"time": "2020-02-25T02:28:35+00:00"
},
{
"name": "woocommerce/woocommerce-admin",
@ -465,16 +465,16 @@
},
{
"name": "woocommerce/woocommerce-blocks",
"version": "v2.5.12",
"version": "v2.5.13",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "8aeae57938dd527d8091f312061c939f1145154b"
"reference": "31fde486e9dc27bd06362a4ceb54e5b23e6b03fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/8aeae57938dd527d8091f312061c939f1145154b",
"reference": "8aeae57938dd527d8091f312061c939f1145154b",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/31fde486e9dc27bd06362a4ceb54e5b23e6b03fb",
"reference": "31fde486e9dc27bd06362a4ceb54e5b23e6b03fb",
"shasum": ""
},
"require": {
@ -508,7 +508,7 @@
"gutenberg",
"woocommerce"
],
"time": "2020-02-05T22:53:11+00:00"
"time": "2020-02-18T13:57:13+00:00"
},
{
"name": "woocommerce/woocommerce-rest-api",

View File

@ -2428,6 +2428,11 @@ class WC_Admin_Setup_Wizard {
}
Jetpack::maybe_set_version_option();
$jetpack = Jetpack::init();
// Older versions of jetpack may not have this method.
if ( method_exists( $jetpack, 'configure' ) ) {
$jetpack->configure();
}
$register_result = Jetpack::try_registration();
if ( is_wp_error( $register_result ) ) {

View File

@ -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;

View File

@ -86,6 +86,28 @@ class WC_Tracker {
return apply_filters( 'woocommerce_tracker_last_send_time', get_option( 'woocommerce_tracker_last_send', false ) );
}
/**
* Test whether this site is a staging site according to the Jetpack criteria.
*
* With Jetpack 8.1+, Jetpack::is_staging_site has been deprecated.
* \Automattic\Jetpack\Status::is_staging_site is the replacement.
* However, there are version of JP where \Automattic\Jetpack\Status exists, but does *not* contain is_staging_site method,
* so with those, code still needs to use the previous check as a fallback.
*
* @return bool
*/
private static function is_jetpack_staging_site() {
if ( class_exists( '\Automattic\Jetpack\Status' ) ) {
// Preferred way of checking with Jetpack 8.1+.
$jp_status = new \Automattic\Jetpack\Status();
if ( is_callable( array( $jp_status, 'is_staging_site' ) ) ) {
return $jp_status->is_staging_site();
}
}
return ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() );
}
/**
* Get all the tracking data.
*
@ -111,9 +133,10 @@ class WC_Tracker {
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
// Jetpack & WooCommerce Connect.
$data['jetpack_version'] = Constants::is_defined( 'JETPACK__VERSION' ) ? Constants::get_constant( 'JETPACK__VERSION' ) : 'none';
$data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no';
$data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no';
$data['jetpack_is_staging'] = self::is_jetpack_staging_site() ? 'yes' : 'no';
$data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no';
$data['connect_active'] = ( class_exists( 'WC_Connect_Loader' ) && wp_next_scheduled( 'wc_connect_fetch_service_schemas' ) ) ? 'yes' : 'no';
$data['helper_connected'] = self::get_helper_connected();

View File

@ -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';
}

View File

@ -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
}

1606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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"

View File

@ -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.

View File

@ -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 );

View File

@ -7,10 +7,10 @@ Automated end-to-end tests for WooCommerce.
- [Pre-requisites](#pre-requisites)
- [Install NodeJS](#install-nodejs)
- [Install Docker](#install-docker)
- [Configuration](#configuration)
- [Test Environment Configuration](#test-environment-configuration)
- [Environment Variables](#environment-variables)
- [Jest test sequencer](#jest-test-sequencer)
- [Configuration](#configuration)
- [Test Environment](#test-environment)
- [Environment Variables](#environment-variables)
- [Jest test sequencer](#jest-test-sequencer)
- [Running tests](#running-tests)
- [Prep work for running tests](#prep-work-for-running-tests)
- [How to run tests in headless mode](#how-to-run-tests-in-headless-mode)
@ -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 Puppeteers 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 Puppeteers 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

View File

@ -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',
}
};

View File

@ -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
afterEnvSetup.push( '<rootDir>/tests/e2e-tests/config/jest.setup.js');
modifiedConfig.setupFilesAfterEnv = afterEnvSetup;
module.exports = {
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Sort test path alphabetically. This is needed so that `activate-and-setup` tests run first
modifiedConfig.testSequencer = '<rootDir>/tests/e2e-tests/config/jest-custom-sequencer.js';
// 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' ],
// 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',
};
module.exports = modifiedConfig;

View File

@ -0,0 +1,117 @@
<?php
/**
* Test for the queue class.
* @package WooCommerce\Tests\Queue
*/
/**
* WC_Tests_Discounts.
*/
class WC_Tests_Queue extends WC_Unit_Test_Case {
/**
* Test scheduling and retrieving actions.
*/
public function test_schedule_and_get_actions() {
$queue = WC_Queue::instance();
// Set up action arguments.
$current_time = time();
$timestamp = $current_time + HOUR_IN_SECONDS;
$args = range( 100, 130 );
$args = array_flip( $args );
$unique_hash = md5( wp_json_encode( $args ) );
$args[119] = $unique_hash;
$group = 'wc-unit-tests';
// Schedule a single action.
$hook = 'single_test_action';
$single = $queue->schedule_single( $timestamp, $hook, $args, $group );
// Test next schedule is specified timestamp.
$schedule = $queue->get_next( $hook, $args, $group );
$this->assertEquals( $schedule->getTimestamp(), $timestamp );
// Test that the action can be found.
$action_ids = $queue->search(
array(
'hook' => $hook,
'args' => $args,
'group' => $group,
),
'ids'
);
$this->assertContains( $single, $action_ids );
$action_ids = $queue->search(
array(
'hook' => $hook,
'search' => $unique_hash,
'group' => $group,
),
'ids'
);
$this->assertContains( $single, $action_ids );
// Schedule a recurring action.
$hook = 'recurring_test_action';
$recurring = $queue->schedule_recurring( $timestamp, DAY_IN_SECONDS, $hook, $args, $group );
// Test next schedule is specified timestamp.
$schedule = $queue->get_next( $hook, $args, $group );
$this->assertEquals( $schedule->getTimestamp(), $timestamp );
// Test that the action can be found.
$action_ids = $queue->search(
array(
'hook' => $hook,
'args' => $args,
'group' => $group,
),
'ids'
);
$this->assertContains( $recurring, $action_ids );
$action_ids = $queue->search(
array(
'hook' => $hook,
'search' => $unique_hash,
'group' => $group,
),
'ids'
);
$this->assertContains( $recurring, $action_ids );
// Schedule a cron action on a daily midnight schedule starting at the next midnight.
$hook = 'recurring_cron_action';
$cron_schedule = '0 0 * * *';
$timestamp = $current_time + DAY_IN_SECONDS - ( $current_time % DAY_IN_SECONDS );
$cron_action = $queue->schedule_cron( $timestamp - HOUR_IN_SECONDS, $cron_schedule, $hook, $args, $group );
// Test next schedule is specified timestamp.
$schedule = $queue->get_next( $hook, $args, $group );
$this->assertEquals( $schedule->getTimestamp(), $timestamp );
// Test that the action can be found.
$action_ids = $queue->search(
array(
'hook' => $hook,
'args' => $args,
'group' => $group,
),
'ids'
);
$this->assertContains( $cron_action, $action_ids );
$action_ids = $queue->search(
array(
'hook' => $hook,
'search' => $unique_hash,
'group' => $group,
),
'ids'
);
$this->assertContains( $cron_action, $action_ids );
// Test wildcard search.
$action_ids = $queue->search( array( 'search' => $unique_hash ), 'ids' );
$this->assertEquals( count( $action_ids ), 3 );
}
}