Merge branch 'trunk' into fix/29540
This commit is contained in:
commit
98901dc9ec
|
@ -0,0 +1,30 @@
|
|||
name: Build release zip file
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: 'By default the zip file is generated from the branch the workflow runs from, but you can specify an explicit reference to use instead here (e.g. refs/tags/tag_name). The resulting file will be available as an artifact on the workflow run.'
|
||||
required: false
|
||||
default: ''
|
||||
jobs:
|
||||
build:
|
||||
name: Build release zip file
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref || github.ref }}
|
||||
- name: Build the zip file
|
||||
id: build
|
||||
uses: woocommerce/action-build@v2
|
||||
- name: Unzip the file (prevents double zip problem)
|
||||
run: unzip ${{ steps.build.outputs.zip_path }} -d zipfile
|
||||
- name: Upload the zip file as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
name: woocommerce
|
||||
path: zipfile
|
||||
retention-days: 7
|
|
@ -4,7 +4,7 @@ on:
|
|||
- cron: '25 3 * * *'
|
||||
jobs:
|
||||
login-run:
|
||||
name: Log into smoke test site.
|
||||
name: Daily smoke test on trunk.
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
|
||||
|
@ -18,21 +18,26 @@ jobs:
|
|||
- name: Checkout code.
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: package/woocommerce
|
||||
ref: trunk
|
||||
|
||||
- name: Run npm install.
|
||||
working-directory: package/woocommerce
|
||||
run: npm install
|
||||
- name: Install prerequisites.
|
||||
run: |
|
||||
npm install
|
||||
composer install --no-dev
|
||||
npm run build:assets
|
||||
npm install jest
|
||||
|
||||
- name: Move current directory to code. We will install zip file in this dir later.
|
||||
run: mv ./package/woocommerce/* ./code/woocommerce
|
||||
|
||||
- name: Run login test.
|
||||
working-directory: code/woocommerce
|
||||
- name: Run smoke test.
|
||||
env:
|
||||
SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }}
|
||||
SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
|
||||
SMOKE_TEST_ADMIN_PASSWORD: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }}
|
||||
SMOKE_TEST_CUSTOMER_USER: ${{ secrets.SMOKE_TEST_CUSTOMER_USER }}
|
||||
SMOKE_TEST_CUSTOMER_PASSWORD: ${{ secrets.SMOKE_TEST_CUSTOMER_PASSWORD }}
|
||||
run: npx wc-e2e test:e2e ./tests/e2e/specs/activate-and-setup/test-activation.js
|
||||
WC_E2E_SCREENSHOTS: 1
|
||||
E2E_RETEST: 1
|
||||
E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }}
|
||||
E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }}
|
||||
run: |
|
||||
npx wc-e2e docker:up
|
||||
npx wc-e2e test:e2e
|
||||
|
|
|
@ -18,4 +18,3 @@ jobs:
|
|||
only-issue-labels: 'needs feedback'
|
||||
close-issue-label: "category: can't reproduce"
|
||||
ascending: true
|
||||
debug-only: true
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
== Changelog ==
|
||||
|
||||
= 5.2.2 2021-04-15 =
|
||||
|
||||
**WooCommerce**
|
||||
|
||||
* Fix - Can't grant permission for download from order details page. #29691
|
||||
|
||||
= 5.2.1 2021-04-14 =
|
||||
|
||||
**WooCommerce**
|
||||
|
||||
* Update - WooCommerce Blocks package 4.7.2. #29660
|
||||
|
||||
**WooCommerce Blocks - 4.7.2**
|
||||
|
||||
* Fix - Check if Cart and Checkout are registered before removing payment methods. ([4056](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4056))
|
||||
|
||||
= 5.2.0 2021-04-13 =
|
||||
|
||||
**WooCommerce**
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
"pelago/emogrifier": "3.1.0",
|
||||
"psr/container": "1.0.0",
|
||||
"woocommerce/action-scheduler": "3.1.6",
|
||||
"woocommerce/woocommerce-admin": "2.1.5",
|
||||
"woocommerce/woocommerce-blocks": "4.7.1"
|
||||
"woocommerce/woocommerce-admin": "2.2.1",
|
||||
"woocommerce/woocommerce-blocks": "4.9.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.4"
|
||||
|
|
|
@ -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": "5005eed74baf10300e2895e9b6a4f344",
|
||||
"content-hash": "11158f53934e897bd84be190a184ec87",
|
||||
"packages": [
|
||||
{
|
||||
"name": "automattic/jetpack-autoloader",
|
||||
|
@ -51,9 +51,6 @@
|
|||
"GPL-2.0-or-later"
|
||||
],
|
||||
"description": "Creates a custom autoloader for a plugin or theme.",
|
||||
"support": {
|
||||
"source": "https://github.com/Automattic/jetpack-autoloader/tree/2.10.1"
|
||||
},
|
||||
"time": "2021-03-30T15:15:59+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -85,9 +82,6 @@
|
|||
"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"
|
||||
},
|
||||
{
|
||||
|
@ -218,10 +212,6 @@
|
|||
"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",
|
||||
|
@ -296,10 +286,6 @@
|
|||
"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"
|
||||
},
|
||||
{
|
||||
|
@ -374,10 +360,6 @@
|
|||
"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"
|
||||
},
|
||||
{
|
||||
|
@ -427,10 +409,6 @@
|
|||
"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"
|
||||
},
|
||||
{
|
||||
|
@ -484,9 +462,6 @@
|
|||
],
|
||||
"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"
|
||||
},
|
||||
{
|
||||
|
@ -522,24 +497,20 @@
|
|||
],
|
||||
"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.1.5",
|
||||
"version": "2.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/woocommerce/woocommerce-admin.git",
|
||||
"reference": "71c233d8463f551430edbe1877e51d19a4bb2df6"
|
||||
"reference": "78cc9c5ef7de5be5bd0f9208483e5ae97422be9a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/71c233d8463f551430edbe1877e51d19a4bb2df6",
|
||||
"reference": "71c233d8463f551430edbe1877e51d19a4bb2df6",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/78cc9c5ef7de5be5bd0f9208483e5ae97422be9a",
|
||||
"reference": "78cc9c5ef7de5be5bd0f9208483e5ae97422be9a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -571,24 +542,20 @@
|
|||
],
|
||||
"description": "A modern, javascript-driven WooCommerce Admin experience.",
|
||||
"homepage": "https://github.com/woocommerce/woocommerce-admin",
|
||||
"support": {
|
||||
"issues": "https://github.com/woocommerce/woocommerce-admin/issues",
|
||||
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.1.5"
|
||||
},
|
||||
"time": "2021-04-02T16:48:38+00:00"
|
||||
"time": "2021-04-02T19:30:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "woocommerce/woocommerce-blocks",
|
||||
"version": "v4.7.1",
|
||||
"version": "v4.9.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
|
||||
"reference": "841c49b8626f4eb717056a2d1e3eba6140f45e2c"
|
||||
"reference": "62f32bfb45dfcb2ba3ca349a6ed0a8cf48ddefce"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/841c49b8626f4eb717056a2d1e3eba6140f45e2c",
|
||||
"reference": "841c49b8626f4eb717056a2d1e3eba6140f45e2c",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/62f32bfb45dfcb2ba3ca349a6ed0a8cf48ddefce",
|
||||
"reference": "62f32bfb45dfcb2ba3ca349a6ed0a8cf48ddefce",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -624,9 +591,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues",
|
||||
"source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.7.1"
|
||||
"source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.9.1"
|
||||
},
|
||||
"time": "2021-04-02T11:18:50+00:00"
|
||||
"time": "2021-04-13T16:11:16+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
@ -674,10 +641,6 @@
|
|||
"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"
|
||||
}
|
||||
],
|
||||
|
@ -693,5 +656,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "7.0"
|
||||
},
|
||||
"plugin-api-version": "2.0.0"
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
|
|
@ -534,7 +534,7 @@ return array(
|
|||
'SO' => __( 'Sololá', 'woocommerce' ),
|
||||
'SU' => __( 'Suchitepéquez', 'woocommerce' ),
|
||||
'TO' => __( 'Totonicapán', 'woocommerce' ),
|
||||
'ZA' => __( 'Zacapa', 'woocommerce' ),
|
||||
'ZA' => __( 'Zacapa', 'woocommerce' )
|
||||
),
|
||||
'HK' => array( // Hong Kong states.
|
||||
'HONG KONG' => __( 'Hong Kong Island', 'woocommerce' ),
|
||||
|
@ -1296,28 +1296,7 @@ return array(
|
|||
),
|
||||
'PL' => array(),
|
||||
'PR' => array(),
|
||||
'PT' => array( // Portugal states. Ref: https://github.com/unicode-org/cldr/blob/release-38-1/common/subdivisions/en.xml#L4139-L4159
|
||||
'PT-01' => __( 'Aveiro', 'woocommerce' ),
|
||||
'PT-02' => __( 'Beja', 'woocommerce' ),
|
||||
'PT-03' => __( 'Braga', 'woocommerce' ),
|
||||
'PT-04' => __( 'Bragança', 'woocommerce' ),
|
||||
'PT-05' => __( 'Castelo Branco', 'woocommerce' ),
|
||||
'PT-06' => __( 'Coimbra', 'woocommerce' ),
|
||||
'PT-07' => __( 'Évora', 'woocommerce' ),
|
||||
'PT-08' => __( 'Faro', 'woocommerce' ),
|
||||
'PT-09' => __( 'Guarda', 'woocommerce' ),
|
||||
'PT-10' => __( 'Leiria', 'woocommerce' ),
|
||||
'PT-11' => __( 'Lisbon', 'woocommerce' ),
|
||||
'PT-12' => __( 'Portalegre', 'woocommerce' ),
|
||||
'PT-13' => __( 'Porto', 'woocommerce' ),
|
||||
'PT-14' => __( 'Santarém', 'woocommerce' ),
|
||||
'PT-15' => __( 'Setúbal', 'woocommerce' ),
|
||||
'PT-16' => __( 'Viana do Castelo', 'woocommerce' ),
|
||||
'PT-17' => __( 'Vila Real', 'woocommerce' ),
|
||||
'PT-18' => __( 'Viseu', 'woocommerce' ),
|
||||
'PT-20' => __( 'Azores', 'woocommerce' ),
|
||||
'PT-30' => __( 'Madeira', 'woocommerce' ),
|
||||
),
|
||||
'PT' => array(),
|
||||
'PY' => array( // Paraguay states.
|
||||
'PY-ASU' => __( 'Asunción', 'woocommerce' ),
|
||||
'PY-1' => __( 'Concepción', 'woocommerce' ),
|
||||
|
|
|
@ -172,7 +172,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) :
|
|||
*/
|
||||
private function populate_payment_tasks() {
|
||||
$is_woo_payment_installed = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' );
|
||||
$country = explode( ':', get_option( 'woocommerce_default_country', '' ) )[0];
|
||||
$country = explode( ':', get_option( 'woocommerce_default_country', 'US:CA' ) )[0];
|
||||
|
||||
// woocommerce-payments requires its plugin activated and country must be US.
|
||||
if ( ! $is_woo_payment_installed || 'US' !== $country ) {
|
||||
|
|
|
@ -81,7 +81,7 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
'title' => __( 'Country / State', 'woocommerce' ),
|
||||
'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_default_country',
|
||||
'default' => 'GB',
|
||||
'default' => 'US:CA',
|
||||
'type' => 'single_select_country',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
|
|
@ -139,14 +139,26 @@ class WC_Logger implements WC_Logger_Interface {
|
|||
}
|
||||
|
||||
if ( $this->should_handle( $level ) ) {
|
||||
$timestamp = current_time( 'timestamp', 1 );
|
||||
$message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context );
|
||||
$timestamp = time();
|
||||
|
||||
foreach ( $this->handlers as $handler ) {
|
||||
/**
|
||||
* Filter the logging message. Returning null will prevent logging from occuring since 5.3.
|
||||
*
|
||||
* @since 3.1
|
||||
* @param string $message Log message.
|
||||
* @param string $level One of: emergency, alert, critical, error, warning, notice, info, or debug.
|
||||
* @param array $context Additional information for log handlers.
|
||||
* @param object $handler The handler object, such as WC_Log_Handler_File. Available since 5.3.
|
||||
*/
|
||||
$message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context, $handler );
|
||||
|
||||
if ( null !== $message ) {
|
||||
$handler->handle( $timestamp, $level, $message, $context );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an emergency level message.
|
||||
|
|
|
@ -1270,7 +1270,7 @@ function wc_format_country_state_string( $country_string ) {
|
|||
* @return array
|
||||
*/
|
||||
function wc_get_base_location() {
|
||||
$default = apply_filters( 'woocommerce_get_base_location', get_option( 'woocommerce_default_country' ) );
|
||||
$default = apply_filters( 'woocommerce_get_base_location', get_option( 'woocommerce_default_country', 'US:CA' ) );
|
||||
|
||||
return wc_format_country_state_string( $default );
|
||||
}
|
||||
|
@ -1286,7 +1286,7 @@ function wc_get_base_location() {
|
|||
*/
|
||||
function wc_get_customer_default_location() {
|
||||
$set_default_location_to = get_option( 'woocommerce_default_customer_address', 'base' );
|
||||
$default_location = '' === $set_default_location_to ? '' : get_option( 'woocommerce_default_country', '' );
|
||||
$default_location = '' === $set_default_location_to ? '' : get_option( 'woocommerce_default_country', 'US:CA' );
|
||||
$location = wc_format_country_state_string( apply_filters( 'woocommerce_customer_default_location', $default_location ) );
|
||||
|
||||
// Geolocation takes priority if used and if geolocation is possible.
|
||||
|
|
18
readme.txt
18
readme.txt
|
@ -4,7 +4,7 @@ Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, d
|
|||
Requires at least: 5.5
|
||||
Tested up to: 5.7
|
||||
Requires PHP: 7.0
|
||||
Stable tag: 5.2.0
|
||||
Stable tag: 5.2.2
|
||||
License: GPLv3
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
|
@ -160,6 +160,22 @@ WooCommerce comes with some sample data you can use to see how products look; im
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 5.2.2 2021-04-15 =
|
||||
|
||||
**WooCommerce**
|
||||
|
||||
* Fix - Can't grant permission for download from order details page. #29691
|
||||
|
||||
= 5.2.1 2021-04-14 =
|
||||
|
||||
**WooCommerce**
|
||||
|
||||
* Update - WooCommerce Blocks package 4.7.2. #29660
|
||||
|
||||
**WooCommerce Blocks - 4.7.2**
|
||||
|
||||
* Fix - Check if Cart and Checkout are registered before removing payment methods. ([4056](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4056))
|
||||
|
||||
= 5.2.0 2021-04-13 =
|
||||
|
||||
**WooCommerce**
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
switchUserToTest,
|
||||
clearLocalStorage,
|
||||
setBrowserViewport,
|
||||
factories,
|
||||
withRestApi,
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
const { merchant } = require( '@woocommerce/e2e-utils' );
|
||||
|
@ -38,50 +38,13 @@ async function trashExistingPosts() {
|
|||
await switchUserToTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use api package to delete products.
|
||||
*
|
||||
* @return {Promise} Promise resolving once products have been trashed.
|
||||
*/
|
||||
async function deleteAllProducts() {
|
||||
const repository = SimpleProduct.restRepository( factories.api.withDefaultPermalinks );
|
||||
let products;
|
||||
|
||||
products = await repository.list();
|
||||
while ( products.length > 0 ) {
|
||||
for( let p = 0; p < products.length; p++ ) {
|
||||
await repository.delete( products[ p ].id );
|
||||
}
|
||||
products = await repository.list();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use api package to delete coupons.
|
||||
*
|
||||
* @return {Promise} Promise resolving once coupons have been trashed.
|
||||
*/
|
||||
async function deleteAllCoupons() {
|
||||
const repository = Coupon.restRepository( factories.api.withDefaultPermalinks );
|
||||
let coupons;
|
||||
|
||||
coupons = await repository.list();
|
||||
|
||||
while ( coupons.length > 0 ) {
|
||||
for (let c = 0; c < coupons.length; c++ ) {
|
||||
await repository.delete( coupons[ c ].id );
|
||||
}
|
||||
coupons = await repository.list();
|
||||
}
|
||||
}
|
||||
|
||||
// Before every test suite run, delete all content created by the test. This ensures
|
||||
// other posts/comments/etc. aren't dirtying tests and tests don't depend on
|
||||
// each other's side-effects.
|
||||
beforeAll( async () => {
|
||||
await trashExistingPosts();
|
||||
await deleteAllProducts();
|
||||
await deleteAllCoupons();
|
||||
await withRestApi.deleteAllProducts();
|
||||
await withRestApi.deleteAllCoupons();
|
||||
await clearLocalStorage();
|
||||
await setBrowserViewport( 'large' );
|
||||
} );
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
# Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- Support for re-running setup and shopper tests
|
||||
- Shopper Order Email Receiving
|
||||
|
||||
## Fixed
|
||||
|
||||
- Checkout create account test would fail if configuration value `addresses.customer.billing.email` was not `john.doe@example.com`
|
||||
|
||||
# 0.1.3
|
||||
|
||||
## Added
|
||||
|
||||
- Shopper Checkout Login Account
|
||||
- Shopper My Account Create Account
|
||||
- Shopper Cart Calculate Shipping
|
||||
- Shopper Cart Redirection
|
||||
|
||||
## Fixed
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ runShopperTests();
|
|||
|
||||
```
|
||||
|
||||
## Retrying/Re-running tests
|
||||
|
||||
On a new site, the setup and activation tests prepare the site for the remainder of the tests. To retry/rerun the test suite on a site where setup/onboarding test have already run use the environment variable `E2E_RETEST=1`.
|
||||
|
||||
|
||||
## Test functions
|
||||
|
||||
The functions to access the core tests are:
|
||||
|
@ -80,6 +85,9 @@ The functions to access the core tests are:
|
|||
- `runCheckoutCreateAccountTest` - Shopper can create an account during checkout
|
||||
- `runCheckoutLoginAccountTest` - Shopper can login to an account during checkout
|
||||
- `runMyAccountCreateAccountTest` - Shopper can create an account via my account page
|
||||
- `runCartCalculateShippingTest` - Shopper can calculate shipping in the cart
|
||||
- `runCartRedirectionTest` - Shopper is redirected to the cart page after adding to cart
|
||||
- `runOrderEmailReceivingTest` - Shopper can receive an email for his order
|
||||
|
||||
### REST API
|
||||
|
||||
|
|
|
@ -1,22 +1,44 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
merchant,
|
||||
completeOnboardingWizard,
|
||||
withRestApi,
|
||||
addShippingZoneAndMethod,
|
||||
IS_RETEST_MODE,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const config = require( 'config' );
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const shippingZoneNameUS = config.get( 'addresses.customer.shipping.country' );
|
||||
|
||||
const runOnboardingFlowTest = () => {
|
||||
describe('Store owner can go through store Onboarding', () => {
|
||||
if ( IS_RETEST_MODE ) {
|
||||
it('can reset onboarding to default settings', async () => {
|
||||
await withRestApi.resetOnboarding();
|
||||
});
|
||||
|
||||
it('can reset shipping zones to default settings', async () => {
|
||||
await withRestApi.deleteAllShippingZones();
|
||||
});
|
||||
|
||||
it('can reset to default settings', async () => {
|
||||
await withRestApi.resetSettingsGroupToDefault('general');
|
||||
await withRestApi.resetSettingsGroupToDefault('products');
|
||||
await withRestApi.resetSettingsGroupToDefault('tax');
|
||||
});
|
||||
}
|
||||
|
||||
it('can start and complete onboarding when visiting the site for the first time.', async () => {
|
||||
await merchant.runSetupWizard();
|
||||
|
@ -33,16 +55,14 @@ const runTaskListTest = () => {
|
|||
});
|
||||
// Query for all tasks on the list
|
||||
const taskListItems = await page.$$('.woocommerce-list__item-title');
|
||||
expect(taskListItems).toHaveLength(6);
|
||||
expect(taskListItems.length).toBeInRange( 5, 6 );
|
||||
|
||||
const [ setupTaskListItem ] = await page.$x( '//div[contains(text(),"Set up shipping")]' );
|
||||
await Promise.all([
|
||||
// Work around for https://github.com/woocommerce/woocommerce-admin/issues/6761
|
||||
if ( taskListItems.length == 6 ) {
|
||||
// Click on "Set up shipping" task to move to the next step
|
||||
setupTaskListItem.click(),
|
||||
|
||||
// Wait for shipping setup section to load
|
||||
page.waitForNavigation({waitUntil: 'networkidle0'}),
|
||||
]);
|
||||
const [ setupTaskListItem ] = await page.$x( '//div[contains(text(),"Set up shipping")]' );
|
||||
await setupTaskListItem.click();
|
||||
await page.waitForNavigation({waitUntil: 'networkidle0'});
|
||||
|
||||
// Wait for "Proceed" button to become active
|
||||
await page.waitForSelector('button.is-primary:not(:disabled)');
|
||||
|
@ -51,6 +71,10 @@ const runTaskListTest = () => {
|
|||
// Click on "Proceed" button to save shipping settings
|
||||
await page.click('button.is-primary');
|
||||
await page.waitFor(3000);
|
||||
} else {
|
||||
await merchant.openNewShipping();
|
||||
await addShippingZoneAndMethod(shippingZoneNameUS);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@ const { HTTPClientFactory } = require( '@woocommerce/api' );
|
|||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,9 @@ const runSingleProductPageTest = require( './shopper/front-end-single-product.te
|
|||
const runVariableProductUpdateTest = require( './shopper/front-end-variable-product-updates.test' );
|
||||
const runCheckoutCreateAccountTest = require( './shopper/front-end-checkout-create-account.test' );
|
||||
const runCheckoutLoginAccountTest = require( './shopper/front-end-checkout-login-account.test' );
|
||||
const runCartCalculateShippingTest = require( './shopper/front-end-cart-calculate-shipping.test' );
|
||||
const runCartRedirectionTest = require( './shopper/front-end-cart-redirection.test' );
|
||||
const runOrderEmailReceivingTest = require( './shopper/front-end-order-email-receiving.test' );
|
||||
|
||||
// Merchant tests
|
||||
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' );
|
||||
|
@ -69,6 +72,9 @@ const runShopperTests = () => {
|
|||
runVariableProductUpdateTest();
|
||||
runCheckoutCreateAccountTest();
|
||||
runCheckoutLoginAccountTest();
|
||||
runCartCalculateShippingTest();
|
||||
runCartRedirectionTest();
|
||||
runOrderEmailReceivingTest();
|
||||
};
|
||||
|
||||
const runMerchantTests = () => {
|
||||
|
@ -144,5 +150,8 @@ module.exports = {
|
|||
runCheckoutCreateAccountTest,
|
||||
runImportProductsTest,
|
||||
runCheckoutLoginAccountTest,
|
||||
runMyAccountCreateAccountTest
|
||||
runCartCalculateShippingTest,
|
||||
runCartRedirectionTest,
|
||||
runMyAccountCreateAccountTest,
|
||||
runOrderEmailReceivingTest,
|
||||
};
|
||||
|
|
|
@ -10,10 +10,18 @@ const {
|
|||
addShippingZoneAndMethod,
|
||||
clearAndFillInput,
|
||||
selectOptionInSelect2,
|
||||
evalAndClick,
|
||||
uiUnblocked,
|
||||
deleteAllShippingZones,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
@ -28,27 +36,7 @@ const runAddNewShippingZoneTest = () => {
|
|||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
await createSimpleProduct();
|
||||
await merchant.openSettings('shipping');
|
||||
|
||||
// Delete existing shipping zones.
|
||||
try {
|
||||
let zone = await page.$( '.wc-shipping-zone-delete' );
|
||||
if ( zone ) {
|
||||
// WP action links aren't clickable because they are hidden with a left=-9999 style.
|
||||
await page.evaluate(() => {
|
||||
document.querySelector('.wc-shipping-zone-name .row-actions')
|
||||
.style
|
||||
.left = '0';
|
||||
});
|
||||
while ( zone ) {
|
||||
await evalAndClick( '.wc-shipping-zone-delete' );
|
||||
await uiUnblocked();
|
||||
zone = await page.$( '.wc-shipping-zone-delete' );
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Prevent an error here causing the test to fail.
|
||||
}
|
||||
await deleteAllShippingZones();
|
||||
});
|
||||
|
||||
it('add shipping zone for San Francisco with free Local pickup', async () => {
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect */
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
shopper,
|
||||
merchant,
|
||||
createSimpleProduct,
|
||||
addShippingZoneAndMethod,
|
||||
clearAndFillInput,
|
||||
uiUnblocked,
|
||||
selectOptionInSelect2,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const config = require( 'config' );
|
||||
const firstProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
||||
const secondProductPrice = '4.99';
|
||||
const fourProductPrice = firstProductPrice * 4;
|
||||
var twoProductsPrice = (+firstProductPrice) + (+secondProductPrice);
|
||||
var firstProductPriceWithFlatRate = (+firstProductPrice) + (+5);
|
||||
var fourProductPriceWithFlatRate = (+fourProductPrice) + (+5);
|
||||
var twoProductsPriceWithFlatRate = (+twoProductsPrice) + (+5);
|
||||
const firstProductName = 'First Product';
|
||||
const secondProductName = 'Second Product';
|
||||
const shippingZoneNameDE = 'Germany Free Shipping';
|
||||
const shippingCountryDE = 'country:DE';
|
||||
const shippingZoneNameFR = 'France Flat Local';
|
||||
const shippingCountryFR = 'country:FR';
|
||||
|
||||
const runCartCalculateShippingTest = () => {
|
||||
describe('Cart Calculate Shipping', () => {
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
await createSimpleProduct(firstProductName);
|
||||
await createSimpleProduct(secondProductName, secondProductPrice);
|
||||
await merchant.openNewShipping();
|
||||
|
||||
// Add a new shipping zone Germany with Free shipping
|
||||
await addShippingZoneAndMethod(shippingZoneNameDE, shippingCountryDE, ' ', 'free_shipping');
|
||||
|
||||
// Add a new shipping zone for France with Flat rate & Local pickup
|
||||
await addShippingZoneAndMethod(shippingZoneNameFR, shippingCountryFR, ' ', 'flat_rate');
|
||||
await page.waitFor(1000); // to avoid flakiness in headless
|
||||
await page.click('a.wc-shipping-zone-method-settings', {text: 'Flat rate'});
|
||||
await clearAndFillInput('#woocommerce_flat_rate_cost', '5');
|
||||
await page.click('.wc-backbone-modal-main button#btn-ok');
|
||||
// Add additional method Local pickup for the same location
|
||||
await page.waitFor(1000); // to avoid flakiness in headless
|
||||
await page.click('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
|
||||
await page.waitForSelector('.wc-shipping-zone-method-selector');
|
||||
await page.select('select[name="add_method_id"]', 'local_pickup');
|
||||
await page.click('button#btn-ok');
|
||||
await page.waitForSelector('#zone_locations');
|
||||
});
|
||||
|
||||
it('allows customer to calculate Free Shipping if in Germany', async () => {
|
||||
await shopper.goToShop();
|
||||
await shopper.addToCartFromShopPage(firstProductName);
|
||||
await shopper.goToCart();
|
||||
|
||||
// Set shipping country to Germany
|
||||
await expect(page).toClick('a.shipping-calculator-button');
|
||||
await expect(page).toClick('#select2-calc_shipping_country-container');
|
||||
await selectOptionInSelect2('Germany');
|
||||
await expect(page).toClick('button[name="calc_shipping"]');
|
||||
|
||||
// Verify shipping costs
|
||||
await page.waitForSelector('.order-total');
|
||||
await expect(page).toMatchElement('.shipping ul#shipping_method > li', {text: 'Free shipping'});
|
||||
await expect(page).toMatchElement('.order-total .amount', {text: `$${firstProductPrice}`});
|
||||
});
|
||||
|
||||
it('allows customer to calculate Flat rate and Local pickup if in France', async () => {
|
||||
await page.reload();
|
||||
|
||||
// Set shipping country to France
|
||||
await expect(page).toClick('a.shipping-calculator-button');
|
||||
await expect(page).toClick('#select2-calc_shipping_country-container');
|
||||
await selectOptionInSelect2('France');
|
||||
await expect(page).toClick('button[name="calc_shipping"]');
|
||||
|
||||
// Verify shipping costs
|
||||
await page.waitForSelector('.order-total');
|
||||
await expect(page).toMatchElement('.shipping .amount', {text: '$5.00'});
|
||||
await expect(page).toMatchElement('.order-total .amount', {text: `$${firstProductPriceWithFlatRate}`});
|
||||
});
|
||||
|
||||
it('should show correct total cart price after updating quantity', async () => {
|
||||
await shopper.setCartQuantity(firstProductName, 4);
|
||||
await expect(page).toClick('button', {text: 'Update cart'});
|
||||
await uiUnblocked();
|
||||
await expect(page).toMatchElement('.order-total .amount', {text: `$${fourProductPriceWithFlatRate}`});
|
||||
});
|
||||
|
||||
it('should show correct total cart price with 2 products and flat rate', async () => {
|
||||
await shopper.goToShop();
|
||||
await shopper.addToCartFromShopPage(secondProductName);
|
||||
await shopper.goToCart();
|
||||
|
||||
await shopper.setCartQuantity(firstProductName, 1);
|
||||
await expect(page).toClick('button', {text: 'Update cart'});
|
||||
await uiUnblocked();
|
||||
await page.waitForSelector('.order-total');
|
||||
await expect(page).toMatchElement('.shipping .amount', {text: '$5.00'});
|
||||
await expect(page).toMatchElement('.order-total .amount', {text: `$${twoProductsPriceWithFlatRate}`});
|
||||
});
|
||||
|
||||
it('should show correct total cart price with 2 products without flat rate', async () => {
|
||||
await page.reload();
|
||||
|
||||
// Set shipping country to Spain
|
||||
await expect(page).toClick('a.shipping-calculator-button');
|
||||
await expect(page).toClick('#select2-calc_shipping_country-container');
|
||||
await selectOptionInSelect2('Spain');
|
||||
await expect(page).toClick('button[name="calc_shipping"]');
|
||||
|
||||
// Verify shipping costs
|
||||
await page.waitForSelector('.order-total');
|
||||
await expect(page).toMatchElement('.order-total .amount', {text: `$${twoProductsPrice}`});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runCartCalculateShippingTest;
|
|
@ -0,0 +1,76 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
shopper,
|
||||
merchant,
|
||||
createSimpleProduct,
|
||||
setCheckbox,
|
||||
unsetCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
||||
const runCartRedirectionTest = () => {
|
||||
describe('Cart > Redirect to cart from shop', () => {
|
||||
let simplePostIdValue;
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
simplePostIdValue = await createSimpleProduct();
|
||||
|
||||
// Set checkbox in settings to enable cart redirection
|
||||
await merchant.openSettings('products');
|
||||
await setCheckbox('#woocommerce_cart_redirect_after_add');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
await merchant.logout();
|
||||
});
|
||||
|
||||
it('can redirect user to cart from shop page', async () => {
|
||||
await shopper.goToShop();
|
||||
|
||||
// Add to cart from shop page
|
||||
const addToCartXPath = `//li[contains(@class, "type-product") and a/h2[contains(text(), "${ simpleProductName }")]]` +
|
||||
'//a[contains(@class, "add_to_cart_button") and contains(@class, "ajax_add_to_cart")';
|
||||
const [ addToCartButton ] = await page.$x( addToCartXPath + ']' );
|
||||
addToCartButton.click();
|
||||
await page.waitFor(1000); // to avoid flakiness
|
||||
|
||||
await shopper.productIsInCart(simpleProductName);
|
||||
await shopper.removeFromCart(simpleProductName);
|
||||
});
|
||||
|
||||
it('can redirect user to cart from detail page', async () => {
|
||||
await shopper.goToProduct(simplePostIdValue);
|
||||
|
||||
// Add to cart from detail page
|
||||
await shopper.addToCart();
|
||||
await page.waitFor(1000); // to avoid flakiness
|
||||
|
||||
await shopper.productIsInCart(simpleProductName);
|
||||
await shopper.removeFromCart(simpleProductName);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await merchant.login();
|
||||
await merchant.openSettings('products');
|
||||
await unsetCheckbox('#woocommerce_cart_redirect_after_add');
|
||||
await settingsPageSaveChanges();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runCartRedirectionTest;
|
|
@ -9,6 +9,7 @@
|
|||
uiUnblocked,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
withRestApi,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
|
@ -22,14 +23,16 @@ const {
|
|||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
const customerBilling = config.get( 'addresses.customer.billing' );
|
||||
|
||||
const runCheckoutCreateAccountTest = () => {
|
||||
describe('Shopper Checkout Create Account', () => {
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
await createSimpleProduct();
|
||||
await withRestApi.deleteCustomerByEmail( customerBilling.email );
|
||||
|
||||
// Set checkbox for creating an account during checkout
|
||||
await merchant.login();
|
||||
await merchant.openSettings('account');
|
||||
await setCheckbox('#woocommerce_enable_signup_and_login_from_checkout');
|
||||
await settingsPageSaveChanges();
|
||||
|
@ -44,7 +47,7 @@ const runCheckoutCreateAccountTest = () => {
|
|||
|
||||
it('can create an account during checkout', async () => {
|
||||
// Fill all the details for a new customer
|
||||
await shopper.fillBillingDetails(config.get('addresses.customer.billing'));
|
||||
await shopper.fillBillingDetails( customerBilling );
|
||||
await uiUnblocked();
|
||||
|
||||
// Set checkbox for creating account during checkout
|
||||
|
@ -58,7 +61,7 @@ const runCheckoutCreateAccountTest = () => {
|
|||
it('can verify that the customer has been created', async () => {
|
||||
await merchant.login();
|
||||
await merchant.openAllUsersView();
|
||||
await expect(page).toMatchElement('td.email.column-email > a', {text: 'john.doe@example.com'});
|
||||
await expect(page).toMatchElement('td.email.column-email > a', { text: customerBilling.email });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -7,11 +7,15 @@ const {
|
|||
merchant,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
withRestApi,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
const customerEmailAddress = 'john.doe.test@example.com';
|
||||
|
||||
const runMyAccountCreateAccountTest = () => {
|
||||
describe('Shopper My Account Create Account', () => {
|
||||
beforeAll(async () => {
|
||||
await withRestApi.deleteCustomerByEmail( customerEmailAddress );
|
||||
await merchant.login();
|
||||
|
||||
// Set checkbox in the settings to enable registration in my account
|
||||
|
@ -25,7 +29,7 @@ const runMyAccountCreateAccountTest = () => {
|
|||
it('can create a new account via my account', async () => {
|
||||
await shopper.gotoMyAccount();
|
||||
await page.waitForSelector('.woocommerce-form-register');
|
||||
await expect(page).toFill('input#reg_email', 'john.doe.test@example.com');
|
||||
await expect(page).toFill('input#reg_email', customerEmailAddress);
|
||||
await expect(page).toClick('button[name="register"]');
|
||||
await page.waitForNavigation({waitUntil: 'networkidle0'});
|
||||
await expect(page).toMatchElement('h1', 'My account');
|
||||
|
@ -33,7 +37,7 @@ const runMyAccountCreateAccountTest = () => {
|
|||
// Verify user has been created successfully
|
||||
await merchant.login();
|
||||
await merchant.openAllUsersView();
|
||||
await expect(page).toMatchElement('td.email.column-email > a', {text: 'john.doe.test@example.com'});
|
||||
await expect(page).toMatchElement('td.email.column-email > a', {text: customerEmailAddress});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
shopper,
|
||||
merchant,
|
||||
createSimpleProduct,
|
||||
uiUnblocked,
|
||||
deleteAllEmailLogs,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
let simplePostIdValue;
|
||||
let orderId;
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
const customerEmail = config.get( 'addresses.customer.billing.email' );
|
||||
const storeName = 'WooCommerce Core E2E Test Suite';
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const runOrderEmailReceivingTest = () => {
|
||||
describe('Shopper Order Email Receiving', () => {
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
await deleteAllEmailLogs();
|
||||
simplePostIdValue = await createSimpleProduct();
|
||||
await merchant.logout();
|
||||
});
|
||||
|
||||
it('should receive order email after purchasing an item', async () => {
|
||||
await shopper.login();
|
||||
|
||||
// Go to the shop and purchase an item
|
||||
await shopper.goToProduct(simplePostIdValue);
|
||||
await shopper.addToCart(simpleProductName);
|
||||
await shopper.goToCheckout();
|
||||
await uiUnblocked();
|
||||
await shopper.placeOrder();
|
||||
// Get order ID from the order received html element on the page
|
||||
orderId = await page.$$eval(".woocommerce-order-overview__order strong", elements => elements.map(item => item.textContent));
|
||||
|
||||
// Verify the new order email has been received
|
||||
await merchant.login();
|
||||
await merchant.openEmailLog();
|
||||
await expect( page ).toMatchElement( '.column-receiver', { text: customerEmail } );
|
||||
await expect( page ).toMatchElement( '.column-subject', { text: `[${storeName}]: New order #${orderId}` } );
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runOrderEmailReceivingTest;
|
|
@ -1,5 +1,9 @@
|
|||
# Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- `takeScreenshotFor` utility function to take screenshots within tests
|
||||
- `toBeInRange` expect numeric range matcher
|
||||
|
||||
# 0.2.1
|
||||
|
||||
|
|
|
@ -79,6 +79,12 @@ The test sequencer provides a screenshot function for test failures. To enable s
|
|||
WC_E2E_SCREENSHOTS=1 npx wc-e2e test:e2e
|
||||
```
|
||||
|
||||
To take adhoc in test screenshots use
|
||||
|
||||
```js
|
||||
await takeScreenshotFor( 'name of current step' );
|
||||
```
|
||||
|
||||
Screenshots will be saved to `tests/e2e/screenshots`. This folder is cleared at the beginning of each test run.
|
||||
|
||||
### Jest Puppeteer Config
|
||||
|
@ -147,6 +153,7 @@ To implement the Slackbot in your CI:
|
|||
- `files:write`
|
||||
- `incoming-webhook`
|
||||
- Add the app to your channel
|
||||
- Invite the Slack app user to your channel `/invite @your-slackbot-user`
|
||||
- In your CI environment
|
||||
- Add the environment variable `WC_E2E_SCREENSHOTS=1`
|
||||
- Add your app Oauth token to a CI secret `E2E_SLACK_TOKEN`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@woocommerce/e2e-environment",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -4,10 +4,8 @@ import {
|
|||
sendFailedTestMessageToSlack,
|
||||
} from '../slack';
|
||||
|
||||
const path = require( 'path' );
|
||||
const mkdirp = require( 'mkdirp' );
|
||||
import { bind } from 'jest-each';
|
||||
const { getAppRoot } = require( '../../utils' );
|
||||
const { takeScreenshotFor } = require( '../../utils' );
|
||||
|
||||
/**
|
||||
* Override the test case method so we can take screenshots of assertion failures.
|
||||
|
@ -88,22 +86,11 @@ const screenshotTest = async ( testName, callback ) => {
|
|||
try {
|
||||
await callback();
|
||||
} catch ( e ) {
|
||||
const testTitle = testName.replace( /\.$/, '' );
|
||||
const appPath = getAppRoot();
|
||||
const savePath = path.resolve( appPath, 'tests/e2e/screenshots' );
|
||||
const filePath = path.join(
|
||||
savePath,
|
||||
`${ testTitle }.png`.replace( /[^a-z0-9.-]+/gi, '-' )
|
||||
);
|
||||
|
||||
mkdirp.sync( savePath );
|
||||
await page.screenshot( {
|
||||
path: filePath,
|
||||
fullPage: true,
|
||||
} );
|
||||
|
||||
await sendFailedTestMessageToSlack( testTitle );
|
||||
const { title, filePath } = await takeScreenshotFor( testName );
|
||||
await sendFailedTestMessageToSlack( title );
|
||||
if ( filePath ) {
|
||||
await sendFailedTestScreenshotToSlack( filePath );
|
||||
}
|
||||
|
||||
throw ( e );
|
||||
}
|
||||
|
|
|
@ -101,6 +101,23 @@ function removePageEvents() {
|
|||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an expect range matcher.
|
||||
* @see https://jestjs.io/docs/expect#expectextendmatchers
|
||||
*/
|
||||
expect.extend({
|
||||
toBeInRange: function (received, floor, ceiling) {
|
||||
const pass = received >= floor && received <= ceiling;
|
||||
const condition = pass ? 'not to be' : 'to be';
|
||||
|
||||
return {
|
||||
message: () =>
|
||||
`expected ${received} ${condition} within range ${floor} - ${ceiling}`,
|
||||
pass,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Adds a page event handler to emit uncaught exception to process if one of
|
||||
* the observed console logging types is encountered.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const getAppRoot = require( './app-root' );
|
||||
const { getAppName, getAppBase } = require( './app-name' );
|
||||
const { getTestConfig, getAdminConfig } = require( './test-config' );
|
||||
const takeScreenshotFor = require( './take-screenshot' );
|
||||
|
||||
module.exports = {
|
||||
getAppBase,
|
||||
|
@ -8,4 +9,5 @@ module.exports = {
|
|||
getAppName,
|
||||
getTestConfig,
|
||||
getAdminConfig,
|
||||
takeScreenshotFor,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
const path = require( 'path' );
|
||||
const mkdirp = require( 'mkdirp' );
|
||||
const getAppRoot = require( './app-root' );
|
||||
|
||||
/**
|
||||
* Take a screenshot if browser context exists.
|
||||
* @param message
|
||||
* @returns {Promise<{filePath: string, title: string}|{filePath: *, title: *}>}
|
||||
*/
|
||||
const takeScreenshotFor = async ( message ) => {
|
||||
const title = message.replace( /\.$/, '' );
|
||||
const appPath = getAppRoot();
|
||||
const savePath = path.resolve( appPath, 'tests/e2e/screenshots' );
|
||||
const filePath = path.join(
|
||||
savePath,
|
||||
`${ title }.png`.replace( /[^a-z0-9.-]+/gi, '-' )
|
||||
);
|
||||
|
||||
mkdirp.sync( savePath );
|
||||
try {
|
||||
await page.screenshot({
|
||||
path: filePath,
|
||||
fullPage: true,
|
||||
});
|
||||
} catch ( error ) {
|
||||
return {
|
||||
title: 'no screenshot',
|
||||
filePath: '',
|
||||
};
|
||||
}
|
||||
return {
|
||||
title,
|
||||
filePath,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = takeScreenshotFor;
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runCartCalculateShippingTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runCartCalculateShippingTest();
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runCartRedirectionTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runCartRedirectionTest();
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runOrderEmailReceivingTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runOrderEmailReceivingTest();
|
|
@ -1,6 +1,16 @@
|
|||
# Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- `emptyCart()` Shopper flow helper that empties the cart
|
||||
- `deleteAllShippingZones` Delete all the existing shipping zones
|
||||
- constants
|
||||
- `WP_ADMIN_POST_TYPE`
|
||||
- `WP_ADMIN_NEW_POST_TYPE`
|
||||
- `WP_ADMIN_ALL_COUPONS_VIEW`
|
||||
- `WP_ADMIN_WC_HOME`
|
||||
- `IS_RETEST_MODE`
|
||||
- `withRestApi` flow containing utility functions that manage data with the rest api
|
||||
|
||||
# 0.1.4
|
||||
|
||||
|
|
|
@ -31,6 +31,50 @@ describe( 'Cart page', () => {
|
|||
} );
|
||||
~~~
|
||||
|
||||
### Retries
|
||||
|
||||
This package provides support for enabling retries in tests:
|
||||
|
||||
- In the test environment set `E2E_RETEST=1`.
|
||||
- To add conditional logic to your tests use the boolean constant `IS_RETEST_MODE`.
|
||||
|
||||
### Available constants
|
||||
|
||||
#### Dashboard
|
||||
|
||||
- `WP_ADMIN_LOGIN` - WordPress login
|
||||
- `WP_ADMIN_DASHBOARD` - WordPress dashboard
|
||||
- `WP_ADMIN_PLUGINS` - Plugin list
|
||||
- `WP_ADMIN_PERMALINK_SETTINGS` - Permalink settings
|
||||
- `WP_ADMIN_ALL_USERS_VIEW` - WordPress user list
|
||||
- `WP_ADMIN_POST_TYPE` - Post listing
|
||||
- `WP_ADMIN_NEW_POST_TYPE` - New post
|
||||
- `WP_ADMIN_ALL_COUPONS_VIEW` - Coupons list
|
||||
- `WP_ADMIN_NEW_COUPON` - New coupon
|
||||
- `WP_ADMIN_ALL_ORDERS_VIEW` - Orders list
|
||||
- `WP_ADMIN_NEW_ORDER` - New Order
|
||||
- `WP_ADMIN_ALL_PRODUCTS_VIEW` - Products list
|
||||
- `WP_ADMIN_NEW_PRODUCT` - New product
|
||||
- `WP_ADMIN_IMPORT_PRODUCTS` - Import products
|
||||
- `WP_ADMIN_PLUGIN_PAGE` - Plugin settings page root
|
||||
- `WP_ADMIN_WC_HOME` - WooCommerce home screen
|
||||
- `WP_ADMIN_SETUP_WIZARD` - WooCommerce setup/onboarding wizard
|
||||
- `WP_ADMIN_ANALYTICS_PAGES` - WooCommerce analytics page root
|
||||
- `WP_ADMIN_WC_SETTINGS` - WooCommerce settings page root
|
||||
- `WP_ADMIN_NEW_SHIPPING_ZONE` - WooCommerce new shipping zone
|
||||
|
||||
#### Front end
|
||||
|
||||
- `SHOP_PAGE` - Shop page
|
||||
- `SHOP_PRODUCT_PAGE` - Single product page
|
||||
- `SHOP_CART_PAGE` - Cart page
|
||||
- `SHOP_CHECKOUT_PAGE` - Checkout page
|
||||
- `SHOP_MY_ACCOUNT_PAGE` - Customer account page
|
||||
- `MY_ACCOUNT_ORDERS` - Customer orders
|
||||
- `MY_ACCOUNT_DOWNLOADS` - Customer downloads
|
||||
- `MY_ACCOUNT_ADDRESSES` - Customer addresses
|
||||
- `MY_ACCOUNT_ACCOUNT_DETAILS` - Customer account details
|
||||
|
||||
## Test Function
|
||||
|
||||
### Merchant `merchant`
|
||||
|
@ -82,6 +126,17 @@ describe( 'Cart page', () => {
|
|||
| `searchForProduct` | | Searching for a product name and landing on its detail page |
|
||||
| `emptyCart` | | Removes any products and coupons that are in the cart |
|
||||
|
||||
### REST API `withRestApi`
|
||||
|
||||
| Function | Parameters | Description |
|
||||
|----------|------------|-------------|
|
||||
| `resetOnboarding` | | Reset onboarding settings |
|
||||
| `deleteAllCoupons` | | Permanently delete all coupons |
|
||||
| `deleteAllProducts` | | Permanently delete all products |
|
||||
| `deleteAllShippingZones` | | Permanently delete all shipping zones except the default |
|
||||
| `deleteCustomerByEmail` | `emailAddress` | Delete customer user account. Posts are reassigned to user ID 1 |
|
||||
| `resetSettingsGroupToDefault` | `settingsGroup` | Reset settings in settings group to default except `select` fields |
|
||||
|
||||
### Page Utilities
|
||||
|
||||
| Function | Parameters | Description |
|
||||
|
@ -125,6 +180,7 @@ describe( 'Cart page', () => {
|
|||
| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |
|
||||
| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |
|
||||
| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |
|
||||
| `deleteAllShippingZones` | | Delete all the existing shipping zones |
|
||||
|
||||
### Test Utilities
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { merchant } from './flows';
|
||||
import { merchant, IS_RETEST_MODE } from './flows';
|
||||
import {
|
||||
clickTab,
|
||||
uiUnblocked,
|
||||
verifyCheckboxIsUnset,
|
||||
selectOptionInSelect2,
|
||||
setCheckbox,
|
||||
unsetCheckbox
|
||||
unsetCheckbox,
|
||||
evalAndClick,
|
||||
clearAndFillInput,
|
||||
} from './page-utils';
|
||||
import factories from './factories';
|
||||
|
||||
|
@ -81,23 +83,20 @@ const completeOnboardingWizard = async () => {
|
|||
// Click on "Continue" button to move to the next step
|
||||
await page.click( 'button.is-primary', { text: 'Continue' } );
|
||||
|
||||
// Wait for usage tracking pop-up window to appear
|
||||
await page.waitForSelector( '.components-modal__header-heading' );
|
||||
await expect( page ).toMatchElement(
|
||||
'.components-modal__header-heading', { text: 'Build a better WooCommerce' }
|
||||
// Wait for usage tracking pop-up window to appear on a new site
|
||||
if ( ! IS_RETEST_MODE ) {
|
||||
await page.waitForSelector('.components-modal__header-heading');
|
||||
await expect(page).toMatchElement(
|
||||
'.components-modal__header-heading', {text: 'Build a better WooCommerce'}
|
||||
);
|
||||
|
||||
// Query for "Continue" buttons
|
||||
const continueButtons = await page.$$( 'button.is-primary' );
|
||||
expect( continueButtons ).toHaveLength( 2 );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button of the usage pop-up window to move to the next step
|
||||
continueButtons[1].click(),
|
||||
|
||||
// Wait for "In which industry does the store operate?" section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
await continueButtons[1].click();
|
||||
}
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
// Industry section
|
||||
|
||||
|
@ -158,6 +157,10 @@ const completeOnboardingWizard = async () => {
|
|||
await waitAndClickPrimary();
|
||||
|
||||
// End of onboarding wizard
|
||||
if ( IS_RETEST_MODE ) {
|
||||
// Home screen modal can't be reset via the rest api.
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for homescreen welcome modal to appear
|
||||
await page.waitForSelector( '.woocommerce__welcome-modal__page-content__header' );
|
||||
|
@ -538,6 +541,33 @@ const deleteAllEmailLogs = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete all the existing shipping zones.
|
||||
*/
|
||||
const deleteAllShippingZones = async () => {
|
||||
await merchant.openSettings('shipping');
|
||||
|
||||
// Delete existing shipping zones.
|
||||
try {
|
||||
let zone = await page.$( '.wc-shipping-zone-delete' );
|
||||
if ( zone ) {
|
||||
// WP action links aren't clickable because they are hidden with a left=-9999 style.
|
||||
await page.evaluate(() => {
|
||||
document.querySelector('.wc-shipping-zone-name .row-actions')
|
||||
.style
|
||||
.left = '0';
|
||||
});
|
||||
while ( zone ) {
|
||||
await evalAndClick( '.wc-shipping-zone-delete' );
|
||||
await uiUnblocked();
|
||||
zone = await page.$( '.wc-shipping-zone-delete' );
|
||||
};
|
||||
};
|
||||
} catch (error) {
|
||||
// Prevent an error here causing the test to fail.
|
||||
};
|
||||
};
|
||||
|
||||
export {
|
||||
completeOnboardingWizard,
|
||||
createSimpleProduct,
|
||||
|
@ -551,4 +581,5 @@ export {
|
|||
createSimpleProductWithCategory,
|
||||
clickUpdateOrder,
|
||||
deleteAllEmailLogs,
|
||||
deleteAllShippingZones,
|
||||
};
|
||||
|
|
|
@ -2,32 +2,60 @@
|
|||
* External dependencies
|
||||
*/
|
||||
const config = require( 'config' );
|
||||
|
||||
const baseUrl = config.get( 'url' );
|
||||
|
||||
/**
|
||||
* WordPress core dashboard pages.
|
||||
* @type {string}
|
||||
*/
|
||||
export const WP_ADMIN_LOGIN = baseUrl + 'wp-login.php';
|
||||
export const WP_ADMIN_DASHBOARD = baseUrl + 'wp-admin';
|
||||
export const WP_ADMIN_PLUGINS = baseUrl + 'wp-admin/plugins.php';
|
||||
export const WP_ADMIN_SETUP_WIZARD = baseUrl + 'wp-admin/admin.php?page=wc-admin';
|
||||
export const WP_ADMIN_ALL_ORDERS_VIEW = baseUrl + 'wp-admin/edit.php?post_type=shop_order';
|
||||
export const WP_ADMIN_ALL_PRODUCTS_VIEW = baseUrl + 'wp-admin/edit.php?post_type=product';
|
||||
export const WP_ADMIN_NEW_COUPON = baseUrl + 'wp-admin/post-new.php?post_type=shop_coupon';
|
||||
export const WP_ADMIN_NEW_ORDER = baseUrl + 'wp-admin/post-new.php?post_type=shop_order';
|
||||
export const WP_ADMIN_NEW_PRODUCT = baseUrl + 'wp-admin/post-new.php?post_type=product';
|
||||
export const WP_ADMIN_WC_SETTINGS = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab=';
|
||||
export const WP_ADMIN_PERMALINK_SETTINGS = baseUrl + 'wp-admin/options-permalink.php';
|
||||
export const WP_ADMIN_NEW_SHIPPING_ZONE = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab=shipping&zone_id=new';
|
||||
export const WP_ADMIN_ANALYTICS_PAGES = baseUrl + 'wp-admin/admin.php?page=wc-admin&path=%2Fanalytics%2F';
|
||||
export const WP_ADMIN_ALL_USERS_VIEW = baseUrl + 'wp-admin/users.php';
|
||||
export const WP_ADMIN_IMPORT_PRODUCTS = baseUrl + 'wp-admin/edit.php?post_type=product&page=product_importer';
|
||||
|
||||
export const WP_ADMIN_DASHBOARD = baseUrl + 'wp-admin/';
|
||||
export const WP_ADMIN_PLUGINS = WP_ADMIN_DASHBOARD + 'plugins.php';
|
||||
export const WP_ADMIN_PERMALINK_SETTINGS = WP_ADMIN_DASHBOARD + 'options-permalink.php';
|
||||
export const WP_ADMIN_ALL_USERS_VIEW = WP_ADMIN_DASHBOARD + 'users.php';
|
||||
/**
|
||||
* WooCommerce core post type pages.
|
||||
* @type {string}
|
||||
*/
|
||||
export const WP_ADMIN_POST_TYPE = WP_ADMIN_DASHBOARD + 'edit.php?post_type=';
|
||||
export const WP_ADMIN_NEW_POST_TYPE = WP_ADMIN_DASHBOARD + 'post-new.php?post_type=';
|
||||
export const WP_ADMIN_ALL_COUPONS_VIEW = WP_ADMIN_POST_TYPE + 'shop_coupon';
|
||||
export const WP_ADMIN_NEW_COUPON = WP_ADMIN_NEW_POST_TYPE + 'shop_coupon';
|
||||
export const WP_ADMIN_ALL_ORDERS_VIEW = WP_ADMIN_POST_TYPE + 'shop_order';
|
||||
export const WP_ADMIN_NEW_ORDER = WP_ADMIN_NEW_POST_TYPE + 'shop_order';
|
||||
export const WP_ADMIN_ALL_PRODUCTS_VIEW = WP_ADMIN_POST_TYPE + 'product';
|
||||
export const WP_ADMIN_NEW_PRODUCT = WP_ADMIN_NEW_POST_TYPE + 'product';
|
||||
export const WP_ADMIN_IMPORT_PRODUCTS = WP_ADMIN_ALL_PRODUCTS_VIEW + '&page=product_importer';
|
||||
/**
|
||||
* WooCommerce settings pages.
|
||||
* @type {string}
|
||||
*/
|
||||
export const WP_ADMIN_PLUGIN_PAGE = WP_ADMIN_DASHBOARD + 'admin.php?page=';
|
||||
export const WP_ADMIN_WC_HOME = WP_ADMIN_PLUGIN_PAGE + 'wc-admin';
|
||||
export const WP_ADMIN_SETUP_WIZARD = WP_ADMIN_WC_HOME + '&path=%2Fsetup-wizard';
|
||||
export const WP_ADMIN_ANALYTICS_PAGES = WP_ADMIN_WC_HOME + '&path=%2Fanalytics%2F';
|
||||
export const WP_ADMIN_WC_SETTINGS = WP_ADMIN_PLUGIN_PAGE + 'wc-settings&tab=';
|
||||
export const WP_ADMIN_NEW_SHIPPING_ZONE = WP_ADMIN_WC_SETTINGS + 'shipping&zone_id=new';
|
||||
/**
|
||||
* Shop pages.
|
||||
* @type {string}
|
||||
*/
|
||||
export const SHOP_PAGE = baseUrl + 'shop';
|
||||
export const SHOP_PRODUCT_PAGE = baseUrl + '?p=';
|
||||
export const SHOP_CART_PAGE = baseUrl + 'cart';
|
||||
export const SHOP_CHECKOUT_PAGE = baseUrl + 'checkout/';
|
||||
export const SHOP_MY_ACCOUNT_PAGE = baseUrl + 'my-account/';
|
||||
/**
|
||||
* Customer account pages.
|
||||
* @type {string}
|
||||
*/
|
||||
export const MY_ACCOUNT_ORDERS = SHOP_MY_ACCOUNT_PAGE + 'orders';
|
||||
export const MY_ACCOUNT_DOWNLOADS = SHOP_MY_ACCOUNT_PAGE + 'downloads';
|
||||
export const MY_ACCOUNT_ADDRESSES = SHOP_MY_ACCOUNT_PAGE + 'edit-address';
|
||||
export const MY_ACCOUNT_ACCOUNT_DETAILS = SHOP_MY_ACCOUNT_PAGE + 'edit-account';
|
||||
|
||||
export const MY_ACCOUNT_ORDERS = baseUrl + 'my-account/orders';
|
||||
export const MY_ACCOUNT_DOWNLOADS = baseUrl + 'my-account/downloads';
|
||||
export const MY_ACCOUNT_ADDRESSES = baseUrl + 'my-account/edit-address';
|
||||
export const MY_ACCOUNT_ACCOUNT_DETAILS = baseUrl + 'my-account/edit-account';
|
||||
/**
|
||||
* Test control flags.
|
||||
* @type {boolean}
|
||||
*/
|
||||
export const IS_RETEST_MODE = process.env.E2E_RETEST == '1';
|
||||
|
|
|
@ -5,10 +5,12 @@ const flowConstants = require( './constants' );
|
|||
const flowExpressions = require( './expressions' );
|
||||
const merchant = require( './merchant' );
|
||||
const shopper = require( './shopper' );
|
||||
const { withRestApi } = require( './with-rest-api' );
|
||||
|
||||
module.exports = {
|
||||
...flowConstants,
|
||||
...flowExpressions,
|
||||
merchant,
|
||||
shopper,
|
||||
withRestApi,
|
||||
};
|
||||
|
|
|
@ -18,11 +18,13 @@ const {
|
|||
WP_ADMIN_PERMALINK_SETTINGS,
|
||||
WP_ADMIN_PLUGINS,
|
||||
WP_ADMIN_SETUP_WIZARD,
|
||||
WP_ADMIN_WC_HOME,
|
||||
WP_ADMIN_WC_SETTINGS,
|
||||
WP_ADMIN_NEW_SHIPPING_ZONE,
|
||||
WP_ADMIN_ANALYTICS_PAGES,
|
||||
WP_ADMIN_ALL_USERS_VIEW,
|
||||
WP_ADMIN_IMPORT_PRODUCTS,
|
||||
IS_RETEST_MODE,
|
||||
} = require( './constants' );
|
||||
|
||||
const baseUrl = config.get( 'url' );
|
||||
|
@ -120,7 +122,8 @@ const merchant = {
|
|||
},
|
||||
|
||||
runSetupWizard: async () => {
|
||||
await page.goto( WP_ADMIN_SETUP_WIZARD, {
|
||||
const setupWizard = IS_RETEST_MODE ? WP_ADMIN_SETUP_WIZARD : WP_ADMIN_WC_HOME;
|
||||
await page.goto( setupWizard, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
import factories from '../factories';
|
||||
import {Coupon, Setting, SimpleProduct} from '@woocommerce/api';
|
||||
|
||||
const client = factories.api.withDefaultPermalinks;
|
||||
const onboardingProfileEndpoint = '/wc-admin/onboarding/profile';
|
||||
const shippingZoneEndpoint = '/wc/v3/shipping/zones';
|
||||
const userEndpoint = '/wp/v2/users';
|
||||
|
||||
/**
|
||||
* Utility function to delete all merchant created data store objects.
|
||||
*
|
||||
* @param repository
|
||||
* @param defaultObjectId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const deleteAllRepositoryObjects = async ( repository, defaultObjectId = null ) => {
|
||||
let objects;
|
||||
const minimum = defaultObjectId == null ? 0 : 1;
|
||||
|
||||
objects = await repository.list();
|
||||
while ( objects.length > minimum ) {
|
||||
for (let o = 0; o < objects.length; o++ ) {
|
||||
// Skip default data store object
|
||||
if ( objects[ o ].id == defaultObjectId ) {
|
||||
continue;
|
||||
}
|
||||
await repository.delete( objects[ o ].id );
|
||||
}
|
||||
objects = await repository.list();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility functions that use the REST API to process the requested function.
|
||||
*/
|
||||
export const withRestApi = {
|
||||
/**
|
||||
* Reset onboarding to equivalent of new site.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
resetOnboarding: async () => {
|
||||
const onboardingReset = {
|
||||
completed: false,
|
||||
industry: [],
|
||||
business_extensions: [],
|
||||
skipped: false,
|
||||
product_types: [],
|
||||
product_count: '0',
|
||||
selling_venues: 'no',
|
||||
revenue: 'none',
|
||||
theme: '',
|
||||
setup_client: false,
|
||||
wccom_connected: false,
|
||||
};
|
||||
|
||||
const response = await client.put( onboardingProfileEndpoint, onboardingReset );
|
||||
expect( response.statusCode ).toEqual( 200 );
|
||||
},
|
||||
/**
|
||||
* Use api package to delete coupons.
|
||||
*
|
||||
* @return {Promise} Promise resolving once coupons have been deleted.
|
||||
*/
|
||||
deleteAllCoupons: async () => {
|
||||
const repository = Coupon.restRepository( client );
|
||||
await deleteAllRepositoryObjects( repository );
|
||||
},
|
||||
/**
|
||||
* Use api package to delete products.
|
||||
*
|
||||
* @return {Promise} Promise resolving once products have been deleted.
|
||||
*/
|
||||
deleteAllProducts: async () => {
|
||||
const repository = SimpleProduct.restRepository( client );
|
||||
await deleteAllRepositoryObjects( repository );
|
||||
},
|
||||
/**
|
||||
* Use api package to delete shipping zones.
|
||||
*
|
||||
* @return {Promise} Promise resolving once shipping zones have been deleted.
|
||||
*/
|
||||
deleteAllShippingZones: async () => {
|
||||
const shippingZones = await client.get( shippingZoneEndpoint );
|
||||
if ( shippingZones.data && shippingZones.data.length ) {
|
||||
for ( let z = 0; z < shippingZones.data.length; z++ ) {
|
||||
// The data store doesn't support deleting the default zone.
|
||||
if ( shippingZones.data[z].id == 0 ) {
|
||||
continue;
|
||||
}
|
||||
const response = await client.delete( shippingZoneEndpoint + `/${shippingZones.data[z].id}?force=true` );
|
||||
expect( response.statusCode ).toBe( 200 );
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Delete a customer account by their email address if the user exists.
|
||||
*
|
||||
* @param emailAddress Customer user account email address.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
deleteCustomerByEmail: async ( emailAddress ) => {
|
||||
const query = {
|
||||
search: emailAddress,
|
||||
context: 'edit',
|
||||
};
|
||||
const customers = await client.get( userEndpoint, query );
|
||||
|
||||
if ( customers.data && customers.data.length ) {
|
||||
for ( let c = 0; c < customers.data.length; c++ ) {
|
||||
const deleteUser = {
|
||||
id: customers.data[c].id,
|
||||
force: true,
|
||||
reassign: 1,
|
||||
}
|
||||
await client.delete( userEndpoint + `/${ deleteUser.id }`, deleteUser );
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Reset a settings group to default values except selects.
|
||||
* @param settingsGroup
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
resetSettingsGroupToDefault: async ( settingsGroup ) => {
|
||||
const settingsClient = Setting.restRepository( client );
|
||||
const settings = await settingsClient.list( settingsGroup );
|
||||
if ( ! settings.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( let s = 0; s < settings.length; s++ ) {
|
||||
// The rest api doesn't allow selects to be set to ''.
|
||||
if ( settings[s].type == 'select' && settings[s].default == '' ) {
|
||||
continue;
|
||||
}
|
||||
const defaultSetting = {
|
||||
group_id: settingsGroup,
|
||||
id: settings[s].id,
|
||||
value: settings[s].default,
|
||||
};
|
||||
|
||||
const response = await settingsClient.update( settingsGroup, defaultSetting.id, defaultSetting );
|
||||
// Multi-selects have a default '' but return an empty [].
|
||||
if ( settings[s].type != 'multiselect' ) {
|
||||
expect( response.value ).toBe( defaultSetting.value );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -9,7 +9,7 @@ import { pressKeyWithModifier } from '@wordpress/e2e-test-utils';
|
|||
* @param {string} selector
|
||||
* @param {string} value
|
||||
*/
|
||||
const clearAndFillInput = async ( selector, value ) => {
|
||||
export const clearAndFillInput = async ( selector, value ) => {
|
||||
await page.waitForSelector( selector );
|
||||
await page.focus( selector );
|
||||
await pressKeyWithModifier( 'primary', 'a' );
|
||||
|
@ -21,14 +21,14 @@ const clearAndFillInput = async ( selector, value ) => {
|
|||
*
|
||||
* @param {string} tabName Tab label
|
||||
*/
|
||||
const clickTab = async ( tabName ) => {
|
||||
export const clickTab = async ( tabName ) => {
|
||||
await expect( page ).toClick( '.wc-tabs > li > a', { text: tabName } );
|
||||
};
|
||||
|
||||
/**
|
||||
* Save changes on a WooCommerce settings page.
|
||||
*/
|
||||
const settingsPageSaveChanges = async () => {
|
||||
export const settingsPageSaveChanges = async () => {
|
||||
await page.focus( 'button.woocommerce-save-button' );
|
||||
await Promise.all( [
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
|
@ -39,7 +39,7 @@ const settingsPageSaveChanges = async () => {
|
|||
/**
|
||||
* Save changes on Permalink settings page.
|
||||
*/
|
||||
const permalinkSettingsPageSaveChanges = async () => {
|
||||
export const permalinkSettingsPageSaveChanges = async () => {
|
||||
await page.focus( '.wp-core-ui .button-primary' );
|
||||
await Promise.all( [
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
|
@ -52,7 +52,7 @@ const permalinkSettingsPageSaveChanges = async () => {
|
|||
*
|
||||
* @param {string} selector
|
||||
*/
|
||||
const setCheckbox = async( selector ) => {
|
||||
export const setCheckbox = async( selector ) => {
|
||||
await page.focus( selector );
|
||||
const checkbox = await page.$( selector );
|
||||
const checkboxStatus = ( await ( await checkbox.getProperty( 'checked' ) ).jsonValue() );
|
||||
|
@ -66,7 +66,7 @@ const setCheckbox = async( selector ) => {
|
|||
*
|
||||
* @param {string} selector
|
||||
*/
|
||||
const unsetCheckbox = async( selector ) => {
|
||||
export const unsetCheckbox = async( selector ) => {
|
||||
await page.focus( selector );
|
||||
const checkbox = await page.$( selector );
|
||||
const checkboxStatus = ( await ( await checkbox.getProperty( 'checked' ) ).jsonValue() );
|
||||
|
@ -78,7 +78,7 @@ const unsetCheckbox = async( selector ) => {
|
|||
/**
|
||||
* Wait for UI blocking to end.
|
||||
*/
|
||||
const uiUnblocked = async () => {
|
||||
export const uiUnblocked = async () => {
|
||||
await page.waitForFunction( () => ! Boolean( document.querySelector( '.blockUI' ) ) );
|
||||
};
|
||||
|
||||
|
@ -90,7 +90,7 @@ const uiUnblocked = async () => {
|
|||
* @param {string} publishVerification
|
||||
* @param {string} trashVerification
|
||||
*/
|
||||
const verifyPublishAndTrash = async ( button, publishNotice, publishVerification, trashVerification ) => {
|
||||
export const verifyPublishAndTrash = async ( button, publishNotice, publishVerification, trashVerification ) => {
|
||||
// Wait for auto save
|
||||
await page.waitFor( 2000 );
|
||||
|
||||
|
@ -124,7 +124,7 @@ const verifyPublishAndTrash = async ( button, publishNotice, publishVerification
|
|||
*
|
||||
* @param {string} selector Selector of the checkbox that needs to be verified.
|
||||
*/
|
||||
const verifyCheckboxIsSet = async( selector ) => {
|
||||
export const verifyCheckboxIsSet = async( selector ) => {
|
||||
await page.focus( selector );
|
||||
const checkbox = await page.$( selector );
|
||||
const checkboxStatus = ( await ( await checkbox.getProperty( 'checked' ) ).jsonValue() );
|
||||
|
@ -136,7 +136,7 @@ const verifyCheckboxIsSet = async( selector ) => {
|
|||
*
|
||||
* @param {string} selector Selector of the checkbox that needs to be verified.
|
||||
*/
|
||||
const verifyCheckboxIsUnset = async( selector ) => {
|
||||
export const verifyCheckboxIsUnset = async( selector ) => {
|
||||
await page.focus( selector );
|
||||
const checkbox = await page.$( selector );
|
||||
const checkboxStatus = ( await ( await checkbox.getProperty( 'checked' ) ).jsonValue() );
|
||||
|
@ -149,7 +149,7 @@ const verifyCheckboxIsUnset = async( selector ) => {
|
|||
* @param {string} selector Selector of the input field that needs to be verified.
|
||||
* @param {string} value Value of the input field that needs to be verified.
|
||||
*/
|
||||
const verifyValueOfInputField = async( selector, value ) => {
|
||||
export const verifyValueOfInputField = async( selector, value ) => {
|
||||
await page.focus( selector );
|
||||
const field = await page.$( selector );
|
||||
const fieldValue = ( await ( await field.getProperty( 'value' ) ).jsonValue() );
|
||||
|
@ -161,7 +161,7 @@ const verifyValueOfInputField = async( selector, value ) => {
|
|||
*
|
||||
* @param {string} selector Selector of the filter link to be clicked.
|
||||
*/
|
||||
const clickFilter = async ( selector ) => {
|
||||
export const clickFilter = async ( selector ) => {
|
||||
await page.waitForSelector( selector );
|
||||
await page.focus( selector );
|
||||
await Promise.all( [
|
||||
|
@ -175,7 +175,7 @@ const clickFilter = async ( selector ) => {
|
|||
*
|
||||
* If there's more than 20 items, it moves all 20 items on the current page.
|
||||
*/
|
||||
const moveAllItemsToTrash = async () => {
|
||||
export const moveAllItemsToTrash = async () => {
|
||||
await setCheckbox( '#cb-select-all-1' );
|
||||
await expect( page ).toSelect( '#bulk-action-selector-top', 'Move to Trash' );
|
||||
await Promise.all( [
|
||||
|
@ -191,7 +191,7 @@ const moveAllItemsToTrash = async () => {
|
|||
*
|
||||
* @param {string} selector Selector of the filter link to be clicked.
|
||||
*/
|
||||
const evalAndClick = async ( selector ) => {
|
||||
export const evalAndClick = async ( selector ) => {
|
||||
// We use this when `expect(page).toClick()` is unable to find the element
|
||||
// See: https://github.com/puppeteer/puppeteer/issues/1769#issuecomment-637645219
|
||||
page.$eval( selector, elem => elem.click() );
|
||||
|
@ -203,7 +203,7 @@ const evalAndClick = async ( selector ) => {
|
|||
* @param {string} value Value of what to be selected
|
||||
* @param {string} selector Selector of the select2 search field
|
||||
*/
|
||||
const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__field' ) => {
|
||||
export const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__field' ) => {
|
||||
await page.waitForSelector(selector);
|
||||
await page.click(selector);
|
||||
await page.type(selector, value);
|
||||
|
@ -218,7 +218,7 @@ const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__f
|
|||
* @param {string} orderId Order ID
|
||||
* @param {string} customerName Customer's full name attached to order ID.
|
||||
*/
|
||||
const searchForOrder = async (value, orderId, customerName) => {
|
||||
export const searchForOrder = async (value, orderId, customerName) => {
|
||||
await clearAndFillInput('#post-search-input', value);
|
||||
await expect(page).toMatchElement('#post-search-input', value);
|
||||
await expect(page).toClick('#search-submit');
|
||||
|
@ -234,7 +234,7 @@ const searchForOrder = async (value, orderId, customerName) => {
|
|||
* @param couponCode string
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const applyCoupon = async ( couponCode ) => {
|
||||
export const applyCoupon = async ( couponCode ) => {
|
||||
try {
|
||||
await expect(page).toClick('a', {text: 'Click here to enter your code'});
|
||||
await uiUnblocked();
|
||||
|
@ -254,7 +254,7 @@ const applyCoupon = async ( couponCode ) => {
|
|||
* @param couponCode Coupon name.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const removeCoupon = async ( couponCode ) => {
|
||||
export const removeCoupon = async ( couponCode ) => {
|
||||
await expect(page).toClick('[data-coupon="'+couponCode.toLowerCase()+'"]', {text: '[Remove]'});
|
||||
await uiUnblocked();
|
||||
await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon has been removed.'});
|
||||
|
@ -266,32 +266,10 @@ const removeCoupon = async ( couponCode ) => {
|
|||
*
|
||||
* @param {string} action The action to take on the order.
|
||||
*/
|
||||
const selectOrderAction = async ( action ) => {
|
||||
export const selectOrderAction = async ( action ) => {
|
||||
await page.select( 'select[name=wc_order_action]', action );
|
||||
await Promise.all( [
|
||||
page.click( '.wc-reload' ),
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
}
|
||||
|
||||
export {
|
||||
clearAndFillInput,
|
||||
clickTab,
|
||||
settingsPageSaveChanges,
|
||||
permalinkSettingsPageSaveChanges,
|
||||
setCheckbox,
|
||||
unsetCheckbox,
|
||||
uiUnblocked,
|
||||
verifyPublishAndTrash,
|
||||
verifyCheckboxIsSet,
|
||||
verifyCheckboxIsUnset,
|
||||
verifyValueOfInputField,
|
||||
clickFilter,
|
||||
moveAllItemsToTrash,
|
||||
evalAndClick,
|
||||
selectOptionInSelect2,
|
||||
searchForOrder,
|
||||
applyCoupon,
|
||||
removeCoupon,
|
||||
selectOrderAction,
|
||||
};
|
||||
|
|
|
@ -17,15 +17,15 @@ class WC_Helper_Customer {
|
|||
'id' => 0,
|
||||
'date_modified' => null,
|
||||
'country' => 'US',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'city' => 'San Francisco',
|
||||
'address' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'shipping_country' => 'US',
|
||||
'shipping_state' => 'PA',
|
||||
'shipping_postcode' => '19123',
|
||||
'shipping_city' => 'Philadelphia',
|
||||
'shipping_state' => 'CA',
|
||||
'shipping_postcode' => '94110',
|
||||
'shipping_city' => 'San Francisco',
|
||||
'shipping_address' => '123 South Street',
|
||||
'shipping_address_2' => 'Apt 1',
|
||||
'is_vat_exempt' => false,
|
||||
|
@ -46,15 +46,15 @@ class WC_Helper_Customer {
|
|||
$customer = new WC_Customer();
|
||||
$customer->set_billing_country( 'US' );
|
||||
$customer->set_first_name( 'Justin' );
|
||||
$customer->set_billing_state( 'PA' );
|
||||
$customer->set_billing_postcode( '19123' );
|
||||
$customer->set_billing_city( 'Philadelphia' );
|
||||
$customer->set_billing_state( 'CA' );
|
||||
$customer->set_billing_postcode( '94110' );
|
||||
$customer->set_billing_city( 'San Francisco' );
|
||||
$customer->set_billing_address( '123 South Street' );
|
||||
$customer->set_billing_address_2( 'Apt 1' );
|
||||
$customer->set_shipping_country( 'US' );
|
||||
$customer->set_shipping_state( 'PA' );
|
||||
$customer->set_shipping_postcode( '19123' );
|
||||
$customer->set_shipping_city( 'Philadelphia' );
|
||||
$customer->set_shipping_state( 'CA' );
|
||||
$customer->set_shipping_postcode( '94110' );
|
||||
$customer->set_shipping_city( 'San Francisco' );
|
||||
$customer->set_shipping_address( '123 South Street' );
|
||||
$customer->set_shipping_address_2( 'Apt 1' );
|
||||
$customer->set_username( $username );
|
||||
|
@ -70,7 +70,7 @@ class WC_Helper_Customer {
|
|||
* @return array
|
||||
*/
|
||||
public static function get_expected_store_location() {
|
||||
return array( 'GB', '', '', '' );
|
||||
return array( 'US', 'CA', '', '' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -179,7 +179,7 @@ class WC_Tests_Account_Functions extends WC_Unit_Test_Case {
|
|||
public function test_wc_get_account_formatted_address() {
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
|
||||
$this->assertEquals( '123 South Street<br/>Apt 1<br/>Philadelphia, PA 19123<br/>United States (US)', wc_get_account_formatted_address( 'billing', $customer->get_id() ) );
|
||||
$this->assertEquals( '123 South Street<br/>Apt 1<br/>San Francisco, CA 94110', wc_get_account_formatted_address( 'billing', $customer->get_id() ) );
|
||||
|
||||
$customer->delete( true );
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Tests\Countries
|
||||
*/
|
||||
|
||||
// phpcs:disable WordPress.Files.FileName
|
||||
|
||||
/**
|
||||
* WC_Countries tests.
|
||||
*/
|
||||
|
@ -178,7 +180,7 @@ class WC_Tests_Countries extends WC_Unit_Test_Case {
|
|||
update_option( 'woocommerce_default_country', 'NO' );
|
||||
$this->assertEquals( 'VAT', $countries->tax_or_vat() );
|
||||
|
||||
update_option( 'woocommerce_default_country', 'US' );
|
||||
update_option( 'woocommerce_default_country', 'US:CA' );
|
||||
$this->assertEquals( 'Tax', $countries->tax_or_vat() );
|
||||
}
|
||||
|
||||
|
|
|
@ -324,16 +324,16 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
|
|||
update_option( 'woocommerce_tax_based_on', 'shipping' );
|
||||
$taxable = $customer->get_taxable_address();
|
||||
$this->assertEquals( 'US', $taxable[0] );
|
||||
$this->assertEquals( 'PA', $taxable[1] );
|
||||
$this->assertEquals( 'CA', $taxable[1] );
|
||||
$this->assertEquals( '11111', $taxable[2] );
|
||||
$this->assertEquals( 'Test', $taxable[3] );
|
||||
|
||||
update_option( 'woocommerce_tax_based_on', 'billing' );
|
||||
$taxable = $customer->get_taxable_address();
|
||||
$this->assertEquals( 'US', $taxable[0] );
|
||||
$this->assertEquals( 'PA', $taxable[1] );
|
||||
$this->assertEquals( '19123', $taxable[2] );
|
||||
$this->assertEquals( 'Philadelphia', $taxable[3] );
|
||||
$this->assertEquals( 'CA', $taxable[1] );
|
||||
$this->assertEquals( '94110', $taxable[2] );
|
||||
$this->assertEquals( 'San Francisco', $taxable[3] );
|
||||
|
||||
update_option( 'woocommerce_tax_based_on', 'base' );
|
||||
$taxable = $customer->get_taxable_address();
|
||||
|
@ -431,7 +431,7 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_customer_is_customer_outside_base() {
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$this->assertTrue( $customer->is_customer_outside_base() );
|
||||
$this->assertFalse( $customer->is_customer_outside_base() );
|
||||
update_option( 'woocommerce_tax_based_on', 'base' );
|
||||
$customer->set_billing_address_to_base();
|
||||
$this->assertFalse( $customer->is_customer_outside_base() );
|
||||
|
@ -444,9 +444,9 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
|
|||
public function test_customer_sessions() {
|
||||
$session = WC_Helper_Customer::create_mock_customer(); // set into session....
|
||||
|
||||
$this->assertEquals( '19123', $session->get_billing_postcode() );
|
||||
$this->assertEquals( '94110', $session->get_billing_postcode() );
|
||||
$this->assertEquals( '123 South Street', $session->get_billing_address() );
|
||||
$this->assertEquals( 'Philadelphia', $session->get_billing_city() );
|
||||
$this->assertEquals( 'San Francisco', $session->get_billing_city() );
|
||||
|
||||
$session->set_billing_address( '124 South Street' );
|
||||
$session->save();
|
||||
|
|
|
@ -83,7 +83,7 @@ class WC_Tests_Customer extends WC_Unit_Test_Case {
|
|||
// Customer is going with the Free Shipping option, and the store calculates tax based on the customer's billing address.
|
||||
WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) );
|
||||
WC_Helper_Customer::set_tax_based_on( 'billing' );
|
||||
$this->assertEquals( $customer->is_customer_outside_base(), true );
|
||||
$this->assertEquals( $customer->is_customer_outside_base(), false );
|
||||
|
||||
// Customer is going with the Free Shipping option, and the store calculates tax based on the store base location.
|
||||
WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) );
|
||||
|
|
|
@ -618,7 +618,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
// Ex tax label.
|
||||
$calc_taxes = get_option( 'woocommerce_calc_taxes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. VAT)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. tax)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
||||
update_option( 'woocommerce_calc_taxes', $calc_taxes );
|
||||
}
|
||||
|
||||
|
|
|
@ -1245,7 +1245,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$order->set_billing_country( 'US' );
|
||||
$order->set_billing_city( 'Portland' );
|
||||
$order->set_billing_postcode( '97266' );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266<br/>United States (US)', $order->get_formatted_billing_address( 'none' ) );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266', $order->get_formatted_billing_address( 'none' ) );
|
||||
|
||||
$this->assertTrue( $order->has_billing_address() );
|
||||
$this->assertFalse( $order->has_shipping_address() );
|
||||
|
@ -1265,7 +1265,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$order->set_shipping_country( 'US' );
|
||||
$order->set_shipping_city( 'Portland' );
|
||||
$order->set_shipping_postcode( '97266' );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266<br/>United States (US)', $order->get_formatted_shipping_address( 'none' ) );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266', $order->get_formatted_shipping_address( 'none' ) );
|
||||
|
||||
$this->assertFalse( $order->has_billing_address() );
|
||||
$this->assertTrue( $order->has_shipping_address() );
|
||||
|
@ -1498,7 +1498,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$object->set_billing_state( 'Boulder' );
|
||||
$object->set_billing_postcode( '00001' );
|
||||
$object->set_billing_country( 'US' );
|
||||
$this->assertEquals( 'Fred Flintstone<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001<br/>United States (US)', $object->get_formatted_billing_address() );
|
||||
$this->assertEquals( 'Fred Flintstone<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001', $object->get_formatted_billing_address() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1515,7 +1515,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$object->set_shipping_state( 'Boulder' );
|
||||
$object->set_shipping_postcode( '00001' );
|
||||
$object->set_shipping_country( 'US' );
|
||||
$this->assertEquals( 'Barney Rubble<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001<br/>United States (US)', $object->get_formatted_shipping_address() );
|
||||
$this->assertEquals( 'Barney Rubble<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001', $object->get_formatted_shipping_address() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,15 +86,15 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
|
|||
),
|
||||
array(
|
||||
'name' => 'Billing City',
|
||||
'value' => 'Philadelphia',
|
||||
'value' => 'San Francisco',
|
||||
),
|
||||
array(
|
||||
'name' => 'Billing Postal/Zip Code',
|
||||
'value' => '19123',
|
||||
'value' => '94110',
|
||||
),
|
||||
array(
|
||||
'name' => 'Billing State',
|
||||
'value' => 'PA',
|
||||
'value' => 'CA',
|
||||
),
|
||||
array(
|
||||
'name' => 'Billing Country / Region',
|
||||
|
@ -114,15 +114,15 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
|
|||
),
|
||||
array(
|
||||
'name' => 'Shipping City',
|
||||
'value' => 'Philadelphia',
|
||||
'value' => 'San Francisco',
|
||||
),
|
||||
array(
|
||||
'name' => 'Shipping Postal/Zip Code',
|
||||
'value' => '19123',
|
||||
'value' => '94110',
|
||||
),
|
||||
array(
|
||||
'name' => 'Shipping State',
|
||||
'value' => 'PA',
|
||||
'value' => 'CA',
|
||||
),
|
||||
array(
|
||||
'name' => 'Shipping Country / Region',
|
||||
|
|
|
@ -26,15 +26,15 @@ class CustomerHelper {
|
|||
'id' => 0,
|
||||
'date_modified' => null,
|
||||
'country' => 'US',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'city' => 'San Francisco',
|
||||
'address' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'shipping_country' => 'US',
|
||||
'shipping_state' => 'PA',
|
||||
'shipping_postcode' => '19123',
|
||||
'shipping_city' => 'Philadelphia',
|
||||
'shipping_state' => 'CA',
|
||||
'shipping_postcode' => '94110',
|
||||
'shipping_city' => 'San Francisco',
|
||||
'shipping_address' => '123 South Street',
|
||||
'shipping_address_2' => 'Apt 1',
|
||||
'is_vat_exempt' => false,
|
||||
|
@ -55,15 +55,15 @@ class CustomerHelper {
|
|||
$customer = new WC_Customer();
|
||||
$customer->set_billing_country( 'US' );
|
||||
$customer->set_first_name( 'Justin' );
|
||||
$customer->set_billing_state( 'PA' );
|
||||
$customer->set_billing_postcode( '19123' );
|
||||
$customer->set_billing_city( 'Philadelphia' );
|
||||
$customer->set_billing_state( 'CA' );
|
||||
$customer->set_billing_postcode( '94110' );
|
||||
$customer->set_billing_city( 'San Francisco' );
|
||||
$customer->set_billing_address( '123 South Street' );
|
||||
$customer->set_billing_address_2( 'Apt 1' );
|
||||
$customer->set_shipping_country( 'US' );
|
||||
$customer->set_shipping_state( 'PA' );
|
||||
$customer->set_shipping_postcode( '19123' );
|
||||
$customer->set_shipping_city( 'Philadelphia' );
|
||||
$customer->set_shipping_state( 'CA' );
|
||||
$customer->set_shipping_postcode( '94110' );
|
||||
$customer->set_shipping_city( 'San Francisco' );
|
||||
$customer->set_shipping_address( '123 South Street' );
|
||||
$customer->set_shipping_address_2( 'Apt 1' );
|
||||
$customer->set_username( $username );
|
||||
|
@ -79,7 +79,7 @@ class CustomerHelper {
|
|||
* @return array
|
||||
*/
|
||||
public static function get_expected_store_location() {
|
||||
return array( 'GB', '', '', '' );
|
||||
return array( 'US', 'CA', '', '' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,9 +70,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
'email' => '',
|
||||
'phone' => '',
|
||||
|
@ -83,9 +83,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
),
|
||||
'is_paying_customer' => false,
|
||||
|
@ -315,9 +315,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
'email' => '',
|
||||
'phone' => '',
|
||||
|
@ -328,9 +328,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
),
|
||||
'is_paying_customer' => false,
|
||||
|
|
|
@ -77,9 +77,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
'email' => '',
|
||||
'phone' => '',
|
||||
|
@ -90,9 +90,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
),
|
||||
'is_paying_customer' => false,
|
||||
|
@ -147,9 +147,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
'email' => '',
|
||||
'phone' => '',
|
||||
|
@ -160,9 +160,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
),
|
||||
'is_paying_customer' => false,
|
||||
|
@ -387,9 +387,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
'email' => '',
|
||||
'phone' => '',
|
||||
|
@ -400,9 +400,9 @@ class Customers extends WC_REST_Unit_Test_Case {
|
|||
'company' => '',
|
||||
'address_1' => '123 South Street',
|
||||
'address_2' => 'Apt 1',
|
||||
'city' => 'Philadelphia',
|
||||
'state' => 'PA',
|
||||
'postcode' => '19123',
|
||||
'city' => 'San Francisco',
|
||||
'state' => 'CA',
|
||||
'postcode' => '94110',
|
||||
'country' => 'US',
|
||||
),
|
||||
'is_paying_customer' => false,
|
||||
|
|
|
@ -117,8 +117,8 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_get_base_tax_rates() {
|
||||
$tax_rate = array(
|
||||
'tax_rate_country' => 'GB',
|
||||
'tax_rate_state' => '',
|
||||
'tax_rate_country' => 'US',
|
||||
'tax_rate_state' => 'CA',
|
||||
'tax_rate' => '20.0000',
|
||||
'tax_rate_name' => 'VAT',
|
||||
'tax_rate_priority' => '1',
|
||||
|
|
|
@ -348,8 +348,8 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
|
|||
public function test_wc_get_base_location() {
|
||||
$default = wc_get_base_location();
|
||||
|
||||
$this->assertEquals( 'GB', $default['country'] );
|
||||
$this->assertEquals( '', $default['state'] );
|
||||
$this->assertEquals( 'US', $default['country'] );
|
||||
$this->assertEquals( 'CA', $default['state'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue