Merge branch 'trunk' into fix/29277-release

This commit is contained in:
Ron Rennick 2021-03-24 16:15:03 -03:00
commit 7529914a98
39 changed files with 921 additions and 298 deletions

74
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,74 @@
name: Run CI
on:
push:
branches:
- trunk
- 'release/**'
jobs:
test:
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }}
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
wp: [ 'latest' ]
include:
- wp: nightly
php: '7.4'
- wp: '5.5'
php: 7.2
- wp: '5.4'
php: 7.2
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
extensions: mysql
coverage: none
- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v2
with:
path: |
./packages
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Setup and install composer
run: composer install
- name: Add PHP8 Compatibility.
run: |
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip
unzip -d /tmp/phpunit-7.5-fork /tmp/phpunit-7.5-fork.zip
composer bin phpunit config --unset platform
composer bin phpunit config repositories.0 '{"type": "path", "url": "/tmp/phpunit-7.5-fork/phpunit-add-compatibility-with-php8-to-phpunit-7", "options": {"symlink": false}}'
composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs
fi
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
- name: Run tests
run: ./vendor/bin/phpunit -c ./phpunit.xml

View File

@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Setup PHP
uses: shivammathur/setup-php@v2
@ -49,3 +51,7 @@ jobs:
run: |
RUN_CODE_COVERAGE=1 bash ./tests/bin/phpunit.sh
exit 0
- name: Send code coverage to Codecov.
run: |
bash <(curl -s https://codecov.io/bash)

View File

@ -6,25 +6,17 @@ jobs:
name: Code sniff (PHP 7.4, WP Latest)
timeout-minutes: 15
runs-on: ubuntu-latest
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: mysql
coverage: none
tools: composer, cs2pr
- name: Tool versions
run: |
@ -42,8 +34,9 @@ jobs:
- name: Setup and install composer
run: composer install
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest
- name: Run code sniff
run: RUN_PHPCS=1 bash ./tests/bin/phpcs.sh
continue-on-error: true
run: ./tests/bin/phpcs.sh "${{ github.event.pull_request.base.sha }}" "${{ github.event.after }}"
- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml

View File

@ -1,110 +0,0 @@
version: ~> 1.0
# Specifies that Travis should create builds for trunk and release branches and also tags.
branches:
only:
- trunk
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
- /^release\//
language: php
os:
- linux
dist: xenial
# Test main supported versions of PHP against latest WP.
php:
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
env:
- WP_VERSION=latest WP_MULTISITE=0
# Additional tests against stable PHP (min version is 7.0)
# and code coverage report.
jobs:
fast_finish: true
include:
- name: "Core E2E Tests"
env: WP_VERSION=latest WP_MULTISITE=0 RUN_E2E=1
install:
- nvm install
- npm install
- composer install --no-dev
script:
- npm run build:assets
- npm run docker:up
- npm run test:e2e
after_script:
- npm run docker:down
- name: "WP Nightly"
php: "7.4"
env: WP_VERSION=nightly WP_MULTISITE=0
- name: "WP Latest - 1"
php: "7.2"
env: WP_VERSION=5.5 WP_MULTISITE=0
- name: "WP Latest - 2"
php: "7.2"
env: WP_VERSION=5.4 WP_MULTISITE=0
- name: "Code Standards"
php: "7.4"
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
- name: "Code Coverage"
php: "7.4"
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
allow_failures:
- php: "7.4"
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
# Git clone depth
# By default Travis CI clones repositories to a depth of 50 commits. Using a depth of 1 makes this step a bit faster.
git:
depth: 1
# Since Xenial services are not started by default, we need to instruct it below to start.
services:
- mysql
- docker
cache:
directories:
- $HOME/.composer/cache
# Composer 2.0.7 introduced a change that broke the jetpack autoloader in PHP 7.0 - 7.3.
before_install:
- composer self-update 2.0.6
install:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
# Remove Xdebug for a huge performance increase:
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi
- composer install
- |
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip
unzip -d /tmp/phpunit-7.5-fork /tmp/phpunit-7.5-fork.zip
composer bin phpunit config --unset platform
composer bin phpunit config repositories.0 '{"type": "path", "url": "/tmp/phpunit-7.5-fork/phpunit-add-compatibility-with-php8-to-phpunit-7", "options": {"symlink": false}}'
composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs
fi
- |
# Install WP Test suite:
if [[ ! -z "$WP_VERSION" ]]; then
bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
fi
script:
- bash tests/bin/phpunit.sh
- bash tests/bin/phpcs.sh
after_script:
- bash tests/bin/travis.sh after

View File

@ -5,7 +5,7 @@
<a href="https://packagist.org/packages/woocommerce/woocommerce"><img src="https://poser.pugx.org/woocommerce/woocommerce/v/stable" alt="Latest Stable Version"></a>
<img src="https://img.shields.io/wordpress/plugin/dt/woocommerce.svg" alt="WordPress.org downloads">
<img src="https://img.shields.io/wordpress/plugin/r/woocommerce.svg" alt="WordPress.org rating">
<a href="https://travis-ci.com/woocommerce/woocommerce"><img src="https://travis-ci.com/woocommerce/woocommerce.svg?branch=trunk" alt="Build Status"></a>
<a href="https://github.com/woocommerce/woocommerce/actions/workflows/ci.yml"><img src="https://github.com/woocommerce/woocommerce/actions/workflows/ci.yml/badge.svg?branch=trunk" alt="Build Status"></a>
<a href="https://codecov.io/gh/woocommerce/woocommerce"><img src="https://codecov.io/gh/woocommerce/woocommerce/branch/trunk/graph/badge.svg" alt="codecov"></a>
</p>

View File

@ -385,6 +385,7 @@ ul.products {
.woocommerce-loop-product__link {
display: block;
text-decoration: none;
position: relative;
}
.woocommerce-loop-product__title {

View File

@ -72,6 +72,49 @@ jQuery( function( $ ) {
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
});
function display_result( self, select2_args ) {
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
$( self ).selectWoo( select2_args ).addClass( 'enhanced' );
if ( $( self ).data( 'sortable' ) ) {
var $select = $(self);
var $list = $( self ).next( '.select2-container' ).find( 'ul.select2-selection__rendered' );
$list.sortable({
placeholder : 'ui-state-highlight select2-selection__choice',
forcePlaceholderSize: true,
items : 'li:not(.select2-search__field)',
tolerance : 'pointer',
stop: function() {
$( $list.find( '.select2-selection__choice' ).get().reverse() ).each( function() {
var id = $( self ).data( 'data' ).id;
var option = $select.find( 'option[value="' + id + '"]' )[0];
$select.prepend( option );
} );
}
});
// Keep multiselects ordered alphabetically if they are not sortable.
} else if ( $( self ).prop( 'multiple' ) ) {
$( self ).on( 'change', function(){
var $children = $( self ).children();
$children.sort(function(a, b){
var atext = a.text.toLowerCase();
var btext = b.text.toLowerCase();
if ( atext > btext ) {
return 1;
}
if ( atext < btext ) {
return -1;
}
return 0;
});
$( self ).html( $children );
});
}
}
// Ajax product search box
$( ':input.wc-product-search' ).filter( ':not(.enhanced)' ).each( function() {
var select2_args = {
@ -112,46 +155,48 @@ jQuery( function( $ ) {
}
};
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
display_result( this, select2_args );
});
// Ajax Page Search.
$( ':input.wc-page-search' ).filter( ':not(.enhanced)' ).each( function() {
var select2_args = {
allowClear: $( this ).data( 'allow_clear' ) ? true : false,
placeholder: $( this ).data( 'placeholder' ),
minimumInputLength: $( this ).data( 'minimum_input_length' ) ? $( this ).data( 'minimum_input_length' ) : '3',
escapeMarkup: function( m ) {
return m;
},
ajax: {
url: wc_enhanced_select_params.ajax_url,
dataType: 'json',
delay: 250,
data: function( params ) {
return {
term : params.term,
action : $( this ).data( 'action' ) || 'woocommerce_json_search_pages',
security : wc_enhanced_select_params.search_pages_nonce,
exclude : $( this ).data( 'exclude' ),
post_status : $( this ).data( 'post_status' ),
limit : $( this ).data( 'limit' ),
};
},
processResults: function( data ) {
var terms = [];
if ( data ) {
$.each( data, function( id, text ) {
terms.push( { id: id, text: text } );
} );
}
return {
results: terms
};
},
cache: true
}
};
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
if ( $( this ).data( 'sortable' ) ) {
var $select = $(this);
var $list = $( this ).next( '.select2-container' ).find( 'ul.select2-selection__rendered' );
$list.sortable({
placeholder : 'ui-state-highlight select2-selection__choice',
forcePlaceholderSize: true,
items : 'li:not(.select2-search__field)',
tolerance : 'pointer',
stop: function() {
$( $list.find( '.select2-selection__choice' ).get().reverse() ).each( function() {
var id = $( this ).data( 'data' ).id;
var option = $select.find( 'option[value="' + id + '"]' )[0];
$select.prepend( option );
} );
}
});
// Keep multiselects ordered alphabetically if they are not sortable.
} else if ( $( this ).prop( 'multiple' ) ) {
$( this ).on( 'change', function(){
var $children = $( this ).children();
$children.sort(function(a, b){
var atext = a.text.toLowerCase();
var btext = b.text.toLowerCase();
if ( atext > btext ) {
return 1;
}
if ( atext < btext ) {
return -1;
}
return 0;
});
$( this ).html( $children );
});
}
});
// Ajax customer search boxes

View File

@ -1,5 +1,140 @@
== Changelog ==
= 5.2.0 beta 2021-03-23 =
**WooCommerce**
* Update - WooCommerce Blocks package 4.7.0. #29406
* Update - WooCommerce Admin package 2.1.3. #29283
* Add - Filter woocommerce_product_recount_terms to allow/prevent recounting of product terms. #29281
* Add - Result return array to the checkout_place_order_success callback to allow 3rd party to manipulate results. #29232
* Dev - Fix miscellaneous typos in docblocks. #29285
* Dev - Added woocommerce_ajax_order_items_removed hook. #29241
* Dev - Fix usage of docker-compose (wc-e2e) commands in e2e tests when running them within WSL2. #29207
* Dev - Fixes to documentation of WC_Shipping_Rate. #29117
* Dev - Add tracks event when a user clicks on the links of the WooCommerce Status widget. #29109
* Dev - Track the number of installations of WooCommerce Payments via that extensions banner for stores that have opted in to tracking. #29052
* Dev - Added woocommerce_ajax_order_items_removed hook. #28936
* Dev - Add tracking of woocommerce_admin_disabled usage. #28535
* Enhancement - Add support for the low stock threshold for variations. #29345
* Enhancement - Clean up of major version update compatibility warnings. #29200
* Enhancement - Add a new dashboard widget to promote users to finish onboarding tasks. #29174
* Enhancement - Update the Woo widget net sales link and logic to use the new analytics page and data. #29149
* Enhancement - Added the body class woocommerce-shop to the shop page, so that it can be targeted via CSS. (#28724). #29051
* Enhancement - Make sure downloadable file paths are properly recognized for strengthened security. #28699
* Enhancement - Delay the registration of data exporters and erasers to avoid multiple language files from being loaded. #28078
* Fix - Offsets not calculated correctly sometimes on select2 dropdowns causing usability issues. #29397
* Fix - Handle errors in fault installations of PHP Intl. #29391
* Fix - Cart page calculate shipping fields not showing correct fields based on location. #29282
* Fix - Product categories widget item count not always showing the correct number. #29281
* Fix - Updated include/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php to include a item schema function which appends support for order and class type values. #29218
* Fix - Check if variation_id if belongs to the parent product while adding products to the cart. #29208
* Fix - Reduce the number of ajax calls used when Geolocation (with Page Caching Enabled) mode is enabled. #29182
* Fix - Don't display the coupon form on checkouts requiring the customer to be logged in to checkout. #29151
* Fix - If coupon_lines are specified within a REST API order update, return an error if coupon item IDs are also specified. #29146
* Fix - Avoids duplicating the word '(optional)' in the context of the Billing Address 2 field. #29136
* Fix - PHP notice when checking out. #29133
* Fix - Remove duplicate containers from the single and archive product pages. #29121
* Fix - Wrong taxonomy caching in term and product attributes controllers. #29115
* Fix - Make the parameters of the refund creation REST API behave as documented. #29099
* Fix - Shipping methods with similar names could cause shipping method not selectable in order page. #29049
* Fix - WC_Countries::get_formatted_address() not returning full name in correct order in some languages. #29008
* Fix - add validation of the posted country codes on checkout. #28849
* Fix - Correctly display pagination arrows on RTL languages. #28523
* Fix - Invalid refund amount error on $0 refund when number of decimals is equal to 0. #27277
* Tweak - Added the Mercado Pago logo into the assets/images folder in order to use it in the payments setup task. #29365
* Tweak - Update the contributor guidelines. #29150
* Tweak - Introduced phone number input validation. #27242
**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3**
* Add - Add navigation intro modal. #6367
* Add - CES track settings tab on updating settings #6368
* Add - Core settings redirection to new settings pages #6091
* Add - Favorites tooltip to the navigation #6312
* Add - Favoriting extensions client UI #6287
* Add - Remove CES actions for adding and editing a product and editing an order #6355
* Add - Settings client pages #6092
* Add - Settings feature and pages #6089
* Dev - Add filter to allow enabling the WP toolbar within the new navigation. #6371
* Dev - Add navigation favorites data store #6275
* Dev - Add unit tests to Navigation's Container component. #6344
* Dev - Allow highlight tooltip to use body tag as parent. #6309
* Dev - Change `siteUrl` to `homeUrl` on navigation site title #6240
* Dev - Fix the react state update error on homescreen. #6320
* Dev - Refactor head and body heights #6247
* Dev - Remove Google fonts and material icons. #6343
* Dev - Use box sizing and padding to fix nav and admin menu styling #6335
* Enhancement - Move capability checks to client #6365
* Enhancement - Move favorited menu items to primary menu #6290
* Enhancement - Navigation: Add test to container component #6344
* Enhancement - override wpbody styles when nav present #6354
* Feature - Increase target audience for business feature step. #6508
* Fix - Add check for navigating being enabled. #6462
* Fix - Add customer name column to CSV export #6556
* Fix - Add guard to "Deactivate Plugin" note handlers to prevent fatal error. #6532
* Fix - Broken link anchors to online documentation. #6455
* Fix - Check if tax was successfully added before displaying notice #6229
* Fix - Correct a bug where the JP connection flow would not happen when installing JP in the OBW. #6521
* Fix - Crash of Analytics > Settings page when Gutenberg is installed. #6540
* Fix - Display" option fails to collapse upon invoking "Help" option #6233
* Fix - Email notes now are turned off by default #6324
* Fix - Empty nav menu #6366
* Fix - Enqueue scripts called incorrectly in php unit tests #6358
* Fix - Hide tooltip in welcome modal #6142
* Fix - Recommended Payment Banner missing in Safari #6375
* Fix - Removal of core settings pages #6328
* Fix - Removed @woocommerce/components/card from OBW #6374
* Fix - Reset Navigation submenu before making Flyout #6396
* Fix - Restore missing Correct the Klarna slug #6440
* Fix - Top bar slightly overlaps wp-admin navigation on mobile #6292
* Fix - update single column home screen width to 680px #6297
* Fix - Update timing of InboxPanel state changes for the unread indicator #6246
* Tweak - Enqueue beta features scripts on enqueue_scripts action instead of filter #6358
* Tweak - Move admin menu manipulation from admin_head to admin_menu #6310
* Tweak - Navigation: Migrate methods to `admin_menu` hook #6319
* Tweak - New Settings: Turn off in dev mode #6348
* Tweak - Order and styles updates to nav footer #6373
* Tweak - Remove categories without menu items #6329
* Tweak - Set `is_deleted` from the database when instantiating a `Note` #6322
* Tweak - Update inline documentation for navigation Screen class #6173
* Tweak - Updates to copy and punctuation to be more conversational and consistent. #6298
**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0**
* Enhancement - Login links on the checkout should use the account page. ([3844](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3844))
* Enhancement - Prevent checkout linking to trashed terms and policy pages. ([3843](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3843))
* Enhancement - Improved nonce logic by moving nonces to cart routes only. ([3812](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3812))
* Enhancement - If coupons become invalid between applying to a cart and checking out, show the user a notice when the order is placed. ([3810](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3810))
* Enhancement - Improve design of cart and checkout sidebars. ([3797](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3797))
* Enhancement - Improve error displayed to customers when an item's stock status changes during checkout. ([3703](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3703))
* Enhancement - Dev - Block Checkout will now respect custom address locales and custom country states via core filter hooks. ([3662](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3662))
* Enhancement - Update checkout block payment methods UI. ([3439](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3439))
* Enhancement - StoreAPI: Inject Order and Cart Controllers into Routes. ([3871](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3871))
* Enhancement - Update Panel component class names to follow guidelines. More info can be found in our theming docs: https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/18dd54f07262b4d1dcf15561624617f824fcdc22/docs/theming/class-names-update-460.md. ([3860](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3860))
* Enhancement - Refactor block type registration to support 3rd party integrations.
* Enhancement - A new configuration property is available to registered payment methods for additional logic handling of saved payment method tokens. ([3961](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3961))
* Enhancement - Provided billing data to payment method extensions so they can decide if payment is possible. ([3922](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3922))
* Enhancement - Prevent errant payment methods from keeping Cart and Checkout blocks from loading. ([3920](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3920))
* Fix block elements that don't play well with dark backgrounds. ([3887](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3887))
* Fix - JS warning if two cart products share the same name. ([3814](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3814))
* Fix - Align place order button to the right of the block. ([3803](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3803))
* Fix - Ensure special characters are displayed properly in the Cart sidebar. ([3721](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3721))
* Fix - Bug where the total price of items did not include tax in the cart and checkout blocks. ([3851](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3851))
* Fix - Handle out-of-stock product visibility setting in All Products block. ([3859](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3859))
* Fix - Show cart item subtotal instead of total in Cart and Checkout blocks ([#3905](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3905))
* Fix - Fix button styles in Twenty Nineteen theme. ([3862](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3862))
* Fix - Return correct sale/regular prices for variable products in the Store API. ([3854](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3854))
* Fix - Remove shadows from text buttons and gradient background from selects in some themes. ([3846](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3846))
* Fix - Hide Browse Shop link in cart block empty state when there is no shop page. ([3845](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3845))
* Fix - Remove extra padding from payment methods with no description. ([3952](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3952))
* Fix - "save payment" checkbox not showing for payment methods. ([3950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3950))
* Fix - Cart preview when shipping rates are set to be hidden until an address is entered. ([3946](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3946))
* Fix - Sync cart item quantity if its Implicitly changed. ([3907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3907))
* Fix - FSE not being visible when WC Blocks was enabled. ([3898](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3898))
* Fix - Ensure sale badges have a uniform height in the Cart block. ([3897](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3897))
* Note - Internally, this release has modified how `AbstractBlock` (the base class for all of our blocks) functions, and how it loads assets. `AbstractBlock` is internal to this project and does not seem like something that would ever need to be extended by 3rd parties, but note if you are doing so for whatever reason, your implementation would need to be updated to match. ([3829](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3829))
= 5.1.0 2021-03-09 =
**WooCommerce**

View File

@ -21,8 +21,8 @@
"pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.1.6",
"woocommerce/woocommerce-admin": "2.0.3",
"woocommerce/woocommerce-blocks": "4.4.3"
"woocommerce/woocommerce-admin": "2.1.3",
"woocommerce/woocommerce-blocks": "4.7.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4"

65
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d60ef90fa87857445878bb83ba4c592c",
"content-hash": "dc5e21e29d4fb70bba776d20112c74f0",
"packages": [
{
"name": "automattic/jetpack-autoloader",
@ -44,6 +44,9 @@
"GPL-2.0-or-later"
],
"description": "Creates a custom autoloader for a plugin or theme.",
"support": {
"source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.9.1"
},
"time": "2021-02-05T19:07:06+00:00"
},
{
@ -75,6 +78,9 @@
"GPL-2.0-or-later"
],
"description": "A wrapper for defining constants in a more testable way.",
"support": {
"source": "https://github.com/Automattic/jetpack-constants/tree/v1.5.1"
},
"time": "2020-10-28T19:00:31+00:00"
},
{
@ -205,6 +211,10 @@
"zend",
"zikula"
],
"support": {
"issues": "https://github.com/composer/installers/issues",
"source": "https://github.com/composer/installers/tree/v1.10.0"
},
"funding": [
{
"url": "https://packagist.com",
@ -279,6 +289,10 @@
"geolocation",
"maxmind"
],
"support": {
"issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues",
"source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.6.0"
},
"time": "2019-12-19T22:59:03+00:00"
},
{
@ -353,6 +367,10 @@
"email",
"pre-processing"
],
"support": {
"issues": "https://github.com/MyIntervals/emogrifier/issues",
"source": "https://github.com/MyIntervals/emogrifier"
},
"time": "2019-12-26T19:37:31+00:00"
},
{
@ -402,6 +420,10 @@
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master"
},
"time": "2017-02-14T16:28:37+00:00"
},
{
@ -455,6 +477,9 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/master"
},
"time": "2017-05-01T15:01:29+00:00"
},
{
@ -490,20 +515,24 @@
],
"description": "Action Scheduler for WordPress and WooCommerce",
"homepage": "https://actionscheduler.org/",
"support": {
"issues": "https://github.com/woocommerce/action-scheduler/issues",
"source": "https://github.com/woocommerce/action-scheduler/tree/master"
},
"time": "2020-05-12T16:22:33+00:00"
},
{
"name": "woocommerce/woocommerce-admin",
"version": "2.0.3",
"version": "2.1.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b"
"reference": "60f4297838569341ae88738a4a8a8090889faaac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/15f43c9a1e81258c245ff50ba416a36a2cba7e0b",
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/60f4297838569341ae88738a4a8a8090889faaac",
"reference": "60f4297838569341ae88738a4a8a8090889faaac",
"shasum": ""
},
"require": {
@ -535,20 +564,24 @@
],
"description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/woocommerce-admin",
"time": "2021-03-10T02:58:43+00:00"
"support": {
"issues": "https://github.com/woocommerce/woocommerce-admin/issues",
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.1.3"
},
"time": "2021-03-15T04:42:40+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",
"version": "v4.4.3",
"version": "v4.7.0",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244"
"reference": "bf9f70607e718c5f83785cad29b33746db0282d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/1eade21846e81d5aaf9bf40cdd1be60778849244",
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/bf9f70607e718c5f83785cad29b33746db0282d3",
"reference": "bf9f70607e718c5f83785cad29b33746db0282d3",
"shasum": ""
},
"require": {
@ -582,7 +615,11 @@
"gutenberg",
"woocommerce"
],
"time": "2021-02-11T18:07:48+00:00"
"support": {
"issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues",
"source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.7.0"
},
"time": "2021-03-16T16:09:55+00:00"
}
],
"packages-dev": [
@ -630,6 +667,10 @@
"isolation",
"tool"
],
"support": {
"issues": "https://github.com/bamarni/composer-bin-plugin/issues",
"source": "https://github.com/bamarni/composer-bin-plugin/tree/master"
},
"time": "2020-05-03T08:27:20+00:00"
}
],
@ -645,5 +686,5 @@
"platform-overrides": {
"php": "7.0"
},
"plugin-api-version": "1.1.0"
"plugin-api-version": "2.0.0"
}

