Merge branch 'trunk' into fix/remove-smoke-test-label

This commit is contained in:
jamelreid 2022-01-03 18:08:08 -05:00
commit 5c8bbea589
17 changed files with 276 additions and 80 deletions

View File

@ -1,5 +1,9 @@
# Unreleased
## Added
- Added low stock threshold field for products
# 0.2.0
## Added

View File

@ -34,7 +34,7 @@ abstract class AbstractProductInventory extends Model {
*
* @type {StockStatus}
*/
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
/**
* The status of backordering for a product.
@ -56,6 +56,13 @@ abstract class AbstractProductInventory extends Model {
* @type {boolean}
*/
public readonly isOnBackorder: boolean = false;
/**
* Indicates the threshold for when the low stock notification will be sent to the merchant.
*
* @type {number}
*/
public readonly lowStockThreshold: number = -1;
}
export interface IProductInventory extends AbstractProductInventory {}

View File

@ -53,7 +53,7 @@ export type ProductGroupedUpdateParams = 'groupedProducts';
* Properties related to tracking inventory.
*/
export type ProductInventoryUpdateParams = 'backorderStatus' | 'canBackorder' | 'trackInventory'
| 'onePerOrder' | 'remainingStock';
| 'onePerOrder' | 'remainingStock' | 'lowStockThreshold';
/**
* Properties related to sales tax.

View File

@ -130,10 +130,11 @@ export class SimpleProduct extends AbstractProduct implements
public readonly onePerOrder: boolean = false;
public readonly trackInventory: boolean = false;
public readonly remainingStock: number = -1;
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/price.ts

View File

@ -115,10 +115,11 @@ export class VariableProduct extends AbstractProduct implements
public readonly onePerOrder: boolean = false;
public readonly trackInventory: boolean = false;
public readonly remainingStock: number = -1;
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/sales-tax.ts

View File

@ -118,6 +118,7 @@ export class ProductVariation extends AbstractProductData implements
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/price.ts

View File

@ -345,6 +345,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] {
onePerOrder: PropertyType.Boolean,
stockStatus: PropertyType.String,
backOrderStatus: PropertyType.String,
lowStockThreshold: PropertyType.Integer,
},
),
new KeyChangeTransformation< IProductInventory >(
@ -356,6 +357,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] {
backorderStatus: 'backorders',
canBackorder: 'backorders_allowed',
isOnBackorder: 'backordered',
lowStockThreshold: 'low_stock_amount',
},
),
];

View File

@ -9,7 +9,7 @@ export const MENUS = [
[
[
'Home',
'#toplevel_page_woocommerce > ul > li:nth-child(2) > a',
'',
'Home',
],
[

View File

@ -28,13 +28,17 @@ const runPageLoadTest = () => {
await Promise.all( [
page.click( menuElement ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
merchant.dismissOnboardingWizard(),
merchant.collapseAdminMenu( false ),
] );
// Click sub-menu item and wait for the page to finish loading
await Promise.all( [
page.click( subMenuElement ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
] );
if ( subMenuElement.length ) {
await Promise.all([
page.click( subMenuElement ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
] );
}
await expect( page ).toMatchElement( 'h1', {
text: subMenuText,

View File

@ -4,6 +4,7 @@
- Added `post-results-to-github-pr.js` to post smoke test results to a GitHub PR.
- Added jest flags to generate a json test report
- Added more entries to `default.json`
## Added

View File

@ -2,75 +2,207 @@
"url": "http://localhost:8084/",
"appName": "woocommerce_e2e",
"users": {
"admin": {
"username": "admin",
"password": "password"
},
"customer": {
"username": "customer",
"password": "password"
}
"admin": {
"username": "admin",
"password": "password"
},
"customer": {
"username": "customer",
"password": "password"
}
},
"products": {
"simple": {
"name": "Simple product"
},
"variable": {
"name": "Variable Product with Three Variations"
}
"simple": {
"name": "Simple product"
},
"variable": {
"name": "Variable Product with Three Attributes",
"defaultAttributes": [
{
"id": 0,
"name": "Size",
"option": "Medium"
},
{
"id": 0,
"name": "Colour",
"option": "Blue"
}
],
"attributes": [
{
"id": 0,
"name": "Colour",
"isVisibleOnProductPage": true,
"isForVariations": true,
"options": [
"Red",
"Green",
"Blue"
],
"sortOrder": 0
},
{
"id": 0,
"name": "Size",
"isVisibleOnProductPage": true,
"isForVariations": true,
"options": [
"Small",
"Medium",
"Large"
],
"sortOrder": 0
},
{
"id": 0,
"name": "Logo",
"isVisibleOnProductPage": true,
"isForVariations": true,
"options": [
"Woo",
"WordPress"
],
"sortOrder": 0
}
]
},
"variations": [
{
"regularPrice": "19.99",
"attributes": [
{
"name": "Size",
"option": "Large"
},
{
"name": "Colour",
"option": "Red"
}
]
},
{
"regularPrice": "18.99",
"attributes": [
{
"name": "Size",
"option": "Medium"
},
{
"name": "Colour",
"option": "Green"
}
]
},
{
"regularPrice": "17.99",
"attributes": [
{
"name": "Size",
"option": "Small"
},
{
"name": "Colour",
"option": "Blue"
}
]
}
],
"grouped": {
"name": "Grouped Product with Three Children",
"groupedProducts": [
{
"name": "Base Unit",
"regularPrice": "29.99"
},
{
"name": "Add-on A",
"regularPrice": "11.95"
},
{
"name": "Add-on B",
"regularPrice": "18.97"
}
]
},
"external": {
"name": "External product",
"regularPrice": "24.99",
"buttonText": "Buy now",
"externalUrl": "https://wordpress.org/plugins/woocommerce"
}
},
"coupons": {
"percentage": {
"code": "20percent",
"discountType": "percent",
"amount": "20.00"
}
},
"addresses": {
"admin": {
"store": {
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"countryandstate": "United States (US) — California",
"city": "San Francisco",
"state": "CA",
"postcode": "94107"
}
},
"customer": {
"billing": {
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"city": "San Francisco",
"state": "CA",
"postcode": "94107",
"phone": "123456789",
"email": "john.doe@example.com"
},
"shipping": {
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"city": "San Francisco",
"state": "CA",
"postcode": "94107"
}
}
"admin": {
"store": {
"email": "admin@woocommercecoree2etestsuite.com",
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"countryandstate": "United States (US) — California",
"city": "San Francisco",
"state": "CA",
"postcode": "94107"
}
},
"customer": {
"billing": {
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"city": "San Francisco",
"state": "CA",
"postcode": "94107",
"phone": "123456789",
"email": "john.doe@example.com"
},
"shipping": {
"firstname": "John",
"lastname": "Doe",
"company": "Automattic",
"country": "United States (US)",
"addressfirstline": "addr 1",
"addresssecondline": "addr 2",
"city": "San Francisco",
"state": "CA",
"postcode": "94107"
}
}
},
"orders": {
"basicPaidOrder": {
"paymentMethod": "cod",
"status": "processing",
"billing": {
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com"
}
}
},
"onboardingwizard": {
"industry": "Test industry",
"numberofproducts": "1 - 10",
"sellingelsewhere": "No"
"industry": "Test industry",
"numberofproducts": "1 - 10",
"sellingelsewhere": "No"
},
"settings": {
"shipping": {
"zonename": "United States",
"zoneregions": "United States (US)",
"shippingmethod": "Free shipping"
}
"shipping": {
"zonename": "United States",
"zoneregions": "United States (US)",
"shippingmethod": "Free shipping"
}
}
}

View File

@ -23,6 +23,8 @@
- `clickAndWaitForSelector( buttonSelector, resultSelector, timeout )` to click a button and wait for response
- Optional parameter `testResponse` to `withRestApi` functions that contain an `expect()`
- `shopper.logout()` to log out the shopper account
- `merchant.dismissOnboardingWizard()` to dismiss the onboarding wizard
- `merchant.collapseAdminMenu()` to expand or collapse the WP admin menu
# 0.1.6

View File

@ -84,6 +84,8 @@ This package provides support for enabling retries in tests:
| Function | Parameters | Description |
|----------|-------------|------------|
| `collapseAdminMenu` | `collapse` | Collapse or expand the WP admin menu |
| `dismissOnboardingWizard` | | Dismiss the onboarding wizard if present |
| `goToOrder` | `orderId` | Go to view a single order |
| `goToProduct` | `productId` | Go to view a single product |
| `login` | | Log in as merchant |

View File

@ -52,6 +52,7 @@ const merchant = {
await Promise.all( [
page.click( 'input[type=submit]' ),
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
merchant.dismissOnboardingWizard(),
] );
},
@ -409,6 +410,41 @@ const merchant = {
await merchant.checkDatabaseUpdateComplete();
}
},
/**
* Dismiss the onboarding wizard if it is open.
*/
dismissOnboardingWizard: async () => {
let waitForNav = false;
const skipButton = await page.$( '.woocommerce-profile-wizard__footer-link' );
if ( skipButton ) {
await skipButton.click();
waitForNav = true;
}
// Dismiss usage tracking pop-up window if it appears on a new site
const usageTrackingHeader = await page.$( '.woocommerce-usage-modal button.is-secondary' );
if ( usageTrackingHeader ) {
await usageTrackingHeader.click();
waitForNav = true;
}
if ( waitForNav ) {
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
}
},
/**
* Expand or collapse the WP admin menu.
* @param {boolean} collapse Flag to collapse or expand the menu. Default collapse.
*/
collapseAdminMenu: async ( collapse = true ) => {
const collapseButton = await page.$( '.folded #collapse-button' );
if ( ( ! collapseButton ) == collapse ) {
await collapseButton.click();
}
},
};
module.exports = merchant;

