From 29f11a5b5ac6ae36353d5927af00adec05bc71f8 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 22 Apr 2021 12:42:50 +0200 Subject: [PATCH 1/2] Added new e2e test to initiate wccom connect --- tests/e2e/core-tests/specs/index.js | 5 +- .../wp-admin-extensions-connect-wccom.test.js | 47 +++++++++++++++++++ .../wp-admin/test-extensions-connect-wccom.js | 6 +++ tests/e2e/utils/README.md | 2 + tests/e2e/utils/src/flows/constants.js | 1 + tests/e2e/utils/src/flows/merchant.js | 7 +++ 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js create mode 100644 tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js diff --git a/tests/e2e/core-tests/specs/index.js b/tests/e2e/core-tests/specs/index.js index 4380bb79d4f..c7cbd79b2fe 100644 --- a/tests/e2e/core-tests/specs/index.js +++ b/tests/e2e/core-tests/specs/index.js @@ -45,6 +45,7 @@ const runMerchantOrderEmailsTest = require( './merchant/wp-admin-order-emails.te const runOrderSearchingTest = require( './merchant/wp-admin-order-searching.test' ); const runAnalyticsPageLoadsTest = require( './merchant/wp-admin-analytics-page-loads.test' ); const runImportProductsTest = require( './merchant/wp-admin-product-import-csv.test' ); +const runInitiateWccomConnectionTest = require( './merchant/wp-admin-extensions-connect-wccom.test' ); // REST API tests const runExternalProductAPITest = require( './api/external-product.test' ); @@ -73,7 +74,7 @@ const runShopperTests = () => { runCheckoutCreateAccountTest(); runCheckoutLoginAccountTest(); runCartCalculateShippingTest(); - runCartRedirectionTest(); + runCartRedirectionTest(); runOrderEmailReceivingTest(); }; @@ -97,6 +98,7 @@ const runMerchantTests = () => { runProductSearchTest(); runMerchantOrdersCustomerPaymentPage(); runAnalyticsPageLoadsTest(); + runInitiateWccomConnectionTest(); } const runApiTests = () => { @@ -154,4 +156,5 @@ module.exports = { runCartRedirectionTest, runMyAccountCreateAccountTest, runOrderEmailReceivingTest, + runInitiateWccomConnectionTest, }; diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js new file mode 100644 index 00000000000..c43022d2024 --- /dev/null +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js @@ -0,0 +1,47 @@ +/* eslint-disable jest/no-export, jest/no-disabled-tests */ +/** + * Internal dependencies + */ + const { + merchant, +} = require( '@woocommerce/e2e-utils' ); + +/** + * External dependencies + */ +const { + it, + describe, + beforeAll, +} = require( '@jest/globals' ); + +const runInitiateWccomConnectionTest = () => { + describe('Merchant > Initiate WCCOM Connection', () => { + beforeAll(async () => { + await merchant.login(); + }); + + it('can initiate WCCOM connection', async () => { + await merchant.openExtensions(); + + // Click on a tab to choose WooCommerce Subscriptions extension + await Promise.all([ + expect(page).toClick('a.nav-tab', {text: "WooCommerce.com Subscriptions"}), + page.waitForNavigation({waitUntil: 'networkidle0'}), + ]); + + // Click on Connect button to initiate a WCCOM connection + await Promise.all([ + expect(page).toClick('.button-helper-connect'), + page.waitForNavigation({waitUntil: 'networkidle0'}), + ]); + + // Verify that you see a login page for connecting WCCOM account + await expect(page).toMatchElement('div.login'); + await expect(page).toMatchElement('input#usernameOrEmail'); + await expect(page).toMatchElement('button.button', {text: "Continue"}); + }); + }); +} + +module.exports = runInitiateWccomConnectionTest; diff --git a/tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js b/tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js new file mode 100644 index 00000000000..a7b4cd8deed --- /dev/null +++ b/tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js @@ -0,0 +1,6 @@ +/* + * Internal dependencies + */ +const { runInitiateWccomConnectionTest } = require( '@woocommerce/e2e-core-tests' ); + +runInitiateWccomConnectionTest(); diff --git a/tests/e2e/utils/README.md b/tests/e2e/utils/README.md index b7fdb4ec48a..9c7e6b4cf80 100644 --- a/tests/e2e/utils/README.md +++ b/tests/e2e/utils/README.md @@ -62,6 +62,7 @@ This package provides support for enabling retries in tests: - `WP_ADMIN_ANALYTICS_PAGES` - WooCommerce analytics page root - `WP_ADMIN_WC_SETTINGS` - WooCommerce settings page root - `WP_ADMIN_NEW_SHIPPING_ZONE` - WooCommerce new shipping zone +- `WP_ADMIN_WC_EXTENSIONS` - WooCommerce extensions page #### Front end @@ -100,6 +101,7 @@ This package provides support for enabling retries in tests: | `openAnalyticsPage` | | Open any Analytics page | | `openAllUsersView` | | Open the All Users page | | `openImportProducts` | | Open the Import Products page | +| `openExtensions` | | Go to WooCommerce -> Extensions | ### Shopper `shopper` diff --git a/tests/e2e/utils/src/flows/constants.js b/tests/e2e/utils/src/flows/constants.js index aefb87ec174..70e1e8f4fc3 100644 --- a/tests/e2e/utils/src/flows/constants.js +++ b/tests/e2e/utils/src/flows/constants.js @@ -36,6 +36,7 @@ export const WP_ADMIN_SETUP_WIZARD = WP_ADMIN_WC_HOME + '&path=%2Fsetup-wizard'; export const WP_ADMIN_ANALYTICS_PAGES = WP_ADMIN_WC_HOME + '&path=%2Fanalytics%2F'; export const WP_ADMIN_WC_SETTINGS = WP_ADMIN_PLUGIN_PAGE + 'wc-settings&tab='; export const WP_ADMIN_NEW_SHIPPING_ZONE = WP_ADMIN_WC_SETTINGS + 'shipping&zone_id=new'; +export const WP_ADMIN_WC_EXTENSIONS = WP_ADMIN_PLUGIN_PAGE + 'wc-addons'; /** * Shop pages. * @type {string} diff --git a/tests/e2e/utils/src/flows/merchant.js b/tests/e2e/utils/src/flows/merchant.js index 4e3add65a6e..dad590a4a63 100644 --- a/tests/e2e/utils/src/flows/merchant.js +++ b/tests/e2e/utils/src/flows/merchant.js @@ -20,6 +20,7 @@ const { WP_ADMIN_SETUP_WIZARD, WP_ADMIN_WC_HOME, WP_ADMIN_WC_SETTINGS, + WP_ADMIN_WC_EXTENSIONS, WP_ADMIN_NEW_SHIPPING_ZONE, WP_ADMIN_ANALYTICS_PAGES, WP_ADMIN_ALL_USERS_VIEW, @@ -121,6 +122,12 @@ const merchant = { } ); }, + openExtensions: async () => { + await page.goto( WP_ADMIN_WC_EXTENSIONS, { + waitUntil: 'networkidle0', + } ); + }, + runSetupWizard: async () => { const setupWizard = IS_RETEST_MODE ? WP_ADMIN_SETUP_WIZARD : WP_ADMIN_WC_HOME; await page.goto( setupWizard, { From ce1e2f260d0a06e8528c2a66bb681a16d1366a31 Mon Sep 17 00:00:00 2001 From: Veljko Date: Wed, 5 May 2021 09:29:38 +0200 Subject: [PATCH 2/2] Rename the test file --- .../{test-extensions-connect-wccom.js => wccom-connect.test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/e2e/specs/wp-admin/{test-extensions-connect-wccom.js => wccom-connect.test.js} (100%) diff --git a/tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js b/tests/e2e/specs/wp-admin/wccom-connect.test.js similarity index 100% rename from tests/e2e/specs/wp-admin/test-extensions-connect-wccom.js rename to tests/e2e/specs/wp-admin/wccom-connect.test.js