From d71a9d9ba929c3ea641e05a0b3b57136d8a333a4 Mon Sep 17 00:00:00 2001 From: jonathansadowski Date: Wed, 5 Jan 2022 14:44:31 -0600 Subject: [PATCH] Revert "Add config default values" --- packages/js/e2e-core-tests/CHANGELOG.md | 4 --- packages/js/e2e-core-tests/package.json | 4 +-- .../onboarding-tasklist.test.js | 2 +- .../e2e-core-tests/specs/api/coupon.test.js | 2 +- .../specs/api/external-product.test.js | 2 +- .../specs/api/grouped-product.test.js | 2 +- .../js/e2e-core-tests/specs/api/order.test.js | 2 +- .../specs/api/telemetry.test.js | 2 +- .../specs/api/variable-product.test.js | 2 +- .../wp-admin-order-apply-coupon.test.js | 4 +-- ...-admin-order-customer-payment-page.test.js | 4 +-- .../merchant/wp-admin-order-emails.test.js | 6 ++-- .../specs/merchant/wp-admin-order-new.test.js | 2 +- .../merchant/wp-admin-order-refund.test.js | 4 +-- .../wp-admin-order-status-filters.test.js | 2 ++ .../merchant/wp-admin-product-new.test.js | 4 +-- .../merchant/wp-admin-product-search.test.js | 4 +-- .../wp-admin-settings-shipping-zones.test.js | 4 +-- .../front-end-cart-calculate-shipping.test.js | 4 +-- .../front-end-cart-redirection.test.js | 2 +- .../specs/shopper/front-end-cart.test.js | 4 +-- .../front-end-checkout-create-account.test.js | 2 +- .../front-end-checkout-login-account.test.js | 2 +- .../specs/shopper/front-end-checkout.test.js | 4 +-- .../front-end-my-account-pay-order.test.js | 2 +- .../front-end-order-email-receiving.test.js | 2 +- ...ont-end-product-browse-search-sort.test.js | 8 ++--- .../shopper/front-end-single-product.test.js | 4 +-- ...front-end-variable-product-updates.test.js | 4 +-- packages/js/e2e-environment/CHANGELOG.md | 8 +---- packages/js/e2e-environment/README.md | 16 ---------- packages/js/e2e-environment/config/config.js | 32 ------------------- packages/js/e2e-environment/config/index.js | 2 -- packages/js/e2e-utils/CHANGELOG.md | 5 --- packages/js/e2e-utils/package.json | 4 +-- packages/js/e2e-utils/src/factories.js | 2 +- packages/js/e2e-utils/src/flows/constants.js | 2 +- packages/js/e2e-utils/src/flows/merchant.js | 5 +-- packages/js/e2e-utils/src/flows/shopper.js | 2 +- pnpm-lock.yaml | 5 ++- 40 files changed, 59 insertions(+), 118 deletions(-) delete mode 100644 packages/js/e2e-environment/config/config.js diff --git a/packages/js/e2e-core-tests/CHANGELOG.md b/packages/js/e2e-core-tests/CHANGELOG.md index 9195a643b23..e3c5f866a57 100644 --- a/packages/js/e2e-core-tests/CHANGELOG.md +++ b/packages/js/e2e-core-tests/CHANGELOG.md @@ -1,9 +1,5 @@ # Unreleased -## Changes - -- Removed the node-config dependency - ## Fixed - Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs. diff --git a/packages/js/e2e-core-tests/package.json b/packages/js/e2e-core-tests/package.json index e63c58fea39..9ba215ddc21 100644 --- a/packages/js/e2e-core-tests/package.json +++ b/packages/js/e2e-core-tests/package.json @@ -12,12 +12,12 @@ "dependencies": { "@jest/globals": "^26.4.2", "@wordpress/deprecated": "^3.2.3", + "config": "3.3.3", "faker": "^5.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" diff --git a/packages/js/e2e-core-tests/specs/activate-and-setup/onboarding-tasklist.test.js b/packages/js/e2e-core-tests/specs/activate-and-setup/onboarding-tasklist.test.js index c6e03feb6cd..a54fabc13c7 100644 --- a/packages/js/e2e-core-tests/specs/activate-and-setup/onboarding-tasklist.test.js +++ b/packages/js/e2e-core-tests/specs/activate-and-setup/onboarding-tasklist.test.js @@ -12,7 +12,7 @@ const { /** * External dependencies */ -const { config } = require( '@woocommerce/e2e-environment' ); +const config = require( 'config' ); import deprecated from '@wordpress/deprecated'; const { it, diff --git a/packages/js/e2e-core-tests/specs/api/coupon.test.js b/packages/js/e2e-core-tests/specs/api/coupon.test.js index d41dbb958ba..512cb6d8249 100644 --- a/packages/js/e2e-core-tests/specs/api/coupon.test.js +++ b/packages/js/e2e-core-tests/specs/api/coupon.test.js @@ -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' ); /** diff --git a/packages/js/e2e-core-tests/specs/api/external-product.test.js b/packages/js/e2e-core-tests/specs/api/external-product.test.js index 5e4b3ed3f83..6f8882aedf6 100644 --- a/packages/js/e2e-core-tests/specs/api/external-product.test.js +++ b/packages/js/e2e-core-tests/specs/api/external-product.test.js @@ -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' ); /** diff --git a/packages/js/e2e-core-tests/specs/api/grouped-product.test.js b/packages/js/e2e-core-tests/specs/api/grouped-product.test.js index ad1d5717991..3a1cf785dd0 100644 --- a/packages/js/e2e-core-tests/specs/api/grouped-product.test.js +++ b/packages/js/e2e-core-tests/specs/api/grouped-product.test.js @@ -10,7 +10,7 @@ const { /** * External dependencies */ -const { config } = require( '@woocommerce/e2e-environment' ); +const config = require( 'config' ); const { it, describe, beforeAll } = require( '@jest/globals' ); /** diff --git a/packages/js/e2e-core-tests/specs/api/order.test.js b/packages/js/e2e-core-tests/specs/api/order.test.js index 6bf560f10fa..0f4b5d75bed 100644 --- a/packages/js/e2e-core-tests/specs/api/order.test.js +++ b/packages/js/e2e-core-tests/specs/api/order.test.js @@ -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' ); /** diff --git a/packages/js/e2e-core-tests/specs/api/telemetry.test.js b/packages/js/e2e-core-tests/specs/api/telemetry.test.js index 139f1c0d376..7def25552ba 100644 --- a/packages/js/e2e-core-tests/specs/api/telemetry.test.js +++ b/packages/js/e2e-core-tests/specs/api/telemetry.test.js @@ -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' ); /** diff --git a/packages/js/e2e-core-tests/specs/api/variable-product.test.js b/packages/js/e2e-core-tests/specs/api/variable-product.test.js index 4579b6222fe..3fcea7a8792 100644 --- a/packages/js/e2e-core-tests/specs/api/variable-product.test.js +++ b/packages/js/e2e-core-tests/specs/api/variable-product.test.js @@ -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, diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js index 1696fa6fecf..6e70fa8f95a 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js @@ -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.'; diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-customer-payment-page.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-customer-payment-page.test.js index 92e047962bc..988dc193d30 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-customer-payment-page.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-customer-payment-page.test.js @@ -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; diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-emails.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-emails.test.js index 8d9b7e2fbc0..1fbb5a0099f 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-emails.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-emails.test.js @@ -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; diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-new.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-new.test.js index 39f510c437e..3dd15e2d758 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-new.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-new.test.js @@ -7,7 +7,7 @@ const { withRestApi, AdminEdit, } = require( '@woocommerce/e2e-utils' ); -const { config } = require( '@woocommerce/e2e-environment' ); +const config = require( 'config' ); const { HTTPClientFactory, VariableProduct, diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-refund.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-refund.test.js index f90f29ac36f..a2cc152406f 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-refund.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-refund.test.js @@ -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', () => { diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-status-filters.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-status-filters.test.js index 75b970184c1..5a2740774cd 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-status-filters.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-order-status-filters.test.js @@ -1,6 +1,8 @@ /** * Internal dependencies */ +const config = require( 'config' ); + const { merchant, withRestApi, diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js index 419d93abb68..ae470d20199 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js @@ -24,11 +24,11 @@ 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 openNewProductAndVerify = async () => { // Go to "add product" page diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-search.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-search.test.js index a4f39b9ae03..d397c5685dc 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-search.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-search.test.js @@ -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', () => { diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-settings-shipping-zones.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-settings-shipping-zones.test.js index 53716c179a5..ec59ac1df15 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-settings-shipping-zones.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-settings-shipping-zones.test.js @@ -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'; diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-cart-calculate-shipping.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-cart-calculate-shipping.test.js index 45a537c3db4..98add6b0d52 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-cart-calculate-shipping.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-cart-calculate-shipping.test.js @@ -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); diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-cart-redirection.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-cart-redirection.test.js index f83f3948362..e91262de4cd 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-cart-redirection.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-cart-redirection.test.js @@ -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 = () => { diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-cart.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-cart.test.js index fa70f769e39..fea98893cf7 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-cart.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-cart.test.js @@ -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 = () => { diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-create-account.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-create-account.test.js index 629185ada8e..71dc37a1bdf 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-create-account.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-create-account.test.js @@ -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 = () => { diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-login-account.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-login-account.test.js index 33141c6495e..b81d115cd36 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-login-account.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout-login-account.test.js @@ -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', () => { diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout.test.js index ea00b8911b3..47999a5d07d 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-checkout.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-checkout.test.js @@ -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; diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-my-account-pay-order.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-my-account-pay-order.test.js index f0ed8206fa7..4b6e9ca6609 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-my-account-pay-order.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-my-account-pay-order.test.js @@ -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 = () => { diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-order-email-receiving.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-order-email-receiving.test.js index 095122e2861..45961523c36 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-order-email-receiving.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-order-email-receiving.test.js @@ -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'; diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-product-browse-search-sort.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-product-browse-search-sort.test.js index fab50e10b7d..a0a1a298582 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-product-browse-search-sort.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-product-browse-search-sort.test.js @@ -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'; diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-single-product.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-single-product.test.js index 213e2d52aa6..6a04850ca52 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-single-product.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-single-product.test.js @@ -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 diff --git a/packages/js/e2e-core-tests/specs/shopper/front-end-variable-product-updates.test.js b/packages/js/e2e-core-tests/specs/shopper/front-end-variable-product-updates.test.js index bb64ca46c89..8c0ac5a9c5f 100644 --- a/packages/js/e2e-core-tests/specs/shopper/front-end-variable-product-updates.test.js +++ b/packages/js/e2e-core-tests/specs/shopper/front-end-variable-product-updates.test.js @@ -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; diff --git a/packages/js/e2e-environment/CHANGELOG.md b/packages/js/e2e-environment/CHANGELOG.md index 7fabf853710..a73b7838292 100644 --- a/packages/js/e2e-environment/CHANGELOG.md +++ b/packages/js/e2e-environment/CHANGELOG.md @@ -1,17 +1,11 @@ # 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 `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` diff --git a/packages/js/e2e-environment/README.md b/packages/js/e2e-environment/README.md index 0aef343c41e..e18973d5f3a 100644 --- a/packages/js/e2e-environment/README.md +++ b/packages/js/e2e-environment/README.md @@ -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 diff --git a/packages/js/e2e-environment/config/config.js b/packages/js/e2e-environment/config/config.js deleted file mode 100644 index 7cb078255fd..00000000000 --- a/packages/js/e2e-environment/config/config.js +++ /dev/null @@ -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; diff --git a/packages/js/e2e-environment/config/index.js b/packages/js/e2e-environment/config/index.js index b4fd540211c..ba96035504a 100644 --- a/packages/js/e2e-environment/config/index.js +++ b/packages/js/e2e-environment/config/index.js @@ -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, diff --git a/packages/js/e2e-utils/CHANGELOG.md b/packages/js/e2e-utils/CHANGELOG.md index 490cf0e5cde..d5f40537e1c 100644 --- a/packages/js/e2e-utils/CHANGELOG.md +++ b/packages/js/e2e-utils/CHANGELOG.md @@ -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 diff --git a/packages/js/e2e-utils/package.json b/packages/js/e2e-utils/package.json index 891c3d52630..9ab299798d2 100644 --- a/packages/js/e2e-utils/package.json +++ b/packages/js/e2e-utils/package.json @@ -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" diff --git a/packages/js/e2e-utils/src/factories.js b/packages/js/e2e-utils/src/factories.js index fb7f080f825..4ebc5e38041 100644 --- a/packages/js/e2e-utils/src/factories.js +++ b/packages/js/e2e-utils/src/factories.js @@ -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'; diff --git a/packages/js/e2e-utils/src/flows/constants.js b/packages/js/e2e-utils/src/flows/constants.js index 17010823f52..118a207bdd6 100644 --- a/packages/js/e2e-utils/src/flows/constants.js +++ b/packages/js/e2e-utils/src/flows/constants.js @@ -1,7 +1,7 @@ /** * External dependencies */ -const { config } = require( '@woocommerce/e2e-environment' ); +const config = require( 'config' ); const baseUrl = config.get( 'url' ); /** diff --git a/packages/js/e2e-utils/src/flows/merchant.js b/packages/js/e2e-utils/src/flows/merchant.js index ec5b2986492..ab880f255de 100644 --- a/packages/js/e2e-utils/src/flows/merchant.js +++ b/packages/js/e2e-utils/src/flows/merchant.js @@ -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(); } + }, }; diff --git a/packages/js/e2e-utils/src/flows/shopper.js b/packages/js/e2e-utils/src/flows/shopper.js index 92fbecb291a..3f9e2cb43ff 100644 --- a/packages/js/e2e-utils/src/flows/shopper.js +++ b/packages/js/e2e-utils/src/flows/shopper.js @@ -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 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b52496d01f5..89b0cb723f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,10 +102,12 @@ importers: specifiers: '@jest/globals': ^26.4.2 '@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 packages/js/e2e-environment: @@ -193,6 +195,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 +203,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 +7549,6 @@ packages: engines: {node: '>= 6.0.0'} dependencies: json5: 2.2.0 - dev: true /config/3.3.6: resolution: {integrity: sha512-Hj5916C5HFawjYJat1epbyY2PlAgLpBtDUlr0MxGLgo3p5+7kylyvnRY18PqJHgnNWXcdd0eWDemT7eYWuFgwg==}