View File

@ -21,7 +21,7 @@
"pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.4.0",
"woocommerce/woocommerce-admin": "3.0.0-rc.1",
"woocommerce/woocommerce-admin": "3.0.1",
"woocommerce/woocommerce-blocks": "6.5.1"
},
"require-dev": {

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ecce1670d22ae2df07e552adce1cfc29",
"content-hash": "ebdb5708b79cdb94e4b2ff5fbed40d89",
"packages": [
{
"name": "automattic/jetpack-autoloader",
@ -543,16 +543,16 @@
},
{
"name": "woocommerce/woocommerce-admin",
"version": "3.0.0-rc.1",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "7c0cdd01ae98be058d684dd19023b0f40094cb63"
"reference": "5542e80021a43d24ab9b1d2d67083b608899835d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/7c0cdd01ae98be058d684dd19023b0f40094cb63",
"reference": "7c0cdd01ae98be058d684dd19023b0f40094cb63",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/5542e80021a43d24ab9b1d2d67083b608899835d",
"reference": "5542e80021a43d24ab9b1d2d67083b608899835d",
"shasum": ""
},
"require": {
@ -608,9 +608,9 @@
"homepage": "https://github.com/woocommerce/woocommerce-admin",
"support": {
"issues": "https://github.com/woocommerce/woocommerce-admin/issues",
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v3.0.0-rc.1"
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v3.0.1"
},
"time": "2021-12-14T23:55:42+00:00"
"time": "2021-12-30T18:38:11+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",

View File

@ -484,12 +484,15 @@ function wc_is_file_valid_csv( $file, $check_path = true ) {
}
/**
* Check if the current theme is an FSE theme.
* Check if the current theme is a block theme.
*
* @since x.x.x
* @return bool
*/
function wc_current_theme_is_fse_theme() {
if ( function_exists( 'wp_is_block_theme' ) ) {
return (bool) wp_is_block_theme();
}
if ( function_exists( 'gutenberg_is_fse_theme' ) ) {
return (bool) gutenberg_is_fse_theme();
}