Merge branch 'trunk' into e2e/add-build-to-e2e-core-tests
This commit is contained in:
commit
2e1a021195
|
@ -35,7 +35,7 @@ jobs:
|
||||||
|
|
||||||
- name: Run smoke test.
|
- name: Run smoke test.
|
||||||
working-directory: package/woocommerce/plugins/woocommerce
|
working-directory: package/woocommerce/plugins/woocommerce
|
||||||
if: steps.installation.outcome == 'success'
|
if: always()
|
||||||
env:
|
env:
|
||||||
SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }}
|
SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }}
|
||||||
SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
|
SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
|
||||||
|
@ -66,7 +66,7 @@ jobs:
|
||||||
|
|
||||||
- name: Run E2E tests.
|
- name: Run E2E tests.
|
||||||
working-directory: package/woocommerce/plugins/woocommerce
|
working-directory: package/woocommerce/plugins/woocommerce
|
||||||
if: steps.installation.outcome == 'success'
|
if: always()
|
||||||
env:
|
env:
|
||||||
SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }}
|
SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }}
|
||||||
SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
|
SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
|
||||||
|
@ -96,7 +96,7 @@ jobs:
|
||||||
await script({github, context})
|
await script({github, context})
|
||||||
|
|
||||||
- name: Remove label from pull request.
|
- name: Remove label from pull request.
|
||||||
if: "${{ contains(github.event.pull_request.labels.*.name, 'run: smoke tests') }}"
|
if: always() && ${{ contains(github.event.label.name, format( 'run{0} smoke tests', ':') ) }}
|
||||||
uses: actions-ecosystem/action-remove-labels@v1
|
uses: actions-ecosystem/action-remove-labels@v1
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Removed the node-config dependency
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
- Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs.
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
- This package is now transpiled with Babel, which allows the usage of modern, yet compatible JS code.
|
- This package is now transpiled with Babel, which allows the usage of modern, yet compatible JS code.
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/globals": "^26.4.2",
|
"@jest/globals": "^26.4.2",
|
||||||
"@wordpress/deprecated": "^3.2.3",
|
"@wordpress/deprecated": "^3.2.3",
|
||||||
"config": "3.3.3",
|
|
||||||
"faker": "^5.1.0"
|
"faker": "^5.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -31,7 +30,8 @@
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@woocommerce/api": "^0.2.0",
|
"@woocommerce/api": "^0.2.0",
|
||||||
"@woocommerce/e2e-utils": "^0.1.6"
|
"@woocommerce/e2e-utils": "^0.1.6",
|
||||||
|
"@woocommerce/e2e-environment": "^0.2.3"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|
|
@ -12,7 +12,7 @@ const {
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
import deprecated from '@wordpress/deprecated';
|
import deprecated from '@wordpress/deprecated';
|
||||||
const {
|
const {
|
||||||
it,
|
it,
|
||||||
|
|
|
@ -6,7 +6,7 @@ const { HTTPClientFactory, Coupon } = require( '@woocommerce/api' );
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const { it, describe, beforeAll } = require( '@jest/globals' );
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ const { HTTPClientFactory, ExternalProduct } = require( '@woocommerce/api' );
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const { it, describe, beforeAll } = require( '@jest/globals' );
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@ const {
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const { it, describe, beforeAll } = require( '@jest/globals' );
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ const { HTTPClientFactory, Order } = require( '@woocommerce/api' );
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const { it, describe, beforeAll } = require( '@jest/globals' );
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ const { HTTPClientFactory } = require( '@woocommerce/api' );
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const { it, describe, beforeAll } = require( '@jest/globals' );
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@ const { HTTPClientFactory, VariableProduct, ProductVariation } = require( '@wooc
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const {
|
const {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
|
|
|
@ -11,8 +11,8 @@ const {
|
||||||
utils,
|
utils,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const discountedPrice = simpleProductPrice - 5.00;
|
const discountedPrice = simpleProductPrice - 5.00;
|
||||||
|
|
||||||
const couponDialogMessage = 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.';
|
const couponDialogMessage = 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.';
|
||||||
|
|
|
@ -9,9 +9,9 @@ const {
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
// TODO create a function for the logic below getConfigSimpleProduct(), see: https://github.com/woocommerce/woocommerce/issues/29072
|
// TODO create a function for the logic below getConfigSimpleProduct(), see: https://github.com/woocommerce/woocommerce/issues/29072
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
|
|
||||||
const runMerchantOrdersCustomerPaymentPage = () => {
|
const runMerchantOrdersCustomerPaymentPage = () => {
|
||||||
let orderId;
|
let orderId;
|
||||||
|
|
|
@ -9,10 +9,10 @@ const {
|
||||||
deleteAllEmailLogs,
|
deleteAllEmailLogs,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const customerEmail = config.get( 'addresses.customer.billing.email' );
|
const customerEmail = config.get( 'addresses.customer.billing.email' );
|
||||||
const adminEmail = config.has( 'users.admin.email' ) ? config.get( 'users.admin.email' ) : 'admin@woocommercecoree2etestsuite.com';
|
const adminEmail = config.get( 'users.admin.email', 'admin@woocommercecoree2etestsuite.com' );
|
||||||
const storeName = 'WooCommerce Core E2E Test Suite';
|
const storeName = config.get( 'storeName', 'WooCommerce Core E2E Test Suite' );
|
||||||
|
|
||||||
let orderId;
|
let orderId;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ const {
|
||||||
withRestApi,
|
withRestApi,
|
||||||
AdminEdit,
|
AdminEdit,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const {
|
const {
|
||||||
HTTPClientFactory,
|
HTTPClientFactory,
|
||||||
VariableProduct,
|
VariableProduct,
|
||||||
|
|
|
@ -12,8 +12,8 @@ const {
|
||||||
clickAndWaitForSelector,
|
clickAndWaitForSelector,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
|
|
||||||
const runRefundOrderTest = () => {
|
const runRefundOrderTest = () => {
|
||||||
describe('WooCommerce Orders > Refund an order', () => {
|
describe('WooCommerce Orders > Refund an order', () => {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
merchant,
|
merchant,
|
||||||
withRestApi,
|
withRestApi,
|
||||||
|
|
|
@ -23,13 +23,12 @@ const {
|
||||||
const {
|
const {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
beforeAll,
|
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
const VirtualProductName = 'Virtual Product Name';
|
const VirtualProductName = 'Virtual Product Name';
|
||||||
const NonVirtualProductName = 'Non-Virtual Product Name';
|
const NonVirtualProductName = 'Non-Virtual Product Name';
|
||||||
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
|
|
||||||
const openNewProductAndVerify = async () => {
|
const openNewProductAndVerify = async () => {
|
||||||
// Go to "add product" page
|
// Go to "add product" page
|
||||||
|
@ -41,10 +40,6 @@ const openNewProductAndVerify = async () => {
|
||||||
|
|
||||||
const runAddSimpleProductTest = () => {
|
const runAddSimpleProductTest = () => {
|
||||||
describe('Add New Simple Product Page', () => {
|
describe('Add New Simple Product Page', () => {
|
||||||
beforeAll(async () => {
|
|
||||||
await merchant.login();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can create simple virtual product and add it to the cart', async () => {
|
it('can create simple virtual product and add it to the cart', async () => {
|
||||||
|
|
||||||
// @todo: remove this once https://github.com/woocommerce/woocommerce/issues/31337 has been addressed
|
// @todo: remove this once https://github.com/woocommerce/woocommerce/issues/31337 has been addressed
|
||||||
|
@ -53,6 +48,7 @@ const runAddSimpleProductTest = () => {
|
||||||
height: 700,
|
height: 700,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
await merchant.login();
|
||||||
await openNewProductAndVerify();
|
await openNewProductAndVerify();
|
||||||
|
|
||||||
// Set product data and publish the product
|
// Set product data and publish the product
|
||||||
|
@ -120,11 +116,8 @@ const runAddSimpleProductTest = () => {
|
||||||
|
|
||||||
const runAddVariableProductTest = () => {
|
const runAddVariableProductTest = () => {
|
||||||
describe('Add New Variable Product Page', () => {
|
describe('Add New Variable Product Page', () => {
|
||||||
beforeAll(async () => {
|
|
||||||
await merchant.login();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can create product with variations', async () => {
|
it('can create product with variations', async () => {
|
||||||
|
await merchant.login();
|
||||||
await openNewProductAndVerify();
|
await openNewProductAndVerify();
|
||||||
|
|
||||||
// Set product data
|
// Set product data
|
||||||
|
|
|
@ -8,9 +8,9 @@ const {
|
||||||
createSimpleProduct
|
createSimpleProduct
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
|
|
||||||
const runProductSearchTest = () => {
|
const runProductSearchTest = () => {
|
||||||
describe('Products > Search and View a product', () => {
|
describe('Products > Search and View a product', () => {
|
||||||
|
|
|
@ -21,8 +21,8 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const california = 'state:US:CA';
|
const california = 'state:US:CA';
|
||||||
const sanFranciscoZIP = '94107';
|
const sanFranciscoZIP = '94107';
|
||||||
const shippingZoneNameUS = 'US with Flat rate';
|
const shippingZoneNameUS = 'US with Flat rate';
|
||||||
|
|
|
@ -18,8 +18,8 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const firstProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
const firstProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const secondProductPrice = '4.99';
|
const secondProductPrice = '4.99';
|
||||||
const fourProductPrice = firstProductPrice * 4;
|
const fourProductPrice = firstProductPrice * 4;
|
||||||
var twoProductsPrice = (+firstProductPrice) + (+secondProductPrice);
|
var twoProductsPrice = (+firstProductPrice) + (+secondProductPrice);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
afterAll,
|
afterAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
|
||||||
const runCartRedirectionTest = () => {
|
const runCartRedirectionTest = () => {
|
||||||
|
|
|
@ -17,9 +17,9 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const twoProductPrice = singleProductPrice * 2;
|
const twoProductPrice = singleProductPrice * 2;
|
||||||
|
|
||||||
const runCartPageTest = () => {
|
const runCartPageTest = () => {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const customerBilling = config.get( 'addresses.customer.billing' );
|
const customerBilling = config.get( 'addresses.customer.billing' );
|
||||||
|
|
||||||
const runCheckoutCreateAccountTest = () => {
|
const runCheckoutCreateAccountTest = () => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require('config');
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
const runCheckoutLoginAccountTest = () => {
|
const runCheckoutLoginAccountTest = () => {
|
||||||
describe('Shopper Checkout Login Account', () => {
|
describe('Shopper Checkout Login Account', () => {
|
||||||
|
|
|
@ -9,9 +9,9 @@ const {
|
||||||
uiUnblocked,
|
uiUnblocked,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const twoProductPrice = singleProductPrice * 2;
|
const twoProductPrice = singleProductPrice * 2;
|
||||||
const threeProductPrice = singleProductPrice * 3;
|
const threeProductPrice = singleProductPrice * 3;
|
||||||
const fourProductPrice = singleProductPrice * 4;
|
const fourProductPrice = singleProductPrice * 4;
|
||||||
|
|
|
@ -11,7 +11,7 @@ const {
|
||||||
|
|
||||||
let simplePostIdValue;
|
let simplePostIdValue;
|
||||||
let orderNum;
|
let orderNum;
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
|
||||||
const runMyAccountPayOrderTest = () => {
|
const runMyAccountPayOrderTest = () => {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
let simplePostIdValue;
|
let simplePostIdValue;
|
||||||
let orderId;
|
let orderId;
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const customerEmail = config.get( 'addresses.customer.billing.email' );
|
const customerEmail = config.get( 'addresses.customer.billing.email' );
|
||||||
const storeName = 'WooCommerce Core E2E Test Suite';
|
const storeName = 'WooCommerce Core E2E Test Suite';
|
||||||
|
|
|
@ -17,11 +17,11 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const singleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const singleProductPrice2 = config.has('products.simple.price') ? '1' + singleProductPrice : '19.99';
|
const singleProductPrice2 = '1' + singleProductPrice;
|
||||||
const singleProductPrice3 = config.has('products.simple.price') ? '2' + singleProductPrice : '29.99';
|
const singleProductPrice3 = '2' + singleProductPrice;
|
||||||
const clothing = 'Clothing';
|
const clothing = 'Clothing';
|
||||||
const audio = 'Audio';
|
const audio = 'Audio';
|
||||||
const hardware = 'Hardware';
|
const hardware = 'Hardware';
|
||||||
|
|
|
@ -9,7 +9,7 @@ const {
|
||||||
uiUnblocked
|
uiUnblocked
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
// Variables for simple product
|
// Variables for simple product
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
@ -20,7 +20,7 @@ const defaultVariableProduct = config.get( 'products.variable' );
|
||||||
let variableProductId;
|
let variableProductId;
|
||||||
|
|
||||||
// Variables for grouped product
|
// Variables for grouped product
|
||||||
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
const simpleProductPrice = config.get( 'products.simple.price', '9.99' );
|
||||||
const simple1 = {
|
const simple1 = {
|
||||||
name: simpleProductName + ' 1',
|
name: simpleProductName + ' 1',
|
||||||
regularPrice: simpleProductPrice
|
regularPrice: simpleProductPrice
|
||||||
|
|
|
@ -6,7 +6,7 @@ const {
|
||||||
shopper,
|
shopper,
|
||||||
createVariableProduct,
|
createVariableProduct,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
const config = require('config');
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
let variablePostIdValue;
|
let variablePostIdValue;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
- Added `post-results-to-github-pr.js` to post smoke test results to a GitHub PR.
|
- Added `post-results-to-github-pr.js` to post smoke test results to a GitHub PR.
|
||||||
|
|
|
@ -98,6 +98,22 @@ The E2E environment has the following methods to let us control Jest's overall b
|
||||||
E2E_RETRY_TIMES=2 pnpx wc-e2e test:e2e
|
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
|
#### Test Screenshots
|
||||||
|
|
||||||
The test sequencer provides a screenshot function for test failures. To enable screenshots on test failure use
|
The test sequencer provides a screenshot function for test failures. To enable screenshots on test failure use
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
|
const config = require('./config');
|
||||||
const jestConfig = require( './jest.config' );
|
const jestConfig = require( './jest.config' );
|
||||||
const jestPuppeteerConfig = require( './jest-puppeteer.config' );
|
const jestPuppeteerConfig = require( './jest-puppeteer.config' );
|
||||||
const jestobjectConfig = require('./jest-object.config');
|
const jestobjectConfig = require('./jest-object.config');
|
||||||
|
@ -12,6 +13,7 @@ const {
|
||||||
} = require( './use-config' );
|
} = require( './use-config' );
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
config,
|
||||||
jestConfig,
|
jestConfig,
|
||||||
...jestobjectConfig,
|
...jestobjectConfig,
|
||||||
jestPuppeteerConfig,
|
jestPuppeteerConfig,
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
# Unreleased
|
# 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
|
## Fixed
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
"@automattic/puppeteer-utils": "github:Automattic/puppeteer-utils#0f3ec50",
|
"@automattic/puppeteer-utils": "github:Automattic/puppeteer-utils#0f3ec50",
|
||||||
"@wordpress/deprecated": "^3.2.3",
|
"@wordpress/deprecated": "^3.2.3",
|
||||||
"@wordpress/e2e-test-utils": "^4.16.1",
|
"@wordpress/e2e-test-utils": "^4.16.1",
|
||||||
"config": "3.3.3",
|
|
||||||
"faker": "^5.1.0",
|
"faker": "^5.1.0",
|
||||||
"fishery": "^1.2.0"
|
"fishery": "^1.2.0"
|
||||||
},
|
},
|
||||||
|
@ -35,7 +34,8 @@
|
||||||
"eslint": "^8.1.0"
|
"eslint": "^8.1.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@woocommerce/api": "^0.2.0"
|
"@woocommerce/api": "^0.2.0",
|
||||||
|
"@woocommerce/e2e-environment": "^0.2.3"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { HTTPClientFactory } from '@woocommerce/api';
|
import { HTTPClientFactory } from '@woocommerce/api';
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
import { simpleProductFactory } from './factories/simple-product';
|
import { simpleProductFactory } from './factories/simple-product';
|
||||||
import { variableProductFactory } from './factories/variable-product';
|
import { variableProductFactory } from './factories/variable-product';
|
||||||
import { variationFactory } from './factories/variation';
|
import { variationFactory } from './factories/variation';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
const baseUrl = config.get( 'url' );
|
const baseUrl = config.get( 'url' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -440,10 +440,9 @@ const merchant = {
|
||||||
*/
|
*/
|
||||||
collapseAdminMenu: async ( collapse = true ) => {
|
collapseAdminMenu: async ( collapse = true ) => {
|
||||||
const collapseButton = await page.$( '.folded #collapse-button' );
|
const collapseButton = await page.$( '.folded #collapse-button' );
|
||||||
if ( ( ! collapseButton ) == collapse ) {
|
if ( ( ! collapse ) == collapseButton ) {
|
||||||
await collapseButton.click();
|
await collapseButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
const { pressKeyWithModifier } = require( '@wordpress/e2e-test-utils' );
|
const { pressKeyWithModifier } = require( '@wordpress/e2e-test-utils' );
|
||||||
const config = require( 'config' );
|
const { config } = require( '@woocommerce/e2e-environment' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -103,6 +103,9 @@ class WC_Template_Loader {
|
||||||
/**
|
/**
|
||||||
* Checks whether a block template with that name exists.
|
* Checks whether a block template with that name exists.
|
||||||
*
|
*
|
||||||
|
* **Note: ** This checks both the `templates` and `block-templates` directories
|
||||||
|
* as both conventions should be supported.
|
||||||
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
* @param string $template_name Template to check.
|
* @param string $template_name Template to check.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
@ -112,7 +115,31 @@ class WC_Template_Loader {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$has_template = is_readable( get_stylesheet_directory() . '/block-templates/' . $template_name . '.html' );
|
$has_template = false;
|
||||||
|
$template_filename = $template_name . '.html';
|
||||||
|
// Since Gutenberg 12.1.0, the conventions for block templates directories have changed,
|
||||||
|
// we should check both these possible directories for backwards-compatibility.
|
||||||
|
$possible_templates_dirs = array( 'templates', 'block-templates' );
|
||||||
|
|
||||||
|
// Combine the possible root directory names with either the template directory
|
||||||
|
// or the stylesheet directory for child themes, getting all possible block templates
|
||||||
|
// locations combinations.
|
||||||
|
$filepath = DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template_filename;
|
||||||
|
$legacy_filepath = DIRECTORY_SEPARATOR . 'block-templates' . DIRECTORY_SEPARATOR . $template_filename;
|
||||||
|
$possible_paths = array(
|
||||||
|
get_stylesheet_directory() . $filepath,
|
||||||
|
get_stylesheet_directory() . $legacy_filepath,
|
||||||
|
get_template_directory() . $filepath,
|
||||||
|
get_template_directory() . $legacy_filepath,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the first matching one.
|
||||||
|
foreach ( $possible_paths as $path ) {
|
||||||
|
if ( is_readable( $path ) ) {
|
||||||
|
$has_template = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the value of the result of the block template check.
|
* Filters the value of the result of the block template check.
|
||||||
|
|
|
@ -113,12 +113,10 @@ importers:
|
||||||
'@wordpress/babel-preset-default': 3.0.2
|
'@wordpress/babel-preset-default': 3.0.2
|
||||||
'@wordpress/browserslist-config': ^4.1.0
|
'@wordpress/browserslist-config': ^4.1.0
|
||||||
'@wordpress/deprecated': ^3.2.3
|
'@wordpress/deprecated': ^3.2.3
|
||||||
config: 3.3.3
|
|
||||||
faker: ^5.1.0
|
faker: ^5.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/globals': 26.6.2
|
'@jest/globals': 26.6.2
|
||||||
'@wordpress/deprecated': 3.2.3
|
'@wordpress/deprecated': 3.2.3
|
||||||
config: 3.3.3
|
|
||||||
faker: 5.5.3
|
faker: 5.5.3
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@babel/cli': 7.12.8_@babel+core@7.12.9
|
'@babel/cli': 7.12.8_@babel+core@7.12.9
|
||||||
|
@ -218,7 +216,6 @@ importers:
|
||||||
'@wordpress/browserslist-config': ^4.1.0
|
'@wordpress/browserslist-config': ^4.1.0
|
||||||
'@wordpress/deprecated': ^3.2.3
|
'@wordpress/deprecated': ^3.2.3
|
||||||
'@wordpress/e2e-test-utils': ^4.16.1
|
'@wordpress/e2e-test-utils': ^4.16.1
|
||||||
config: 3.3.3
|
|
||||||
eslint: ^8.1.0
|
eslint: ^8.1.0
|
||||||
faker: ^5.1.0
|
faker: ^5.1.0
|
||||||
fishery: ^1.2.0
|
fishery: ^1.2.0
|
||||||
|
@ -226,7 +223,6 @@ importers:
|
||||||
'@automattic/puppeteer-utils': github.com/Automattic/puppeteer-utils/0f3ec50
|
'@automattic/puppeteer-utils': github.com/Automattic/puppeteer-utils/0f3ec50
|
||||||
'@wordpress/deprecated': 3.2.3
|
'@wordpress/deprecated': 3.2.3
|
||||||
'@wordpress/e2e-test-utils': 4.16.1_jest@27.3.1
|
'@wordpress/e2e-test-utils': 4.16.1_jest@27.3.1
|
||||||
config: 3.3.3
|
|
||||||
faker: 5.5.3
|
faker: 5.5.3
|
||||||
fishery: 1.4.0
|
fishery: 1.4.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -7572,6 +7568,7 @@ packages:
|
||||||
engines: {node: '>= 6.0.0'}
|
engines: {node: '>= 6.0.0'}
|
||||||
dependencies:
|
dependencies:
|
||||||
json5: 2.2.0
|
json5: 2.2.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/config/3.3.6:
|
/config/3.3.6:
|
||||||
resolution: {integrity: sha512-Hj5916C5HFawjYJat1epbyY2PlAgLpBtDUlr0MxGLgo3p5+7kylyvnRY18PqJHgnNWXcdd0eWDemT7eYWuFgwg==}
|
resolution: {integrity: sha512-Hj5916C5HFawjYJat1epbyY2PlAgLpBtDUlr0MxGLgo3p5+7kylyvnRY18PqJHgnNWXcdd0eWDemT7eYWuFgwg==}
|
||||||
|
|
Loading…
Reference in New Issue