View File

@ -145,6 +145,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
'search_pages_nonce' => wp_create_nonce( 'search-pages' ),
)
);

View File

@ -579,6 +579,47 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
<?php
break;
case 'single_select_page_with_search':
$option_value = $value['value'];
$page = get_post( $option_value );
if ( ! is_null( $page ) ) {
$page = get_post( $option_value );
$option_display_name = sprintf(
/* translators: 1: page name 2: page ID */
__( '%1$s (ID: %2$s)', 'woocommerce' ),
$page->post_title,
$option_value
);
}
?>
<tr valign="top" class="single_select_page">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
</th>
<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
<select
name="<?php echo esc_attr( $value['id'] ); ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
style="<?php echo esc_attr( $value['css'] ); ?>"
class="<?php echo esc_attr( $value['class'] ); ?>"
<?php echo implode( ' ', $custom_attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
data-placeholder="<?php esc_attr_e( 'Search for a page&hellip;', 'woocommerce' ); ?>"
data-allow_clear="true"
data-exclude="<?php echo wc_esc_json( wp_json_encode( $value['args']['exclude'] ) ); ?>"
>
<option value=""></option>
<?php if ( ! is_null( $page ) ) { ?>
<option value="<?php echo esc_attr( $option_value ); ?>" selected="selected">
<?php echo wp_strip_all_tags( $option_display_name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</option>
<?php } ?>
</select> <?php echo $description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
break;
// Single country selects.
case 'single_select_country':
$country_setting = (string) $value['value'];

View File

@ -15,7 +15,7 @@ if ( class_exists( 'WC_Admin_List_Table_Orders', false ) ) {
}
if ( ! class_exists( 'WC_Admin_List_Table', false ) ) {
include_once __DIR__ . '/abstract-class-wc-admin-list-table.php';
include_once __DIR__ . '/abstract-class-wc-admin-list-table.php';
}
/**
@ -765,7 +765,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
}
?>
<select class="wc-customer-search" name="_customer_user" data-placeholder="<?php esc_attr_e( 'Filter by registered customer', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?><option>
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
</select>
<?php
}

View File

@ -337,7 +337,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
?>
<select class="wc-category-search" name="product_cat" data-placeholder="<?php esc_attr_e( 'Filter by category', 'woocommerce' ); ?>" data-allow_clear="true">
<?php if ( $current_category_slug && $current_category ) : ?>
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( htmlspecialchars( wp_kses_post( $current_category->name ) ) ); ?><option>
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( htmlspecialchars( wp_kses_post( $current_category->name ) ) ); ?></option>
<?php endif; ?>
</select>
<?php

View File

@ -74,9 +74,9 @@ class WC_Settings_Advanced extends WC_Settings_Page {
/* Translators: %s Page contents. */
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ),
'id' => 'woocommerce_cart_page_id',
'type' => 'single_select_page',
'type' => 'single_select_page_with_search',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'args' => array(
'exclude' =>
@ -94,9 +94,9 @@ class WC_Settings_Advanced extends WC_Settings_Page {
/* Translators: %s Page contents. */
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ),
'id' => 'woocommerce_checkout_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'type' => 'single_select_page_with_search',
'default' => wc_get_page_id( 'checkout' ),
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'args' => array(
'exclude' =>
@ -114,9 +114,9 @@ class WC_Settings_Advanced extends WC_Settings_Page {
/* Translators: %s Page contents. */
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) ),
'id' => 'woocommerce_myaccount_page_id',
'type' => 'single_select_page',
'type' => 'single_select_page_with_search',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'args' => array(
'exclude' =>
@ -134,9 +134,9 @@ class WC_Settings_Advanced extends WC_Settings_Page {
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
'id' => 'woocommerce_terms_page_id',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'type' => 'single_select_page',
'type' => 'single_select_page_with_search',
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ),
'desc_tip' => true,
'autoload' => false,

View File

@ -207,6 +207,10 @@ class WC_Settings_Emails extends WC_Settings_Page {
'autoload' => false,
),
array(
'type' => 'sectionend',
'id' => 'email_merchant_notes',
),
)
);

View File

@ -2,17 +2,13 @@
/**
* WooCommerce Integration Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce\Admin
* @version 2.1.0
* @package WooCommerce\Admin
* @version 2.1.0
*/
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
@ -50,7 +46,7 @@ if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
$current_section = current( $integrations )->id;
}
if ( sizeof( $integrations ) > 1 ) {
if ( count( $integrations ) > 1 ) {
foreach ( $integrations as $integration ) {
$title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
$sections[ strtolower( $integration->id ) ] = esc_html( $title );

View File

@ -514,7 +514,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
<tbody>
<tr>
<td data-export-label="WC Database Version"><?php esc_html_e( 'WooCommerce database version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The database version for WooCommerce. Note that it may not match WooCommerce core version and that is normal.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr>
<tr>

View File

@ -155,6 +155,7 @@ class WC_AJAX {
'json_search_downloadable_products_and_variations',
'json_search_customers',
'json_search_categories',
'json_search_pages',
'term_ordering',
'product_ordering',
'refund_line_items',
@ -1766,6 +1767,47 @@ class WC_AJAX {
wp_send_json( apply_filters( 'woocommerce_json_search_found_categories', $found_categories ) );
}
/**
* Ajax request handling for page searching.
*/
public static function json_search_pages() {
ob_start();
check_ajax_referer( 'search-pages', 'security' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( -1 );
}
$search_text = isset( $_GET['term'] ) ? wc_clean( wp_unslash( $_GET['term'] ) ) : '';
$limit = isset( $_GET['limit'] ) ? absint( wp_unslash( $_GET['limit'] ) ) : -1;
$exclude_ids = ! empty( $_GET['exclude'] ) ? array_map( 'absint', (array) wp_unslash( $_GET['exclude'] ) ) : array();
$args = array(
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'posts_per_page' => $limit,
'post_type' => 'page',
'post_status' => array( 'publish', 'private', 'draft' ),
's' => $search_text,
'post__not_in' => $exclude_ids,
);
$search_results_query = new WP_Query( $args );
$pages_results = array();
foreach ( $search_results_query->get_posts() as $post ) {
$pages_results[ $post->ID ] = sprintf(
/* translators: 1: page name 2: page ID */
__( '%1$s (ID: %2$s)', 'woocommerce' ),
get_the_title( $post ),
$post->ID
);
}
wp_send_json( apply_filters( 'woocommerce_json_search_found_pages', $pages_results ) );
}
/**
* Ajax request handling for categories ordering.
*/

View File

@ -977,7 +977,8 @@ class WC_Checkout {
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
if ( ! is_ajax() ) {
wp_safe_redirect( $result['redirect'] );
// phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
wp_redirect( $result['redirect'] );
exit;
}

View File

@ -23,7 +23,7 @@ final class WooCommerce {
*
* @var string
*/
public $version = '5.2.0';
public $version = '5.3.0';
/**
* WooCommerce Schema version.

View File

@ -146,10 +146,12 @@ class WC_Log_Handler_File extends WC_Log_Handler {
if ( $file ) {
if ( ! file_exists( $file ) ) {
$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
@fclose( $temphandle ); // @codingStandardsIgnoreLine.
if ( is_resource( $temphandle ) ) {
@fclose( $temphandle ); // @codingStandardsIgnoreLine.
if ( Constants::is_defined( 'FS_CHMOD_FILE' ) ) {
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
if ( Constants::is_defined( 'FS_CHMOD_FILE' ) ) {
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
}
}
}

View File

@ -487,13 +487,12 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
/**
* Prepare a single tax output for response.
*
* @param stdClass $tax Tax object.
* @param stdClass $tax Tax object.
* @param WP_REST_Request $request Request object.
*
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response( $tax, $request ) {
global $wpdb;
$id = (int) $tax->tax_rate_id;
$data = array(
'id' => $id,
@ -510,18 +509,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
'class' => $tax->tax_rate_class ? $tax->tax_rate_class : 'standard',
);
// Get locales from a tax rate.
$locales = $wpdb->get_results( $wpdb->prepare( "
SELECT location_code, location_type
FROM {$wpdb->prefix}woocommerce_tax_rate_locations
WHERE tax_rate_id = %d
", $id ) );
if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
foreach ( $locales as $locale ) {
$data[ $locale->location_type ] = $locale->location_code;
}
}
$data = $this->add_tax_rate_locales( $data, $tax );
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object( $data, $request );
@ -561,6 +549,38 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
return $links;
}
/**
* Add tax rate locales to the response array.
*
* @param array $data Response data.
* @param stdClass $tax Tax object.
*
* @return array
*/
protected function add_tax_rate_locales( $data, $tax ) {
global $wpdb;
// Get locales from a tax rate.
$locales = $wpdb->get_results(
$wpdb->prepare(
"
SELECT location_code, location_type
FROM {$wpdb->prefix}woocommerce_tax_rate_locations
WHERE tax_rate_id = %d
",
$tax->tax_rate_id
)
);
if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
foreach ( $locales as $locale ) {
$data[ $locale->location_type ] = $locale->location_code;
}
}
return $data;
}
/**
* Get the Taxes schema, conforming to JSON Schema.
*

View File

@ -24,4 +24,73 @@ class WC_REST_Taxes_Controller extends WC_REST_Taxes_V2_Controller {
* @var string
*/
protected $namespace = 'wc/v3';
/**
* Add tax rate locales to the response array.
*
* @param array $data Response data.
* @param stdClass $tax Tax object.
*
* @return array
*/
protected function add_tax_rate_locales( $data, $tax ) {
global $wpdb;
$data = parent::add_tax_rate_locales( $data, $tax );
$data['postcodes'] = array();
$data['cities'] = array();
// Get locales from a tax rate.
$locales = $wpdb->get_results(
$wpdb->prepare(
"
SELECT location_code, location_type
FROM {$wpdb->prefix}woocommerce_tax_rate_locations
WHERE tax_rate_id = %d
",
$tax->tax_rate_id
)
);
if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
foreach ( $locales as $locale ) {
if ( 'postcode' === $locale->location_type ) {
$data['postcodes'][] = $locale->location_code;
} elseif ( 'city' === $locale->location_type ) {
$data['cities'][] = $locale->location_code;
}
}
}
return $data;
}
/**
* Get the taxes schema, conforming to JSON Schema.
*
* @return array
*/
public function get_item_schema() {
$schema = parent::get_item_schema();
$schema['properties']['postcodes'] = array(
'description' => __( 'List of postcodes / ZIPs.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
'context' => array( 'view', 'edit' ),
);
$schema['properties']['cities'] = array(
'description' => __( 'List of city names.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
'context' => array( 'view', 'edit' ),
);
return $schema;
}
}

View File

@ -84,7 +84,7 @@ class WC_Shortcode_Products {
* Get shortcode type.
*
* @since 3.2.0
* @return array
* @return string
*/
public function get_type() {
return $this->type;

View File

@ -1,7 +1,7 @@
{
"name": "woocommerce",
"title": "WooCommerce",
"version": "5.1.0",
"version": "5.3.0",
"homepage": "https://woocommerce.com/",
"repository": {
"type": "git",

View File

@ -1,7 +1,7 @@
=== WooCommerce ===
Contributors: automattic, mikejolley, jameskoster, claudiosanches, rodrigosprimo, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, wpmuguru, royho
Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, downloads, payments, paypal, storefront, stripe, woo commerce
Requires at least: 5.4
Requires at least: 5.5
Tested up to: 5.7
Requires PHP: 7.0
Stable tag: 5.1.0
@ -160,6 +160,139 @@ WooCommerce comes with some sample data you can use to see how products look; im
== Changelog ==
= 5.2.0 2021-04-xx =
= 5.2.0 beta 2021-03-23 =
**WooCommerce**
* Update - WooCommerce Blocks package 4.7.0. #29406
* Update - WooCommerce Admin package 2.1.3. #29283
* Add - Filter woocommerce_product_recount_terms to allow/prevent recounting of product terms. #29281
* Add - Result return array to the checkout_place_order_success callback to allow 3rd party to manipulate results. #29232
* Dev - Fix miscellaneous typos in docblocks. #29285
* Dev - Added woocommerce_ajax_order_items_removed hook. #29241
* Dev - Fix usage of docker-compose (wc-e2e) commands in e2e tests when running them within WSL2. #29207
* Dev - Fixes to documentation of WC_Shipping_Rate. #29117
* Dev - Add tracks event when a user clicks on the links of the WooCommerce Status widget. #29109
* Dev - Track the number of installations of WooCommerce Payments via that extensions banner for stores that have opted in to tracking. #29052
* Dev - Added woocommerce_ajax_order_items_removed hook. #28936
* Dev - Add tracking of woocommerce_admin_disabled usage. #28535
* Enhancement - Add support for the low stock threshold for variations. #29345
* Enhancement - Clean up of major version update compatibility warnings. #29200
* Enhancement - Add a new dashboard widget to promote users to finish onboarding tasks. #29174
* Enhancement - Update the Woo widget net sales link and logic to use the new analytics page and data. #29149
* Enhancement - Added the body class woocommerce-shop to the shop page, so that it can be targeted via CSS. (#28724). #29051
* Enhancement - Make sure downloadable file paths are properly recognized for strengthened security. #28699
* Enhancement - Delay the registration of data exporters and erasers to avoid multiple language files from being loaded. #28078
* Fix - Offsets not calculated correctly sometimes on select2 dropdowns causing usability issues. #29397
* Fix - Handle errors in fault installations of PHP Intl. #29391
* Fix - Cart page calculate shipping fields not showing correct fields based on location. #29282
* Fix - Product categories widget item count not always showing the correct number. #29281
* Fix - Updated include/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php to include a item schema function which appends support for order and class type values. #29218
* Fix - Check if variation_id if belongs to the parent product while adding products to the cart. #29208
* Fix - Reduce the number of ajax calls used when Geolocation (with Page Caching Enabled) mode is enabled. #29182
* Fix - Don't display the coupon form on checkouts requiring the customer to be logged in to checkout. #29151
* Fix - If coupon_lines are specified within a REST API order update, return an error if coupon item IDs are also specified. #29146
* Fix - Avoids duplicating the word '(optional)' in the context of the Billing Address 2 field. #29136
* Fix - PHP notice when checking out. #29133
* Fix - Remove duplicate containers from the single and archive product pages. #29121
* Fix - Wrong taxonomy caching in term and product attributes controllers. #29115
* Fix - Make the parameters of the refund creation REST API behave as documented. #29099
* Fix - Shipping methods with similar names could cause shipping method not selectable in order page. #29049
* Fix - WC_Countries::get_formatted_address() not returning full name in correct order in some languages. #29008
* Fix - add validation of the posted country codes on checkout. #28849
* Fix - Correctly display pagination arrows on RTL languages. #28523
* Fix - Invalid refund amount error on $0 refund when number of decimals is equal to 0. #27277
* Tweak - Added the Mercado Pago logo into the assets/images folder in order to use it in the payments setup task. #29365
* Tweak - Update the contributor guidelines. #29150
* Tweak - Introduced phone number input validation. #27242
**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3**
* Add - Add navigation intro modal. #6367
* Add - CES track settings tab on updating settings #6368
* Add - Core settings redirection to new settings pages #6091
* Add - Favorites tooltip to the navigation #6312
* Add - Favoriting extensions client UI #6287
* Add - Remove CES actions for adding and editing a product and editing an order #6355
* Add - Settings client pages #6092
* Add - Settings feature and pages #6089
* Dev - Add filter to allow enabling the WP toolbar within the new navigation. #6371
* Dev - Add navigation favorites data store #6275
* Dev - Add unit tests to Navigation's Container component. #6344
* Dev - Allow highlight tooltip to use body tag as parent. #6309
* Dev - Change `siteUrl` to `homeUrl` on navigation site title #6240
* Dev - Fix the react state update error on homescreen. #6320
* Dev - Refactor head and body heights #6247
* Dev - Remove Google fonts and material icons. #6343
* Dev - Use box sizing and padding to fix nav and admin menu styling #6335
* Enhancement - Move capability checks to client #6365
* Enhancement - Move favorited menu items to primary menu #6290
* Enhancement - Navigation: Add test to container component #6344
* Enhancement - override wpbody styles when nav present #6354
* Feature - Increase target audience for business feature step. #6508
* Fix - Add check for navigating being enabled. #6462
* Fix - Add customer name column to CSV export #6556
* Fix - Add guard to "Deactivate Plugin" note handlers to prevent fatal error. #6532
* Fix - Broken link anchors to online documentation. #6455
* Fix - Check if tax was successfully added before displaying notice #6229
* Fix - Correct a bug where the JP connection flow would not happen when installing JP in the OBW. #6521
* Fix - Crash of Analytics > Settings page when Gutenberg is installed. #6540
* Fix - Display" option fails to collapse upon invoking "Help" option #6233
* Fix - Email notes now are turned off by default #6324
* Fix - Empty nav menu #6366
* Fix - Enqueue scripts called incorrectly in php unit tests #6358
* Fix - Hide tooltip in welcome modal #6142
* Fix - Recommended Payment Banner missing in Safari #6375
* Fix - Removal of core settings pages #6328
* Fix - Removed @woocommerce/components/card from OBW #6374
* Fix - Reset Navigation submenu before making Flyout #6396
* Fix - Restore missing Correct the Klarna slug #6440
* Fix - Top bar slightly overlaps wp-admin navigation on mobile #6292
* Fix - update single column home screen width to 680px #6297
* Fix - Update timing of InboxPanel state changes for the unread indicator #6246
* Tweak - Enqueue beta features scripts on enqueue_scripts action instead of filter #6358
* Tweak - Move admin menu manipulation from admin_head to admin_menu #6310
* Tweak - Navigation: Migrate methods to `admin_menu` hook #6319
* Tweak - New Settings: Turn off in dev mode #6348
* Tweak - Order and styles updates to nav footer #6373
* Tweak - Remove categories without menu items #6329
* Tweak - Set `is_deleted` from the database when instantiating a `Note` #6322
* Tweak - Update inline documentation for navigation Screen class #6173
* Tweak - Updates to copy and punctuation to be more conversational and consistent. #6298
**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0**
* Enhancement - Login links on the checkout should use the account page. ([3844](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3844))
* Enhancement - Prevent checkout linking to trashed terms and policy pages. ([3843](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3843))
* Enhancement - Improved nonce logic by moving nonces to cart routes only. ([3812](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3812))
* Enhancement - If coupons become invalid between applying to a cart and checking out, show the user a notice when the order is placed. ([3810](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3810))
* Enhancement - Improve design of cart and checkout sidebars. ([3797](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3797))
* Enhancement - Improve error displayed to customers when an item's stock status changes during checkout. ([3703](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3703))
* Enhancement - Dev - Block Checkout will now respect custom address locales and custom country states via core filter hooks. ([3662](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3662))
* Enhancement - Update checkout block payment methods UI. ([3439](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3439))
* Enhancement - StoreAPI: Inject Order and Cart Controllers into Routes. ([3871](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3871))
* Enhancement - Update Panel component class names to follow guidelines. More info can be found in our theming docs: https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/18dd54f07262b4d1dcf15561624617f824fcdc22/docs/theming/class-names-update-460.md. ([3860](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3860))
* Enhancement - Refactor block type registration to support 3rd party integrations.
* Enhancement - A new configuration property is available to registered payment methods for additional logic handling of saved payment method tokens. ([3961](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3961))
* Enhancement - Provided billing data to payment method extensions so they can decide if payment is possible. ([3922](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3922))
* Enhancement - Prevent errant payment methods from keeping Cart and Checkout blocks from loading. ([3920](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3920))
* Fix block elements that don't play well with dark backgrounds. ([3887](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3887))
* Fix - JS warning if two cart products share the same name. ([3814](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3814))
* Fix - Align place order button to the right of the block. ([3803](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3803))
* Fix - Ensure special characters are displayed properly in the Cart sidebar. ([3721](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3721))
* Fix - Bug where the total price of items did not include tax in the cart and checkout blocks. ([3851](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3851))
* Fix - Handle out-of-stock product visibility setting in All Products block. ([3859](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3859))
* Fix - Show cart item subtotal instead of total in Cart and Checkout blocks ([#3905](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3905))
* Fix - Fix button styles in Twenty Nineteen theme. ([3862](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3862))
* Fix - Return correct sale/regular prices for variable products in the Store API. ([3854](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3854))
* Fix - Remove shadows from text buttons and gradient background from selects in some themes. ([3846](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3846))
* Fix - Hide Browse Shop link in cart block empty state when there is no shop page. ([3845](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3845))
* Fix - Remove extra padding from payment methods with no description. ([3952](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3952))
* Fix - "save payment" checkbox not showing for payment methods. ([3950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3950))
* Fix - Cart preview when shipping rates are set to be hidden until an address is entered. ([3946](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3946))
* Fix - Sync cart item quantity if its Implicitly changed. ([3907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3907))
* Fix - FSE not being visible when WC Blocks was enabled. ([3898](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3898))
* Fix - Ensure sale badges have a uniform height in the Cart block. ([3897](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3897))
* Note - Internally, this release has modified how `AbstractBlock` (the base class for all of our blocks) functions, and how it loads assets. `AbstractBlock` is internal to this project and does not seem like something that would ever need to be extended by 3rd parties, but note if you are doing so for whatever reason, your implementation would need to be updated to match. ([3829](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3829))
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/changelog.txt).

View File

@ -2,7 +2,6 @@
This document discusses unit tests. See [the e2e README](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e) to learn how to setup testing environment for running e2e tests and run them.
## Table of contents
- [WooCommerce Tests](#woocommerce-tests)
@ -51,7 +50,6 @@ Example:
**Important**: The `<db-name>` database will be created if it doesn't exist and all data will be removed during testing.
## Running Tests
Change to the plugin root directory and type:
@ -78,9 +76,9 @@ WooCommerce currently supports PHP versions from 7.0 up to 8.0, and this poses a
To workaround this, the testing strategy used by WooCommerce is as follows:
* We normally use PHPUnit 6.5.14
* For PHP 8 we use [a custom fork of PHPUnit 7.5.20 with support for PHP 8](https://github.com/woocommerce/phpunit/pull/1). The Travis build is configured to use this fork instead of the old version 6 when running in PHP 8.
* For PHP 8 we use [a custom fork of PHPUnit 7.5.20 with support for PHP 8](https://github.com/woocommerce/phpunit/pull/1). WooCommerce's GitHub Actions CI workflow is configured to use this fork instead of the old version 6 when running in PHP 8.
If you want to run the tests locally under PHP 8 you'll need to temporarily modify `composer.json` to use the custom PHPUnit fork in the same way that the Travis setup script does. These are the commands that you'll need (run them after a regular `composer install`):
If you want to run the tests locally under PHP 8 you'll need to temporarily modify `composer.json` to use the custom PHPUnit fork in the same way that the GitHub Actions CI workflow file does. These are the commands that you'll need (run them after a regular `composer install`):
```shell
curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip
@ -92,7 +90,6 @@ composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-req
Just remember that you can't include the modified `composer.json` in any commit!
## Writing Tests
There are three different unit test directories:
@ -122,12 +119,10 @@ General guidelines for all the unit tests:
* 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
Tests are automatically run with [Travis-CI](https://travis-ci.org/woocommerce/woocommerce) for each commit and pull request.
Tests are automatically run with [GitHub Actions](https://github.com/woocommerce/woocommerce/actions/workflows/ci.yml) for each commit and pull request.
## Code Coverage
Code coverage is available on [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 build.

View File

@ -1,11 +1,14 @@
#!/usr/bin/env bash
if [[ ${RUN_PHPCS} == 1 ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,includes/libraries/,includes/api/legacy/"
COMMIT_RANGE="${1}...${2}"
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,includes/libraries/,includes/api/legacy/"
if [ "$CHANGED_FILES" != "" ]; then
echo "Running Code Sniffer."
vendor/bin/phpcs --ignore=$IGNORE --encoding=utf-8 -s -n -p $CHANGED_FILES
fi
if [ "$CHANGED_FILES" != "" ]; then
echo "Changed files: $CHANGED_FILES"
echo "Running Code Sniffer."
./vendor/bin/phpcs --ignore=$IGNORE --encoding=utf-8 -s -n -p --report-full --report-checkstyle=./phpcs-report.xml ${CHANGED_FILES}
else
echo "No changes found. Skipping PHPCS run."
fi

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
# usage: travis.sh before|after
if [ $1 == 'after' ]; then
if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then
bash <(curl -s https://codecov.io/bash)
wget https://scrutinizer-ci.com/ocular.phar
chmod +x ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi
fi

View File

@ -55,7 +55,7 @@ This section explains how e2e tests are working behind the scenes. These are not
### 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 mapped into the `plugins` folder of that newly built test site.
We recommend using Docker for running tests locally in order for the test environment to match the setup on Github 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 mapped into the `plugins` folder of that newly built test site.
### Test Variables
@ -77,13 +77,13 @@ The jest test sequencer uses the following test variables:
}
```
If you need to modify the port for your local test environment (eg. port is already in use), copy `tests/e2e/env/config/default.json` to `tests/e2e/config/default.json` and edit that copy. Only edit this file while your test container is `down`.
If you need to modify the port for your local test environment (eg. port is already in use), edit `tests/e2e/config/default.json`. Only edit this file while your test container is `down`.
### Jest test sequencer
[Jest](https://jestjs.io/) is being used to run e2e tests. 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. 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](https://jestjs.io/) is being used to run e2e tests. 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 directory `activate-and-setup` will run first. 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).
The Setup Wizard e2e test (located in `activate-and-setup` directory) will run first. This ensures that WooCommerce is active and the setup wizard has been completed. This is necessary because `docker:up` creates a brand new install of WordPress and WooCommerce.
The Setup Wizard e2e test runs first to ensure that WooCommerce is active and that the setup wizard has been completed. This is necessary because `docker:up` creates a brand new install of WordPress and WooCommerce.
### Chromium Download
@ -99,23 +99,25 @@ Puppeteer will still automatically download Chromium when needed.
### Prep work for running tests
Run the following in a terminal/command line window
- `cd` to the WooCommerce plugin folder
- `git checkout trunk` or checkout the branch where you need to run tests
- `git checkout trunk` (or the branch where you need to run tests)
- Run `nvm use`
- `nvm use`
- Run `npm install`
- `npm install`
- Run `composer install --no-dev`
- `composer install --no-dev`
- Run `npm run build:assets`
- `npm run build:assets`
- Run `npm install jest --global` (this only needs to be done once)
- `npm install jest --global` (this only needs to be done once)
- Run `npx wc-e2e docker:up` - it will build the test site using Docker.
- `npx wc-e2e docker:up` (this will build the test site using Docker)
- Run `docker ps` - to confirm that the Docker containers are running. You should see the log that looks similar to below indicating that everything had been built as expected:
- Use `docker ps` to confirm that the Docker containers are running. You should see a log similar to one below indicating that everything had been built as expected:
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -305,7 +307,7 @@ describe( 'Merchant can create virtual product', () => {
} );
```
Next, you can start filling up each section with relevant functions (test building blocks). Note, that we have the `@woocommerce/e2e-utils` package where many reusable helper functions can be found for writing tests. For example, `flows.js` of `@woocommerce/e2e-utils` package contains `merchant` object that has `login` method. As a result, in the test it can be used as `await merchant.login();` so the first `it()` section of the test will become:
Next, you can start filling up each section with relevant functions (test building blocks). Note, that we have the `@woocommerce/e2e-utils` package where many reusable helper functions can be found for writing tests. For example, `merchant.js` of `@woocommerce/e2e-utils` package contains `merchant` object that has `login` method. As a result, in the test it can be used as `await merchant.login();` so the first `it()` section of the test will become:
```
it( 'merchant can log in', async () => {
@ -327,7 +329,7 @@ it( 'merchant can create virtual product', async () => {
You would then continue writing the test using utilities where possible.
Make sure to utilize the functions of the `@automattic/puppeteer-utils` package where possible. For example, if you need to wait for certain element to be ready to be clicked on and then click on it, you can use `waitAndClick()` function:
Make sure to utilize the functions of the `@automattic/puppeteer-utils` package where possible. For example, if you need to wait for a certain element to be ready to be clicked on and then click on it, you can use `waitAndClick()` function:
```
await waitAndClick( page, '#selector' );
@ -351,4 +353,6 @@ In the example above, you can see that `allows customer to see downloads` part o
## Debugging tests
The test sequencer (`npx wc-e2e test:e2e`) includes support for saving [screenshots on test errors](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#test-screenshots) which can be sent to a Slack channel via a [Slackbot](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#slackbot-setup).
For Puppeteer debugging, follow [Google's documentation](https://developers.google.com/web/tools/puppeteer/debugging).

View File

@ -49,11 +49,19 @@ httpClient.get( '/wc/v3/products' ).then( ( response ) => {
### Repositories
As a convenience utility we've created repositories for core data types that can simplify interacting with the API.
As a convenience utility we've created repositories for core data types that can simplify interacting with the API:
- `SimpleProduct`
- `ExternalProduct`
- `GroupedProduct`
- `VariableProduct`
- `ProductVariation`
- `Coupon`
These repositories provide CRUD methods for ease-of-use:
```javascript
import { SimpleProduct } from '@woocommerce/api';
import { HTTPClientFactory, SimpleProduct } from '@woocommerce/api';
// Prepare the HTTP client that will be consumed by the repository.
// This is necessary so that it can make requests to the REST API.
@ -68,5 +76,86 @@ const product = repository.create( { name: 'Simple Product', regularPrice: '9.99
// The response will be one of the models with structured properties and TypeScript support.
product.id;
```
#### Repository Methods
The following methods are available on all repositories:
- `create( {...properties} )` - Create a single object of the model type
- `delete( objectId )` - Delete a single object of the model type
- `list` - Retrieve a list of the existing objects of that model type
- `read( objectId )` - Read a single object of the model type
- `update( objectId, {...properties} )` - Update a single object of the model type
#### Child Repositories
`ProductVariation` is a child model repository. In child model repositories, each method requires the `parentId` as the first parameter:
```javascript
import { HTTPClientFactory, VariableProduct, ProductVariation } from '@woocommerce/api';
const httpClient = HTTPClientFactory.build( 'https://example.com' )
.withBasicAuth( 'username', 'password' )
.withIndexPermalinks()
.create();
const productRepository = VariableProduct.restRepository( httpClient );
const variationRepository = ProductVariation.restRepository( httpClient );
const product = await productRepository.create({
"name": "Variable Product with Three Attributes",
"defaultAttributes": [
{
"id": 0,
"name": "Size",
"option": "Medium"
},
{
"id": 0,
"name": "Colour",
"option": "Blue"
}
],
"attributes": [
{
"id": 0,
"name": "Colour",
"isVisibleOnProductPage": true,
"isForVariations": true,
"options": [
"Red",
"Green",
"Blue"
],
"sortOrder": 0
},
{
"id": 0,
"name": "Size",
"isVisibleOnProductPage": true,
"isForVariations": true,
"options": [
"Small",
"Medium",
"Large"
],
"sortOrder": 0
}
]
});
const variation = await variationRepository.create( product.id, {
"regularPrice": "19.99",
"attributes": [
{
"name": "Size",
"option": "Large"
},
{
"name": "Colour",
"option": "Red"
}
]
});
```

View File

@ -45,21 +45,22 @@ The functions to access the core tests are:
### Merchant
- `runMerchantTests` - Run all merchant tests
- `runCreateCouponTest` - Merchant can create coupon
- `runCreateOrderTest` - Merchant can create order
- `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them
- `runAddSimpleProductTest` - Merchant can create a simple product
- `runAddVariableProductTest` - Merchant can create a variable product
- `runUpdateGeneralSettingsTest` - Merchant can update general settings
- `runProductSettingsTest` - Merchant can update product settings
- `runTaxSettingsTest` - Merchant can update tax settings
- `runCreateCouponTest` - Merchant can create coupon
- `runCreateOrderTest` - Merchant can create order
- `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page
- `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions
- `runOrderStatusFilterTest` - Merchant can filter orders by order status
- `runOrderRefundTest` - Merchant can refund an order
- `runOrderApplyCouponTest` - Merchant can apply a coupon to an order
- `runOrderSearchingTest` - Merchant can search for order via different terms
- `runProductEditDetailsTest` - Merchant can edit an existing product
- `runProductSearchTest` - Merchant can search for a product and view it
- `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page
- `runOrderSearchingTest` - Merchant can search for order via different terms
- `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them
- `runProductSettingsTest` - Merchant can update product settings
- `runTaxSettingsTest` - Merchant can update tax settings
- `runUpdateGeneralSettingsTest` - Merchant can update general settings
- `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions
### Shopper
@ -70,13 +71,20 @@ The functions to access the core tests are:
- `runCheckoutApplyCouponsTest` - Shopper can use coupons on checkout
- `runCheckoutPageTest` - Shopper can complete checkout
- `runMyAccountPageTest` - Shopper can access my account page
- `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped)
- `runMyAccountPayOrderTest` - Shopper can pay for his order in My Account
- `runCartApplyCouponsTest` - Shopper can apply coupons in the cart
- `runCheckoutApplyCouponsTest` - Shopper can apply coupons in the checkout
- `runMyAccountPayOrderTest` - Shopper can pay for their order in My Account
- `runProductBrowseSearchSortTest` - Shopper can browse, search & sort products
- `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped)
- `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product
### REST API
- `runApiTests` - Run all API tests
- `runExternalProductAPITest` - Can create, read, and delete an external product
- `runGroupedProductAPITest` - Can create, read, and delete a grouped product
- `runVariableProductAPITest` - Can create, read, and delete a variable product and its variations
- `runCouponApiTest` - Can create, read, and delete a coupon
## Contributing a new test
- In your branch create a new `example-test-name.test.js` under the `tests/e2e/core-tests/specs` folder.

View File

@ -2,13 +2,16 @@
echo "Initializing WooCommerce E2E"
wp plugin install woocommerce --activate
wp plugin activate woocommerce
wp theme install twentynineteen --activate
wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=customer --path=/var/www/html
# we cannot create API keys for the API, so we using basic auth, this plugin allows that.
wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate
# install the WP Mail Logging plugin to test emails
wp plugin install wp-mail-logging --activate
echo "Updating to WordPress Nightly Point Release"
wp plugin install wordpress-beta-tester --activate

View File

@ -11,7 +11,7 @@ npm install jest --global
## Configuration
The `@woocommerce/e2e-environment` package exports configuration objects that can be consumed in JavaScript config files in your project. Additionally, it includes a hosting container for running tests and includes instructions for creating your Travis CI setup.
The `@woocommerce/e2e-environment` package exports configuration objects that can be consumed in JavaScript config files in your project. Additionally, it includes a basic hosting container for running tests and includes instructions for creating your Travis CI setup.
### Babel Config
@ -56,7 +56,7 @@ module.exports = useE2EEsLintConfig( {
### Jest Config
The E2E environment uses Jest as a test runner. Extending the base config is needed in order for Jest to run your project's test files.
The E2E environment uses Jest as a test runner. Extending the base config is necessary in order for Jest to run your project's test files.
```js
const path = require( 'path' );
@ -69,7 +69,7 @@ const jestConfig = useE2EJestConfig( {
module.exports = jestConfig;
```
**NOTE:** Your project's Jest config file is expected to be: `tests/e2e/config/jest.config.js`.
**NOTE:** Your project's Jest config file is: `tests/e2e/config/jest.config.js`.
#### Test Screenshots
@ -79,7 +79,7 @@ The test sequencer provides a screenshot function for test failures. To enable s
WC_E2E_SCREENSHOTS=1 npx wc-e2e test:e2e
```
Screenshots will be saved to `tests/e2e/screenshots`
Screenshots will be saved to `tests/e2e/screenshots`. This folder is cleared at the beginning of each test run.
### Jest Puppeteer Config
@ -125,11 +125,11 @@ module.exports = puppeteerConfig;
### Jest Setup
Jest provides setup and teardown functions similar to PHPUnit. The default setup and teardown is in [`tests/e2e/env/src/setup/jest.setup.js`](src/setup/jest.setup.js). Additional setup and teardown functions can be added to [`tests/e2e/config/jest.setup.js`](../config/jest.setup.js)
Jest provides [setup and teardown functions](https://jestjs.io/docs/setup-teardown) similar to PHPUnit. The default setup and teardown is in [`tests/e2e/env/src/setup/jest.setup.js`](src/setup/jest.setup.js). Additional setup and teardown functions can be added to [`tests/e2e/config/jest.setup.js`](../config/jest.setup.js)
### Container Setup
Depending on the project and testing scenario, the built in testing environment container might not be the best solution for testing. This could be local testing where there is already a testing container, a repository that isn't a plugin or theme and there are multiple folders mapped into the container, or similar. The `e2e-environment` container supports using either the built in container or an external container. See the the appropriate readme for details:
Depending on the project and testing scenario, the built in testing environment container might not be the best solution for testing. This could be local testing where there is already a testing container, a repository that isn't a plugin or theme and there are multiple folders mapped into the container, or similar. The `e2e-environment` test runner supports using either the built in container or an external container. See the appropriate readme for details:
- [Built In Container](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env/builtin.md)
- [External Container](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env/external.md)

View File

@ -34,6 +34,35 @@ echo "Initializing WooCommerce E2E"
wp plugin activate woocommerce
wp theme install twentynineteen --activate
```
### Adhoc Initialization
The container build script supports an initialization script parameter
```shell script
npx wc-e2e docker:up tests/e2e/docker/init-wp-beta.sh
```
This script updates WordPress to the latest nightly point release
```shell script
#!/bin/bash
echo "Initializing WooCommerce E2E"
wp plugin install woocommerce --activate
wp theme install twentynineteen --activate
wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=customer --path=/var/www/html
# we cannot create API keys for the API, so we using basic auth, this plugin allows that.
wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate
echo "Updating to WordPress Nightly Point Release"
wp plugin install wordpress-beta-tester --activate
wp core check-update
```
### Container Configuration

View File

@ -66,7 +66,7 @@ version: ~> 1.0
script:
- npm install jest --global
# add your initialization script here
- npm explore @woocommerce/e2e-environment -- npm run test:e2e
- npx wc-e2e test:e2e
....

View File

@ -21,9 +21,7 @@ import {
describe( 'Cart page', () => {
beforeAll( async () => {
await merchant.login();
await createSimpleProduct();
await merchant.logout();
} );
it( 'should display no item in the cart', async () => {
@ -85,20 +83,33 @@ describe( 'Cart page', () => {
| Function | Parameters | Description |
|----------|------------|-------------|
| `addProductToOrder` | `orderId, productName` | adds a product to an order using the product search |
| `applyCoupon` | `couponName` | helper method which applies a coupon in cart or checkout |
| `clearAndFillInput` | `selector, value` | Replace the contents of an input with the passed value |
| `clickFilter` | `selector` | helper method that clicks on a list page filter |
| `clickTab` | `tabName` | Click on a WooCommerce -> Settings tab |
| `createCoupon` | `couponAmount` | creates a basic coupon. Default amount is 5. Returns the generated coupon code. |
| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |
| `completeOnboardingWizard` | | completes the onboarding wizard with some default settings |
| `createCoupon` | `couponAmount`, `couponType` | creates a basic coupon. Default amount is 5. Default coupon type is fixed discount. Returns the generated coupon code. |
| `createGroupedProduct` | | creates a grouped product for the grouped product tests. Returns the product id. |
| `createSimpleOrder` | `status` | creates a basic order with the provided status string |
| `createSimpleProduct` | | creates the simple product configured in default.json. Returns the product id. |
| `createSimpleProductWithCategory` | `name`, `price`,`categoryName` | creates a simple product used passed values. Returns the product id. |
| `createVariableProduct` | | creates a variable product for the variable product tests. Returns the product id. |
| `deleteAllEmailLogs` | | deletes the emails generated by WP Mail Logging plugin |
| `evalAndClick` | `selector` | helper method that clicks an element inserted in the DOM by a script |
| `moveAllItemsToTrash` | | helper method that checks every item in a list page and moves them to the trash |
| `settingsPageSaveChanges` | | Save the current WooCommerce settings page |
| `permalinkSettingsPageSaveChanges` | | Save the current Permalink settings |
| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |
| `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside |
| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |
| `setCheckbox` | `selector` | Check a checkbox |
| `unsetCheckbox` | `selector` | Uncheck a checkbox |
| `settingsPageSaveChanges` | | Save the current WooCommerce settings page |
| `uiUnblocked` | | Wait until the page is unblocked |
| `verifyPublishAndTrash` | `button, publishNotice, publishVerification, trashVerification` | Verify that an item can be published and trashed |
| `unsetCheckbox` | `selector` | Uncheck a checkbox |
| `verifyAndPublish` | `noticeText` | Verify that an item can be published |
| `verifyCheckboxIsSet` | `selector` | Verify that a checkbox is checked |
| `verifyCheckboxIsUnset` | `selector` | Verify that a checkbox is unchecked |
| `verifyPublishAndTrash` | `button, publishNotice, publishVerification, trashVerification` | Verify that an item can be published and trashed |
| `verifyValueOfInputField` | `selector, value` | Verify an input contains the passed value |
| `clickFilter` | `selector` | Click on a list page filter |
| `moveAllItemsToTrash` | | Moves all items in a list view to the Trash |
@ -113,4 +124,4 @@ describe( 'Cart page', () => {
### Test Utilities
As of version 0.1.2, all test utilities from [`@wordpress/e2e-test-utils`](https://www.npmjs.com/package/@wordpress/e2e-test-utils) are available through this package.
As of version 0.1.3, all test utilities from [`@wordpress/e2e-test-utils`](https://www.npmjs.com/package/@wordpress/e2e-test-utils) are available through this package.

View File

@ -3,12 +3,12 @@
* Plugin Name: WooCommerce
* Plugin URI: https://woocommerce.com/
* Description: An eCommerce toolkit that helps you sell anything. Beautifully.
* Version: 5.2.0-dev
* Version: 5.3.0-dev
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woocommerce
* Domain Path: /i18n/languages/
* Requires at least: 5.4
* Requires at least: 5.5
* Requires PHP: 7.0
*
* @package WooCommerce