Merge branch 'trunk' of https://github.com/woocommerce/woocommerce into fix/update-api-tests-package-lock
This commit is contained in:
commit
8da357f1dc
|
@ -731,10 +731,26 @@
|
|||
margin: 14px 64px 0 0;
|
||||
max-width: 389px;
|
||||
}
|
||||
|
||||
.product-developed-by {
|
||||
color: #50575e; // Gray 60
|
||||
font-size: 12px;
|
||||
font-family: sans-serif;
|
||||
line-height: 20px;
|
||||
margin-top: 4px;
|
||||
|
||||
.product-vendor-link {
|
||||
color: #50575e; // Gray 60
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.product-footer {
|
||||
align-items: center;
|
||||
border-top: 1px solid #dcdcde;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding: 24px;
|
||||
|
||||
.price {
|
||||
|
@ -742,32 +758,78 @@
|
|||
color: #1d2327;
|
||||
}
|
||||
|
||||
.price-suffix {
|
||||
color: #646970; // Gray 50
|
||||
}
|
||||
|
||||
.product-reviews-block {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 4px;
|
||||
|
||||
.product-rating-star {
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
height: 16px;
|
||||
margin: 4px 4px 4px 0;
|
||||
width: 17px;
|
||||
|
||||
&__fill {
|
||||
background-image: url(../images/icons/star-golden.svg);
|
||||
}
|
||||
|
||||
&__half-fill {
|
||||
background-image: url(../images/icons/star-half-filled.svg);
|
||||
}
|
||||
|
||||
&__no-fill {
|
||||
background-image: url(../images/icons/star-gray.svg);
|
||||
}
|
||||
}
|
||||
|
||||
.product-reviews-count {
|
||||
color: #646970; // Gray 50
|
||||
font-size: 12px;
|
||||
font-family: sans-serif;
|
||||
line-height: 24px;
|
||||
letter-spacing: -0.154px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.button {
|
||||
background-color: #fff;
|
||||
border-color: #007cba;
|
||||
color: #007cba;
|
||||
float: right;
|
||||
height: 22px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.storefront {
|
||||
max-width: 990px;
|
||||
background: url(../images/storefront-bg.jpg) bottom right #f6f6f6;
|
||||
border: 1px solid #ddd;
|
||||
margin-top: 1em;
|
||||
padding: 20px;
|
||||
margin: 1em auto;
|
||||
padding: 24px;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
|
||||
img {
|
||||
width: 278px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
height: auto;
|
||||
float: left;
|
||||
margin: 0 20px 0 0;
|
||||
margin: 0 auto 16px;
|
||||
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
p:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: 750px;
|
||||
}
|
||||
|
@ -7690,5 +7752,18 @@ table.bar_chart {
|
|||
.marketplace-header {
|
||||
padding-left: 84px;
|
||||
}
|
||||
|
||||
.storefront {
|
||||
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
float: left;
|
||||
margin: 0 16px 0 auto;
|
||||
width: 278px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16.27"
|
||||
height="15.39"
|
||||
viewBox="0 0 16.270002 15.39"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="m 8.1376662,11.759108 5.0199998,3.6 -1.9214,-5.8133003 5.02,-3.52 h -6.1566 L 8.1376662,0.02580769 6.1757662,6.0258077 H 0.01919622 l 5.01994998,3.52 -1.92139,5.8133003 z"
|
||||
fill="#f0c930" />
|
||||
</svg>
|
After Width: | Height: | Size: 424 B |
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16.27"
|
||||
height="15.39"
|
||||
viewBox="0 0 16.270002 15.39"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="m 8.1376662,11.759108 5.0199998,3.6 -1.9214,-5.8133003 5.02,-3.52 h -6.1566 L 8.1376662,0.02580769 6.1757662,6.0258077 H 0.01919622 l 5.01994998,3.52 -1.92139,5.8133003 z"
|
||||
fill="#a7aaad" />
|
||||
</svg>
|
After Width: | Height: | Size: 424 B |
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16.27"
|
||||
height="15.39"
|
||||
viewBox="0 0 16.270002 15.39"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<linearGradient id="gradient">
|
||||
<stop offset="50%" stop-color="#f0c930"/>
|
||||
<stop offset="50%" stop-color="#a7aaad" stop-opacity="1"/>
|
||||
</linearGradient>
|
||||
<path
|
||||
d="m 8.1376662,11.759108 5.0199998,3.6 -1.9214,-5.8133003 5.02,-3.52 h -6.1566 L 8.1376662,0.02580769 6.1757662,6.0258077 H 0.01919622 l 5.01994998,3.52 -1.92139,5.8133003 z"
|
||||
fill="url(#gradient)"
|
||||
/>
|
||||
</svg>
|
After Width: | Height: | Size: 588 B |
|
@ -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": "1a8d9b536eba5d14612c538b56803186",
|
||||
"content-hash": "ed397d52c25da204154232b3dd4b529f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "automattic/jetpack-autoloader",
|
||||
|
|
|
@ -882,6 +882,40 @@ class WC_Admin_Addons {
|
|||
return " $admin_body_class woocommerce-page-wc-marketplace ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine which class should be used for a rating star:
|
||||
* - golden
|
||||
* - half-filled (50/50 golden and gray)
|
||||
* - gray
|
||||
*
|
||||
* Consider ratings from 3.0 to 4.0 as an example
|
||||
* 3.0 will produce 3 stars
|
||||
* 3.1 to 3.5 will produce 3 stars and a half star
|
||||
* 3.6 to 4.0 will product 4 stars
|
||||
*
|
||||
* @param float $rating Rating of a product.
|
||||
* @param int $index Index of a star in a row.
|
||||
*
|
||||
* @return string CSS class to use.
|
||||
*/
|
||||
public static function get_star_class( $rating, $index ) {
|
||||
if ( $rating >= $index ) {
|
||||
// Rating more that current star to show.
|
||||
return 'fill';
|
||||
} else if (
|
||||
abs( $index - 1 - floor( $rating ) ) < 0.0000001 &&
|
||||
0 < ( $rating - floor( $rating ) )
|
||||
) {
|
||||
// For rating more than x.0 and less than x.5 or equal it will show a half star.
|
||||
return 50 >= floor( ( $rating - floor( $rating ) ) * 100 )
|
||||
? 'half-fill'
|
||||
: 'fill';
|
||||
}
|
||||
|
||||
// Don't show a golden star otherwise.
|
||||
return 'no-fill';
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an action object and return the URL based on properties of the action.
|
||||
*
|
||||
|
|
|
@ -63,4 +63,5 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
do_action( 'woocommerce_product_options_shipping' );
|
||||
?>
|
||||
</div>
|
||||
<?php do_action( 'woocommerce_product_options_shipping_product_data' ); ?>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
}
|
||||
|
||||
$current_section_name = __( 'Browse Categories', 'woocommerce' );
|
||||
|
||||
?>
|
||||
<div class="woocommerce wc-addons-wrap">
|
||||
<h1 class="screen-reader-text"><?php esc_html_e( 'Marketplace', 'woocommerce' ); ?></h1>
|
||||
|
@ -118,21 +117,74 @@ $current_section_name = __( 'Browse Categories', 'woocommerce' );
|
|||
?>
|
||||
<li class="product">
|
||||
<div class="product-details">
|
||||
<?php if ( ! empty( $addon->image ) ) : ?>
|
||||
<span class="product-img-wrap"><img src="<?php echo esc_url( $addon->image ); ?>" /></span>
|
||||
<?php if ( ! empty( $addon->icon ) ) : ?>
|
||||
<span class="product-img-wrap">
|
||||
<?php /* Show an icon if it exists */ ?>
|
||||
<img src="<?php echo esc_url( $addon->icon ); ?>" />
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url( WC_Admin_Addons::add_in_app_purchase_url_params( $addon->link ) ); ?>">
|
||||
<h2><?php echo esc_html( $addon->title ); ?></h2>
|
||||
</a>
|
||||
<?php if ( ! empty( $addon->vendor_name ) && ! empty( $addon->vendor_url ) ) : ?>
|
||||
<div class="product-developed-by">
|
||||
<?php
|
||||
$parsed_vendor_url = parse_url( $addon->vendor_url );
|
||||
if ( null == $parsed_vendor_url['path'] ) {
|
||||
$addon->vendor_url .= '/';
|
||||
}
|
||||
$separator = ( null == $parsed_vendor_url['query'] ) ? '?' : '&';
|
||||
$query = http_build_query(
|
||||
array(
|
||||
'utm_source' => 'extensionsscreen',
|
||||
'utm_medium' => 'product',
|
||||
'utm_campaign' => 'wcaddons',
|
||||
'utm_content' => 'devpartner',
|
||||
)
|
||||
);
|
||||
$addon->vendor_url .= $separator . $query;
|
||||
|
||||
printf(
|
||||
/* translators: %s vendor link */
|
||||
esc_html__( 'Developed by %s', 'woocommerce' ),
|
||||
sprintf(
|
||||
'<a class="product-vendor-link" href="%1$s" target="_blank">%2$s</a>',
|
||||
esc_url_raw( $addon->vendor_url ),
|
||||
wp_kses_post( $addon->vendor_name )
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<p><?php echo wp_kses_post( $addon->excerpt ); ?></p>
|
||||
</div>
|
||||
<div class="product-footer">
|
||||
<?php if ( '$0.00' === $addon->price ) : ?>
|
||||
<span class="price"><?php esc_html_e( 'Free', 'woocommerce' ); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="price"><?php echo wp_kses_post( $addon->price ); ?></span>
|
||||
<span class="price_suffix"><?php esc_html_e( 'per year', 'woocommerce' ); ?></span>
|
||||
<?php endif; ?>
|
||||
<div class="product-price-and-reviews-container">
|
||||
<div class="product-price-block">
|
||||
<?php if ( '$0.00' === $addon->price ) : ?>
|
||||
<span class="price"><?php esc_html_e( 'Free', 'woocommerce' ); ?></span>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
$price_suffix = __( 'per year', 'woocommerce' );
|
||||
if ( ! empty( $addon->price_suffix ) ) {
|
||||
$price_suffix = $addon->price_suffix;
|
||||
}
|
||||
?>
|
||||
<span class="price"><?php echo wp_kses_post( $addon->price ); ?></span>
|
||||
<span class="price-suffix"><?php echo esc_html( $price_suffix ); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ( ! empty( $addon->reviews_count ) && ! empty( $addon->rating ) ) : ?>
|
||||
<?php /* Show rating and the number of reviews */ ?>
|
||||
<div class="product-reviews-block">
|
||||
<?php for ( $index = 1; $index <= 5; ++$index ) : ?>
|
||||
<?php $rating_star_class = 'product-rating-star product-rating-star__' . WC_Admin_Addons::get_star_class( $addon->rating, $index ); ?>
|
||||
<div class="<?php echo esc_attr( $rating_star_class ); ?>"></div>
|
||||
<?php endfor; ?>
|
||||
<span class="product-reviews-count">(<?php echo wp_kses_post( $addon->reviews_count ); ?>)</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<a class="button" href="<?php echo esc_url( WC_Admin_Addons::add_in_app_purchase_url_params( $addon->link ) ); ?>">
|
||||
<?php esc_html_e( 'View details', 'woocommerce' ); ?>
|
||||
</a>
|
||||
|
@ -148,13 +200,16 @@ $current_section_name = __( 'Browse Categories', 'woocommerce' );
|
|||
<?php endif; ?>
|
||||
|
||||
<?php if ( 'Storefront' !== $theme['Name'] && '_featured' !== $current_section ) : ?>
|
||||
<?php
|
||||
$storefront_url = WC_Admin_Addons::add_in_app_purchase_url_params( 'https://woocommerce.com/storefront/?utm_source=extensionsscreen&utm_medium=product&utm_campaign=wcaddon' );
|
||||
?>
|
||||
<div class="storefront">
|
||||
<a href="<?php echo esc_url( 'https://woocommerce.com/storefront/' ); ?>" target="_blank"><img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/storefront.png" alt="<?php esc_attr_e( 'Storefront', 'woocommerce' ); ?>" /></a>
|
||||
<a href="<?php echo esc_url( $storefront_url ); ?>" target="_blank"><img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/storefront.png" alt="<?php esc_attr_e( 'Storefront', 'woocommerce' ); ?>" /></a>
|
||||
<h2><?php esc_html_e( 'Looking for a WooCommerce theme?', 'woocommerce' ); ?></h2>
|
||||
<p><?php echo wp_kses_post( __( 'We recommend Storefront, the <em>official</em> WooCommerce theme.', 'woocommerce' ) ); ?></p>
|
||||
<p><?php echo wp_kses_post( __( 'Storefront is an intuitive, flexible and <strong>free</strong> WordPress theme offering deep integration with WooCommerce and many of the most popular customer-facing extensions.', 'woocommerce' ) ); ?></p>
|
||||
<p>
|
||||
<a href="https://woocommerce.com/storefront/" target="_blank" class="button"><?php esc_html_e( 'Read all about it', 'woocommerce' ); ?></a>
|
||||
<a href="<?php echo esc_url( $storefront_url ); ?>" target="_blank" class="button"><?php esc_html_e( 'Read all about it', 'woocommerce' ); ?></a>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-theme&theme=storefront' ), 'install-theme_storefront' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Download & install', 'woocommerce' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -166,6 +166,9 @@ class WC_Tracker {
|
|||
// WooCommerce Admin info.
|
||||
$data['wc_admin_disabled'] = apply_filters( 'woocommerce_admin_disabled', false ) ? 'yes' : 'no';
|
||||
|
||||
// Mobile info.
|
||||
$data['wc_mobile_usage'] = self::get_woocommerce_mobile_usage();
|
||||
|
||||
return apply_filters( 'woocommerce_tracker_data', $data );
|
||||
}
|
||||
|
||||
|
@ -756,6 +759,15 @@ class WC_Tracker {
|
|||
'checkout_block_attributes' => $checkout_block_data['block_attributes'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about WooCommerce Mobile App usage
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_woocommerce_mobile_usage() {
|
||||
return get_option( 'woocommerce_mobile_app_usage' );
|
||||
}
|
||||
}
|
||||
|
||||
WC_Tracker::init();
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* REST API WC Telemetry controller
|
||||
*
|
||||
* Handles requests to the /wc-telemetry endpoint.
|
||||
*
|
||||
* @package WooCommerce\RestApi
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Telemetry controller class.
|
||||
*
|
||||
* @package WooCommerce\RestApi
|
||||
* @extends WC_REST_Controller
|
||||
*/
|
||||
class WC_REST_Telemetry_Controller extends WC_REST_Controller {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc-telemetry';
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rest_base = 'tracker';
|
||||
|
||||
/**
|
||||
* Register the route for /tracker
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'record_usage_data' ),
|
||||
'permission_callback' => array( $this, 'telemetry_permissions_check' ),
|
||||
'args' => $this->get_collection_params(),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a given request has permission to post telemetry data
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_Error|boolean
|
||||
*/
|
||||
public function telemetry_permissions_check( $request ) {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you post telemetry data.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record WCTracker Data
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
*/
|
||||
public function record_usage_data( $request ) {
|
||||
$new = $this->get_usage_data( $request );
|
||||
if ( ! $new || ! $new['platform'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = get_option( 'woocommerce_mobile_app_usage' );
|
||||
if ( ! $data ) {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$platform = $new['platform'];
|
||||
if ( ! $data[ $platform ] || version_compare( $new['version'], $data[ $platform ]['version'], '>=' ) ) {
|
||||
$data[ $platform ] = $new;
|
||||
}
|
||||
|
||||
update_option( 'woocommerce_mobile_app_usage', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get usage data from current request
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return Array
|
||||
*/
|
||||
public function get_usage_data( $request ) {
|
||||
$platform = strtolower( $request->get_param( 'platform' ) );
|
||||
switch ( $platform ) {
|
||||
case 'ios':
|
||||
case 'android':
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$version = $request->get_param( 'version' );
|
||||
if ( ! $version ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
'platform' => sanitize_text_field( $platform ),
|
||||
'version' => sanitize_text_field( $version ),
|
||||
'last_used' => gmdate( 'c' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any query params needed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_collection_params() {
|
||||
return array(
|
||||
'platform' => array(
|
||||
'description' => __( 'Platform to track.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
),
|
||||
'version' => array(
|
||||
'description' => __( 'Platform version to track.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -52,9 +52,10 @@ class Server {
|
|||
return apply_filters(
|
||||
'woocommerce_rest_api_get_rest_namespaces',
|
||||
array(
|
||||
'wc/v1' => $this->get_v1_controllers(),
|
||||
'wc/v2' => $this->get_v2_controllers(),
|
||||
'wc/v3' => $this->get_v3_controllers(),
|
||||
'wc/v1' => $this->get_v1_controllers(),
|
||||
'wc/v2' => $this->get_v2_controllers(),
|
||||
'wc/v3' => $this->get_v3_controllers(),
|
||||
'wc-telemetry' => $this->get_telemetry_controllers(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -179,6 +180,17 @@ class Server {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of controllers in the telemetry namespace.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_telemetry_controllers() {
|
||||
return array(
|
||||
'tracker' => 'WC_REST_Telemetry_Controller',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path to the package.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { HTTPClientFactory, Coupon } = require( '@woocommerce/api' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const config = require( 'config' );
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
/**
|
||||
* Create the default coupon and tests interactions with it via the API.
|
||||
*/
|
||||
const runTelemetryAPITest = () => {
|
||||
describe( 'REST API > Telemetry', () => {
|
||||
let client;
|
||||
|
||||
beforeAll(async () => {
|
||||
const admin = config.get( 'users.admin' );
|
||||
const url = config.get( 'url' );
|
||||
|
||||
client = HTTPClientFactory.build( url )
|
||||
.withBasicAuth( admin.username, admin.password )
|
||||
.withIndexPermalinks()
|
||||
.create();
|
||||
} );
|
||||
|
||||
it.each([
|
||||
null,
|
||||
{},
|
||||
{ platform: 'ios' },
|
||||
{ version: '1.1' },
|
||||
])( 'errors for invalid request body - %p', async data => {
|
||||
const response = await client
|
||||
.post( `/wc-telemetry/tracker`, data )
|
||||
.catch( err => {
|
||||
expect( err.statusCode ).toBe( 400 );
|
||||
} );
|
||||
|
||||
expect( response ).toBeUndefined();
|
||||
} );
|
||||
|
||||
it( 'returns 200 with correct fields', async () => {
|
||||
const response = await client
|
||||
.post( `/wc-telemetry/tracker`, {
|
||||
platform: 'ios',
|
||||
version: '1.0',
|
||||
})
|
||||
|
||||
expect( response.statusCode ).toBe( 200 );
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
module.exports = runTelemetryAPITest;
|
|
@ -53,6 +53,7 @@ const runCouponApiTest = require( './api/coupon.test' );
|
|||
const runGroupedProductAPITest = require( './api/grouped-product.test' );
|
||||
const runVariableProductAPITest = require( './api/variable-product.test' );
|
||||
const runOrderApiTest = require( './api/order.test' );
|
||||
const runTelemetryAPITest = require( './api/telemetry.test' );
|
||||
|
||||
const runSetupOnboardingTests = () => {
|
||||
runActivationTest();
|
||||
|
@ -108,6 +109,7 @@ const runApiTests = () => {
|
|||
runVariableProductAPITest();
|
||||
runCouponApiTest();
|
||||
runOrderApiTest();
|
||||
runTelemetryAPITest();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -160,4 +162,5 @@ module.exports = {
|
|||
runMyAccountCreateAccountTest,
|
||||
runOrderEmailReceivingTest,
|
||||
runInitiateWccomConnectionTest,
|
||||
runTelemetryAPITest,
|
||||
};
|
||||
|
|
|
@ -8,4 +8,4 @@ WORDPRESS_DEBUG=1
|
|||
|
||||
# WordPress CLI environment
|
||||
WORDPRESS_HOST=wordpress-www:80
|
||||
WORDPRESS_TITLE=WooCommerce Core E2E Test Suite
|
||||
WORDPRESS_TITLE="WooCommerce Core E2E Test Suite"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Added
|
||||
|
||||
- Added quotes around `WORDPRESS_TITLE` value in .env file to address issue with docker compose 2 "key cannot contain a space" error.
|
||||
- Added `LATEST_WP_VERSION_MINUS` that allows setting a number to subtract from the current WordPress version for the WordPress Docker image.
|
||||
|
||||
# 0.2.3
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runTelemetryAPITest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runTelemetryAPITest();
|
Loading…
Reference in New Issue