Merge branch 'trunk' into issue/31562-filter-coupons-by-status

# Conflicts:
#	plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php
#	plugins/woocommerce/tests/legacy/unit-tests/coupon/data.php
This commit is contained in:
anitaamurthy 2022-01-11 11:36:16 +05:30
commit 9a34ccc7ba
81 changed files with 354 additions and 165 deletions

View File

@ -96,7 +96,7 @@ jobs:
await script({github, context})
- name: Remove label from pull request.
if: always() && ${{ contains(github.event.label.name, format( 'run{0} smoke tests', ':') ) }}
if: always() && ${{ contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) }}
uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,14 +1,11 @@
# Unreleased
## Changes
- Removed the node-config dependency
## Fixed
- Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs.
## Added
- This package is now transpiled with Babel, which allows the usage of modern, yet compatible JS code.
- A `specs/data` folder to store page element data.
- Tests to verify that different top-level menu and their associated sub-menus load successfully.
- Test scaffolding via `npx wc-e2e install @woocommerce/e2e-core-tests`

View File

@ -21,6 +21,7 @@ const getCoreTestsRoot = () => {
return {
appRoot: coreTestsPath,
packageRoot: moduleDir,
coreTestsRoot: __dirname
};
};

View File

@ -8,23 +8,47 @@
"url": "https://github.com/woocommerce/woocommerce.git"
},
"license": "GPL-3.0+",
"main": "index.js",
"main": "build/index.js",
"module": "build-module/index.js",
"files": [
"build",
"build-module",
"test-data",
"core-tests-root.js",
"installFiles",
"CHANGELOG.md"
],
"dependencies": {
"@jest/globals": "^26.4.2",
"@wordpress/deprecated": "^3.2.3",
"config": "3.3.3",
"faker": "^5.1.0"
},
"devDependencies": {
"@babel/cli": "7.12.8",
"@babel/core": "7.12.9",
"@babel/plugin-proposal-async-generator-functions": "^7.16.4",
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/plugin-transform-react-jsx": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.12.7",
"@wordpress/babel-plugin-import-jsx-pragma": "1.1.3",
"@wordpress/babel-preset-default": "3.0.2",
"@wordpress/browserslist-config": "^4.1.0"
},
"peerDependencies": {
"@woocommerce/api": "^0.2.0",
"@woocommerce/e2e-utils": "^0.1.6",
"@woocommerce/e2e-environment": "^0.2.3"
"@woocommerce/e2e-utils": "^0.1.6"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "./bin/build.sh",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"clean": "rm -rf ./build ./build-module",
"compile": "node ./../bin/build.js",
"build": "./bin/build.sh && pnpm run clean && pnpm run compile"
}
}

View File

@ -12,7 +12,7 @@ const {
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
import deprecated from '@wordpress/deprecated';
const {
it,

View File

@ -6,7 +6,7 @@ const { HTTPClientFactory, Coupon } = require( '@woocommerce/api' );
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const { it, describe, beforeAll } = require( '@jest/globals' );
/**

View File

@ -6,7 +6,7 @@ const { HTTPClientFactory, ExternalProduct } = require( '@woocommerce/api' );
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const { it, describe, beforeAll } = require( '@jest/globals' );
/**

View File

@ -10,7 +10,7 @@ const {
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const { it, describe, beforeAll } = require( '@jest/globals' );
/**

View File

@ -6,7 +6,7 @@ const { HTTPClientFactory, Order } = require( '@woocommerce/api' );
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const { it, describe, beforeAll } = require( '@jest/globals' );
/**

View File

@ -6,7 +6,7 @@ const { HTTPClientFactory } = require( '@woocommerce/api' );
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const { it, describe, beforeAll } = require( '@jest/globals' );
/**

View File

@ -7,7 +7,7 @@ const { HTTPClientFactory, VariableProduct, ProductVariation } = require( '@wooc
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const {
it,
describe,

View File

@ -11,8 +11,8 @@ const {
utils,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const config = require( 'config' );
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const discountedPrice = simpleProductPrice - 5.00;
const couponDialogMessage = 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.';

View File

@ -9,9 +9,9 @@ const {
} = require( '@woocommerce/e2e-utils' );
// TODO create a function for the logic below getConfigSimpleProduct(), see: https://github.com/woocommerce/woocommerce/issues/29072
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
const runMerchantOrdersCustomerPaymentPage = () => {
let orderId;

View File

@ -9,10 +9,10 @@ const {
deleteAllEmailLogs,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const customerEmail = config.get( 'addresses.customer.billing.email' );
const adminEmail = config.get( 'users.admin.email', 'admin@woocommercecoree2etestsuite.com' );
const storeName = config.get( 'storeName', 'WooCommerce Core E2E Test Suite' );
const adminEmail = config.has( 'users.admin.email' ) ? config.get( 'users.admin.email' ) : 'admin@woocommercecoree2etestsuite.com';
const storeName = 'WooCommerce Core E2E Test Suite';
let orderId;

View File

@ -7,7 +7,7 @@ const {
withRestApi,
AdminEdit,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const {
HTTPClientFactory,
VariableProduct,

View File

@ -12,8 +12,8 @@ const {
clickAndWaitForSelector,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const config = require( 'config' );
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const runRefundOrderTest = () => {
describe('WooCommerce Orders > Refund an order', () => {

View File

@ -1,6 +1,8 @@
/**
* Internal dependencies
*/
const config = require( 'config' );
const {
merchant,
withRestApi,

View File

@ -7,7 +7,7 @@ const {
setCheckbox,
withRestApi,
} = require( '@woocommerce/e2e-utils' );
const getCoreTestsRoot = require( '../../core-tests-root' );
const getCoreTestsRoot = require( '../../../core-tests-root' );
/**
* External dependencies
@ -17,11 +17,11 @@ const { it, describe, beforeAll, afterAll } = require( '@jest/globals' );
const path = require( 'path' );
const coreTestsPath = getCoreTestsRoot();
const filePath = path.resolve(
coreTestsPath.packageRoot,
coreTestsPath.coreTestsRoot,
'test-data/sample_products.csv'
);
const filePathOverride = path.resolve(
coreTestsPath.packageRoot,
coreTestsPath.coreTestsRoot,
'test-data/sample_products_override.csv'
);
const productNames = [

View File

@ -24,11 +24,12 @@ const {
it,
describe,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const VirtualProductName = 'Virtual Product Name';
const NonVirtualProductName = 'Non-Virtual Product Name';
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const defaultAttributes = [ 'val2', 'val1', 'val2' ];
const openNewProductAndVerify = async () => {
// Go to "add product" page
@ -38,6 +39,33 @@ const openNewProductAndVerify = async () => {
await expect(page.title()).resolves.toMatch('Add new product');
}
/**
* Select a variation action from the actions menu.
*
* @param action item you selected from the variation actions menu
*/
const selectVariationAction = async ( action ) => {
await waitForSelector( page, 'select.variation_actions:not(:disabled)' );
await page.focus( 'select.variation_actions' );
await expect( page ).toSelect( 'select.variation_actions', action );
};
const clickGoButton = async () => {
await evalAndClick( 'a.do_variation_action' );
};
const saveChanges = async () => {
await page.focus( 'button.save-variation-changes' );
await expect( page ).toClick( 'button.save-variation-changes', {
text: 'Save changes',
} );
await uiUnblocked();
};
const expandVariations = async () => {
await waitAndClick( page, '.variations-pagenav .expand_all' );
};
const runAddSimpleProductTest = () => {
describe('Add New Simple Product Page', () => {
it('can create simple virtual product and add it to the cart', async () => {
@ -149,18 +177,18 @@ const runAddVariableProductTest = () => {
await uiUnblocked();
});
it('can create variable product variations', async () => {
it('can create variations from all attributes', async () => {
// Create variations from attributes
await waitForSelector( page, '.variations_tab' );
await waitAndClick( page, '.variations_tab a' );
await waitForSelector( page, 'select.variation_actions:not(:disabled)');
await page.focus('select.variation_actions');
await expect(page).toSelect('select.variation_actions', 'Create variations from all attributes');
await selectVariationAction('Create variations from all attributes');
// headless: false doesn't require this
const firstDialog = await expect(page).toDisplayDialog(async () => {
await evalAndClick( 'a.do_variation_action' );
});
const firstDialog = await expect( page ).toDisplayDialog(
async () => {
await clickGoButton();
}
);
await expect(firstDialog.message()).toMatch('Are you sure you want to link all variations?');
@ -198,7 +226,7 @@ const runAddVariableProductTest = () => {
await expect( page ).toMatchElement( `select[name="attribute_attr-3[${index}]"]`, attr3 ? val2 : val1 );
}
await waitAndClick( page, '.variations-pagenav .expand_all');
await expandVariations();
await waitForSelectorWithoutThrow( 'input[name="variable_is_virtual[0]"]', 5 );
await setCheckbox('input[name="variable_is_virtual[0]"]');
await expect(page).toFill('input[name="variable_regular_price[0]"]', '9.99');
@ -213,10 +241,172 @@ const runAddVariableProductTest = () => {
await expect(page).toFill('input[name="variable_width[2]"]', '20');
await expect(page).toFill('input[name="variable_height[2]"]', '15');
await page.focus('button.save-variation-changes');
await expect(page).toClick('button.save-variation-changes', {text: 'Save changes'});
// @todo: https://github.com/woocommerce/woocommerce/issues/30580
await saveChanges();
});
it( 'can bulk-edit variations', async () => {
// Verify that all 'Downloadable' checkboxes are UNCHECKED.
await expandVariations();
for ( let i = 0; i < 8; i++ ) {
const chkbox = await page.$(
`input[name="variable_is_downloadable[${ i }]"]`
);
const isChecked = await (
await chkbox.getProperty( 'checked' )
).jsonValue();
expect( isChecked ).toEqual( false );
}
// Perform the 'Toggle "Downloadable"' bulk action
await selectVariationAction('Toggle "Downloadable"');
await clickGoButton();
await uiUnblocked();
await uiUnblocked();
// Verify that all 'Downloadable' checkboxes are now CHECKED.
await expandVariations();
for ( let i = 0; i < 8; i++ ) {
const chkbox = await page.$(
`input[name="variable_is_downloadable[${ i }]"]`
);
const isChecked = await (
await chkbox.getProperty( 'checked' )
).jsonValue();
expect( isChecked ).toEqual( true );
}
} );
it( 'can delete all variations', async () => {
// Select "Delete all variations" from the actions menu.
await selectVariationAction( 'Delete all variations' );
const firstDialog = await expect( page ).toDisplayDialog(
async () => {
await clickGoButton();
}
);
// Verify that confirmation dialog shows the correct message.
await expect( firstDialog.message() ).toMatch(
'Are you sure you want to delete all variations? This cannot be undone.'
);
await uiUnblocked();
// Verify that no variations were displayed.
const variationsCount = await page.$$( '.woocommerce_variation' );
expect( variationsCount ).toHaveLength( 0 );
} );
it( 'can manually add a variation', async () => {
// Select "Add variation" from the actions menu.
await selectVariationAction( 'Add variation' );
await expect( page ).toClick( 'a.do_variation_action' );
await uiUnblocked();
// Set attribute values.
for ( let i = 0; i < defaultAttributes.length; i++ ) {
await expect( page ).toSelect(
`select[name="attribute_attr-${ i + 1 }[0]"]`,
defaultAttributes[ i ]
);
}
await saveChanges();
// Verify that attribute values were saved.
for ( let i = 0; i < defaultAttributes.length; i++ ) {
await expect( page ).toMatchElement(
`select[name="attribute_attr-${
i + 1
}[0]"] option[selected]`,
{
text: defaultAttributes[ i ],
}
);
}
} );
it( 'can manage stock at variation level', async () => {
await expandVariations();
// Enable "Manage stock?" option.
await setCheckbox( 'input.checkbox.variable_manage_stock' );
// Input a regular price
await expect( page ).toFill(
'input#variable_regular_price_0',
simpleProductPrice
);
// Verify that the "Stock status" dropdown menu disappears.
await expect( page ).toMatchElement( 'p.variable_stock_status', {
visible: false,
} );
// Fill out the "Stock quantity", "Allow backorders?", and "Low stock threshold" fields.
await expect( page ).toFill( 'input#variable_stock0', '100' );
await expect( page ).toSelect(
'select#variable_backorders0',
'Allow, but notify customer'
);
await expect( page ).toFill(
'input#variable_low_stock_amount0',
'10'
);
await saveChanges();
// Verify that field values specific to stock management were saved.
await expandVariations();
// Stock quantity
const actualStockQty = await page.$eval(
'input#variable_stock0',
( stockQtyInput ) => stockQtyInput.value
);
expect( actualStockQty ).toEqual( '100' );
// Allow backorders?
await expect( page ).toMatchElement(
'select#variable_backorders0 option[selected]',
'Allow, but notify customer'
);
// Low stock threshold
const actualLowStockThresh = await page.$eval(
'input#variable_low_stock_amount0',
( lowStockThreshInput ) => lowStockThreshInput.value
);
expect( actualLowStockThresh ).toEqual( '10' );
} );
it( 'can set variation defaults', async () => {
// Set default attribute values
for ( let i = 0; i < defaultAttributes.length; i++ ) {
await expect( page ).toSelect(
`select[name="default_attribute_attr-${ i + 1 }"]`,
defaultAttributes[ i ]
);
}
await saveChanges();
} );
it( 'can remove a variation', async () => {
// Click 'Remove' and confirm
const confirmDialog = await expect( page ).toDisplayDialog(
async () => {
await expect( page ).toClick( '.remove_variation.delete' );
}
);
expect( confirmDialog.message() ).toMatch(
'Are you sure you want to remove this variation?'
);
await uiUnblocked();
// Verify that no variations were displayed.
const variationsCount = await page.$$( '.woocommerce_variation' );
expect( variationsCount ).toHaveLength( 0 );
} );
});
};

View File

@ -8,9 +8,9 @@ const {
createSimpleProduct
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const runProductSearchTest = () => {
describe('Products > Search and View a product', () => {

View File

@ -21,8 +21,8 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const config = require( 'config' );
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
const california = 'state:US:CA';
const sanFranciscoZIP = '94107';
const shippingZoneNameUS = 'US with Flat rate';

View File

@ -18,8 +18,8 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const firstProductPrice = config.get( 'products.simple.price', '9.99' );
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);

View File

@ -21,7 +21,7 @@
afterAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const runCartRedirectionTest = () => {

View File

@ -17,9 +17,9 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const twoProductPrice = singleProductPrice * 2;
const runCartPageTest = () => {

View File

@ -21,7 +21,7 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const customerBilling = config.get( 'addresses.customer.billing' );
const runCheckoutCreateAccountTest = () => {

View File

@ -19,7 +19,7 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require('config');
const runCheckoutLoginAccountTest = () => {
describe('Shopper Checkout Login Account', () => {

View File

@ -9,9 +9,9 @@ const {
uiUnblocked,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const twoProductPrice = singleProductPrice * 2;
const threeProductPrice = singleProductPrice * 3;
const fourProductPrice = singleProductPrice * 4;

View File

@ -11,7 +11,7 @@ const {
let simplePostIdValue;
let orderNum;
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const runMyAccountPayOrderTest = () => {

View File

@ -12,7 +12,7 @@
let simplePostIdValue;
let orderId;
const { config } = require( '@woocommerce/e2e-environment' );
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';

View File

@ -17,11 +17,11 @@ const {
beforeAll,
} = require( '@jest/globals' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
const singleProductPrice2 = '1' + singleProductPrice;
const singleProductPrice3 = '2' + singleProductPrice;
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const singleProductPrice2 = config.has('products.simple.price') ? '1' + singleProductPrice : '19.99';
const singleProductPrice3 = config.has('products.simple.price') ? '2' + singleProductPrice : '29.99';
const clothing = 'Clothing';
const audio = 'Audio';
const hardware = 'Hardware';

View File

@ -9,7 +9,7 @@ const {
uiUnblocked
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
// Variables for simple product
const simpleProductName = config.get( 'products.simple.name' );
@ -20,7 +20,7 @@ const defaultVariableProduct = config.get( 'products.variable' );
let variableProductId;
// Variables for grouped product
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
const simple1 = {
name: simpleProductName + ' 1',
regularPrice: simpleProductPrice

View File

@ -6,7 +6,7 @@ const {
shopper,
createVariableProduct,
} = require( '@woocommerce/e2e-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require('config');
let variablePostIdValue;
@ -100,7 +100,7 @@ const runVariableProductUpdateTest = () => {
});
});
};
module.exports = runVariableProductUpdateTest;

View File

@ -1,17 +1,15 @@
# Unreleased
## Fixed
## Added
- Added the ability to take screenshots from multiple test failures (when retried) in `utils/take-screenshot.js`.
- Added a `config` export to the `@woocommerce/e2e-environment` package that has all data and methods of the [config](https://github.com/lorenwest/node-config) package
- it provides its own `get()` method that accepts an optional default parameter to be used if the property is not found in the config file.
## Added
- 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
- Added `await` for every call to `shopper.logout`

View File

@ -98,22 +98,6 @@ The E2E environment has the following methods to let us control Jest's overall b
E2E_RETRY_TIMES=2 pnpx wc-e2e test:e2e
```
### Default Environment Configurations
The E2E environment exports a config object which provides all the functionality of the [config](https://www.npmjs.com/package/config) package along with extending the `get` method to accept an optional second argument that will be used if the property is not found in the config file.
```js
const { config } = require( '@woocommerce/e2e-environment' );
// 'users.admin.email' doesn't exist
const adminEmail = config.get( 'users.admin.email', 'admin@woocommercecoree2etestsuite.com' );
console.log( adminEmail );
// admin@woocommercecoree2etestsuite.com
```
**Note**: If the default parameter is not found and no optional parameter is provided, an error will be thrown.
#### Test Screenshots
The test sequencer provides a screenshot function for test failures. To enable screenshots on test failure use

View File

@ -20,7 +20,7 @@ const {
confirmLocalCopy,
confirmLocalDelete,
getPackageData,
installDefaults
installDefaults,
} = require( '../utils/scaffold' );
const args = process.argv.slice( 2 );

View File

@ -34,7 +34,7 @@ REALPATH=$(readlink "$0")
cd "$SCRIPTPATH/$(dirname "$REALPATH")/.."
# Set a flag to distinguish between the development repo and npm package
DEV_PATH=$(echo $0 | rev | cut -f4 -d/ | rev)
DEV_PATH=$(pwd | rev | cut -f3 -d/ | rev)
if [ "$DEV_PATH" != "node_modules" ]; then
export WC_E2E_WOOCOMMERCE_DEV='true'
export WC_E2E_FOLDER='plugins/woocommerce'

View File

@ -1,32 +0,0 @@
/**
* External Dependencies
*/
const config = require( 'config' );
/**
* Since the 'config' object is not extensible, we create an empty 'e2eConfig' object and map
* its prototype to the 'config' object. This allows us to extend the new 'e2eConfig' object
* while still having access to all the data and methods of 'config'
*/
const e2eConfig = Object.create( config );
/**
*
* @param property { string } - the property to be fetched from the config file
* @param defaultValue { string | number | boolean | null } - default value if 'property' is not found
* @returns { string | number | boolean }
* @throws Error
*/
e2eConfig.get = ( property, defaultValue = null ) => {
if ( config.has( property ) ) {
return config.get( property );
} else if ( defaultValue ) {
return defaultValue;
}
throw new Error(
`Configuration property "${ property }" is not defined and no defaultValue has been provided`
);
};
module.exports = e2eConfig;

View File

@ -1,7 +1,6 @@
/**
* Internal dependencies
*/
const config = require('./config');
const jestConfig = require( './jest.config' );
const jestPuppeteerConfig = require( './jest-puppeteer.config' );
const jestobjectConfig = require('./jest-object.config');
@ -13,7 +12,6 @@ const {
} = require( './use-config' );
module.exports = {
config,
jestConfig,
...jestobjectConfig,
jestPuppeteerConfig,

View File

@ -30,6 +30,7 @@
"app-root-path": "^3.0.0",
"commander": "4.1.1",
"jest": "^25.1.0",
"jest-circus": "25.1.0",
"jest-each": "25.5.0",
"jest-puppeteer": "^4.4.0",
"node-stream-zip": "^1.13.6",
@ -51,7 +52,6 @@
"@wordpress/browserslist-config": "^4.1.0",
"@wordpress/eslint-plugin": "7.3.0",
"eslint": "^8.1.0",
"jest-circus": "25.1.0",
"ndb": "^1.1.5",
"semver": "^7.3.2"
},
@ -59,7 +59,6 @@
"access": "public"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"clean": "rm -rf ./build ./build-module",
"compile": "node ./../bin/build.js",
"build": "pnpm run clean && pnpm run compile",

View File

@ -109,9 +109,9 @@ const installDefaults = () => {
createLocalE2ePath( 'config' );
console.log( 'Writing tests/e2e/config/jest.config.js' );
confirmLocalCopy( `config${path.sep}jest.config.js`, `installFiles${path.sep}jest.config.js` );
confirmLocalCopy( `config${path.sep}jest.config.js`, `installFiles${path.sep}jest.config.js.default` );
console.log( 'Writing tests/e2e/config/jest.setup.js' );
confirmLocalCopy( `config${path.sep}jest.setup.js`, `installFiles${path.sep}jest.setup.js` );
confirmLocalCopy( `config${path.sep}jest.setup.js`, `installFiles${path.sep}jest.setup.js.default` );
};
module.exports = {

View File

@ -8,8 +8,9 @@ const { resolveLocalE2ePath } = require( './test-config' );
* @param message
* @return {Promise<{filePath: string, title: string}|{filePath: *, title: *}>}
*/
const takeScreenshotFor = async ( message ) => {
const title = message.replace( /\.$/, '' );
const takeScreenshotFor = async (message) => {
let now = new Date();
const title = `${message.replace( /\.$/, '' )}-${now.getDate()}${now.getHours()}${now.getMinutes()}${now.getSeconds()}`;
const savePath = resolveLocalE2ePath( 'screenshots' );
const filePath = path.join(
savePath,

View File

@ -1,9 +1,4 @@
# Unreleased
## Changes
- Removed node-config dependency
- Added @woocommerce/e2e-environment peerDependency
- Updated the package to use the custom node-config object from @woocommerce/e2e-environment
## Fixed

View File

@ -14,6 +14,7 @@
"@automattic/puppeteer-utils": "github:Automattic/puppeteer-utils#0f3ec50",
"@wordpress/deprecated": "^3.2.3",
"@wordpress/e2e-test-utils": "^4.16.1",
"config": "3.3.3",
"faker": "^5.1.0",
"fishery": "^1.2.0"
},
@ -34,8 +35,7 @@
"eslint": "^8.1.0"
},
"peerDependencies": {
"@woocommerce/api": "^0.2.0",
"@woocommerce/e2e-environment": "^0.2.3"
"@woocommerce/api": "^0.2.0"
},
"publishConfig": {
"access": "public"

View File

@ -1,5 +1,5 @@
import { HTTPClientFactory } from '@woocommerce/api';
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
import { simpleProductFactory } from './factories/simple-product';
import { variableProductFactory } from './factories/variable-product';
import { variationFactory } from './factories/variation';

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
const baseUrl = config.get( 'url' );
/**

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
/**
* Internal dependencies
@ -440,9 +440,10 @@ const merchant = {
*/
collapseAdminMenu: async ( collapse = true ) => {
const collapseButton = await page.$( '.folded #collapse-button' );
if ( ( ! collapse ) == collapseButton ) {
if ( ( ! collapseButton ) == collapse ) {
await collapseButton.click();
}
},
};

View File

@ -2,7 +2,7 @@
* External dependencies
*/
const { pressKeyWithModifier } = require( '@wordpress/e2e-test-utils' );
const { config } = require( '@woocommerce/e2e-environment' );
const config = require( 'config' );
/**
* Internal dependencies

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.1",
"woocommerce/woocommerce-admin": "3.0.3",
"woocommerce/woocommerce-blocks": "6.5.1"
},
"require-dev": {
@ -39,6 +39,11 @@
"sort-packages": true,
"platform": {
"php": "7.0.33"
},
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"composer/installers": true,
"bamarni/composer-bin-plugin": true
}
},
"autoload": {

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": "ebdb5708b79cdb94e4b2ff5fbed40d89",
"content-hash": "fb68c78e4ab4269155c3c9613af1a22a",
"packages": [
{
"name": "automattic/jetpack-autoloader",
@ -543,16 +543,16 @@
},
{
"name": "woocommerce/woocommerce-admin",
"version": "3.0.1",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "5542e80021a43d24ab9b1d2d67083b608899835d"
"reference": "0b1abab35c62717f3121428fe7f378998ef4899c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/5542e80021a43d24ab9b1d2d67083b608899835d",
"reference": "5542e80021a43d24ab9b1d2d67083b608899835d",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/0b1abab35c62717f3121428fe7f378998ef4899c",
"reference": "0b1abab35c62717f3121428fe7f378998ef4899c",
"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.1"
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v3.0.3"
},
"time": "2021-12-30T18:38:11+00:00"
"time": "2022-01-06T22:46:17+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",
@ -2926,5 +2926,5 @@
"platform-overrides": {
"php": "7.0.33"
},
"plugin-api-version": "2.1.0"
"plugin-api-version": "2.0.0"
}

View File

@ -123,7 +123,7 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
array(
'code' => $post_object->post_title,
'description' => $post_object->post_excerpt,
'status' => $post_object->post_status,
'status' => $post_object->post_status,
'date_created' => $this->string_to_timestamp( $post_object->post_date_gmt ),
'date_modified' => $this->string_to_timestamp( $post_object->post_modified_gmt ),
'date_expires' => metadata_exists( 'post', $coupon_id, 'date_expires' ) ? get_post_meta( $coupon_id, 'date_expires', true ) : get_post_meta( $coupon_id, 'expiry_date', true ), // @todo: Migrate expiry_date meta to date_expires in upgrade routine.

View File

@ -1498,19 +1498,19 @@ p.jetpack-terms {
background-color: #f4a224;
max-height: 3em;
max-width: 3em;
padding: ( 3.5em - 3em ) / 2;
padding: calc( ( 3.5em - 3em ) / 2 );
}
&.recommended-item-icon-automated_taxes {
background-color: #d0011b;
max-height: 1.75em;
padding: ( 3.5em - 1.75em ) / 2;
padding: calc( ( 3.5em - 1.75em ) / 2 );
}
&.recommended-item-icon-mailchimp {
background-color: #ffe01b;
height: 2em;
padding: ( 3.5em - 2em ) / 2;
padding: calc( ( 3.5em - 2em ) / 2 );
}
&.recommended-item-icon-woocommerce_services {

View File

@ -579,7 +579,7 @@ jQuery( function( $ ) {
var scrollElement = $( '.woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout' );
if ( ! scrollElement.length ) {
scrollElement = $( '.form.checkout' );
scrollElement = $( 'form.checkout' );
}
$.scroll_to_notices( scrollElement );
}

View File

@ -3230,7 +3230,7 @@ _registerModule('Tap', {
return;
}
if(!_moved && !_isMultitouch && !_numAnimations) {
if(!_moved && !_isMultitouch && !_numAnimations && self.container.contains(e.target)) {
var p0 = releasePoint;
if(tapTimer) {
clearTimeout(tapTimer);

View File

@ -9,7 +9,7 @@
"options": {
"commands": [
{
"command": "grunt assets",
"command": "pnpx grunt assets",
"forwardAllArgs": false
}
],
@ -25,11 +25,11 @@
"options": {
"commands": [
{
"command": "grunt eslint",
"command": "pnpx grunt eslint",
"forwardAllArgs": false
},
{
"command": "grunt stylelint",
"command": "pnpx grunt stylelint",
"forwardAllArgs": false
}
],

View File

@ -73,7 +73,7 @@
},
"engines": {
"node": "^16.13.1",
"npm": "^8.1.2"
"pnpm": "^6.24.2"
},
"husky": {
"hooks": {

View File

@ -53,7 +53,7 @@
"build-watch": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "grunt watch",
"command": "pnpx grunt watch",
"cwd": "plugins/woocommerce/legacy"
}
},

View File

@ -100,13 +100,38 @@ importers:
packages/js/e2e-core-tests:
specifiers:
'@babel/cli': 7.12.8
'@babel/core': 7.12.9
'@babel/plugin-proposal-async-generator-functions': ^7.16.4
'@babel/plugin-proposal-object-rest-spread': ^7.16.0
'@babel/plugin-transform-react-jsx': ^7.16.0
'@babel/plugin-transform-runtime': ^7.16.4
'@babel/polyfill': 7.12.1
'@babel/preset-env': 7.12.7
'@jest/globals': ^26.4.2
'@wordpress/babel-plugin-import-jsx-pragma': 1.1.3
'@wordpress/babel-preset-default': 3.0.2
'@wordpress/browserslist-config': ^4.1.0
'@wordpress/deprecated': ^3.2.3
config: 3.3.3
faker: ^5.1.0
dependencies:
'@jest/globals': 26.6.2
'@wordpress/deprecated': 3.2.3
config: 3.3.3
faker: 5.5.3
devDependencies:
'@babel/cli': 7.12.8_@babel+core@7.12.9
'@babel/core': 7.12.9
'@babel/plugin-proposal-async-generator-functions': 7.16.4_@babel+core@7.12.9
'@babel/plugin-proposal-object-rest-spread': 7.16.0_@babel+core@7.12.9
'@babel/plugin-transform-react-jsx': 7.16.0_@babel+core@7.12.9
'@babel/plugin-transform-runtime': 7.16.4_@babel+core@7.12.9
'@babel/polyfill': 7.12.1
'@babel/preset-env': 7.12.7_@babel+core@7.12.9
'@wordpress/babel-plugin-import-jsx-pragma': 1.1.3_@babel+core@7.12.9
'@wordpress/babel-preset-default': 3.0.2
'@wordpress/browserslist-config': 4.1.0
packages/js/e2e-environment:
specifiers:
@ -151,6 +176,7 @@ importers:
app-root-path: 3.0.0
commander: 4.1.1
jest: 25.5.4
jest-circus: 25.1.0
jest-each: 25.5.0
jest-puppeteer: 4.4.0
node-stream-zip: 1.15.0
@ -171,7 +197,6 @@ importers:
'@wordpress/browserslist-config': 4.1.0
'@wordpress/eslint-plugin': 7.3.0_eslint@8.2.0+typescript@4.2.4
eslint: 8.2.0
jest-circus: 25.1.0
ndb: 1.1.5
semver: 7.3.5
@ -193,6 +218,7 @@ importers:
'@wordpress/browserslist-config': ^4.1.0
'@wordpress/deprecated': ^3.2.3
'@wordpress/e2e-test-utils': ^4.16.1
config: 3.3.3
eslint: ^8.1.0
faker: ^5.1.0
fishery: ^1.2.0
@ -200,6 +226,7 @@ importers:
'@automattic/puppeteer-utils': github.com/Automattic/puppeteer-utils/0f3ec50
'@wordpress/deprecated': 3.2.3
'@wordpress/e2e-test-utils': 4.16.1_jest@27.3.1
config: 3.3.3
faker: 5.5.3
fishery: 1.4.0
devDependencies:
@ -7545,7 +7572,6 @@ packages:
engines: {node: '>= 6.0.0'}
dependencies:
json5: 2.2.0
dev: true
/config/3.3.6:
resolution: {integrity: sha512-Hj5916C5HFawjYJat1epbyY2PlAgLpBtDUlr0MxGLgo3p5+7kylyvnRY18PqJHgnNWXcdd0eWDemT7eYWuFgwg==}
@ -7660,7 +7686,7 @@ packages:
/core-js/2.6.12:
resolution: {integrity: sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==}
deprecated: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
deprecated: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
requiresBuild: true
/core-js/3.19.1:
@ -12407,7 +12433,7 @@ packages:
throat: 5.0.0
transitivePeerDependencies:
- supports-color
dev: true
dev: false
/jest-circus/27.3.1:
resolution: {integrity: sha512-v1dsM9II6gvXokgqq6Yh2jHCpfg7ZqV4jWY66u7npz24JnhP3NHxI0sKT7+ZMQ7IrOWHYAaeEllOySbDbWsiXw==}