diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index 88ad7d60..fcb489da 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -29,7 +29,6 @@ jobs: needs: setup uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main with: - only-module-tests: true module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'bluehost/bluehost-wordpress-plugin' @@ -41,7 +40,6 @@ jobs: needs: setup uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main with: - only-module-tests: true module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-hostgator' @@ -53,7 +51,6 @@ jobs: needs: setup uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main with: - only-module-tests: true module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-crazy-domains' diff --git a/bootstrap.php b/bootstrap.php index 6e168e73..b9b39e69 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -5,7 +5,7 @@ use function NewfoldLabs\WP\ModuleLoader\register; -define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.3.33' ); +define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.3.34' ); if ( function_exists( 'is_admin' ) && is_admin() ) { $old_woocommerce_module_version = get_option( 'nfd_ecommerce_module_version' ); diff --git a/build/index.asset.php b/build/index.asset.php index b68f6dde..2d040723 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '82fc366b1c64c71eb887'); + array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'fcffdffca026344a7b49'); diff --git a/composer.lock b/composer.lock index 97bef54d..768c67ea 100644 --- a/composer.lock +++ b/composer.lock @@ -237,16 +237,16 @@ }, { "name": "newfold-labs/wp-module-coming-soon", - "version": "1.2.4", + "version": "1.2.5", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-coming-soon.git", - "reference": "05112a5908bb08ca0aa3aa7d7e7c508d44401b28" + "reference": "36da71998930ffc6fcb13d2ea082b82507a284b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-coming-soon/zipball/05112a5908bb08ca0aa3aa7d7e7c508d44401b28", - "reference": "05112a5908bb08ca0aa3aa7d7e7c508d44401b28", + "url": "https://api.github.com/repos/newfold-labs/wp-module-coming-soon/zipball/36da71998930ffc6fcb13d2ea082b82507a284b2", + "reference": "36da71998930ffc6fcb13d2ea082b82507a284b2", "shasum": "" }, "require": { @@ -284,10 +284,10 @@ ], "description": "Coming Soon module for WordPress sites.", "support": { - "source": "https://github.com/newfold-labs/wp-module-coming-soon/tree/1.2.4", + "source": "https://github.com/newfold-labs/wp-module-coming-soon/tree/1.2.5", "issues": "https://github.com/newfold-labs/wp-module-coming-soon/issues" }, - "time": "2024-05-31T16:22:17+00:00" + "time": "2024-06-19T19:13:33+00:00" }, { "name": "newfold-labs/wp-module-context", @@ -345,16 +345,16 @@ }, { "name": "newfold-labs/wp-module-data", - "version": "2.5.2", + "version": "2.5.3", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-data.git", - "reference": "bd9642c155735fac8f114ea1eb237da4a72eb267" + "reference": "6c0941bc9ac3d18820f924de8c4afe58bb421782" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-data/zipball/bd9642c155735fac8f114ea1eb237da4a72eb267", - "reference": "bd9642c155735fac8f114ea1eb237da4a72eb267", + "url": "https://api.github.com/repos/newfold-labs/wp-module-data/zipball/6c0941bc9ac3d18820f924de8c4afe58bb421782", + "reference": "6c0941bc9ac3d18820f924de8c4afe58bb421782", "shasum": "" }, "require": { @@ -367,10 +367,20 @@ }, "require-dev": { "10up/wp_mock": "^0.4.2", + "bluehost/bluehost-wordpress-plugin": "*", + "brianhenryie/composer-phpstorm": "*", "johnpbloch/wordpress": "*", - "newfold-labs/wp-php-standards": "^1.2" + "kporras07/composer-symlinks": "^1.2", + "lucatume/wp-browser": "^3", + "newfold-labs/wp-php-standards": "^1.2", + "wpackagist-plugin/woocommerce": "*" }, "type": "library", + "extra": { + "symlinks": { + ".": "wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-data" + } + }, "autoload": { "psr-4": { "NewfoldLabs\\WP\\Module\\Data\\": "includes/" @@ -381,8 +391,14 @@ }, "autoload-dev": { "psr-4": { - "NewfoldLabs\\WP\\Module\\Data\\": "tests/phpunit/includes/" - } + "NewfoldLabs\\WP\\Module\\Data\\": [ + "tests/phpunit/includes/", + "tests/wpunit/includes" + ] + }, + "classmap": [ + "wordpress" + ] }, "scripts": { "fix": [ @@ -393,6 +409,15 @@ ], "lint": [ "vendor/bin/phpcs . --standard=phpcs.xml -s" + ], + "create-symlinks": [ + "Kporras07\\ComposerSymlinks\\ScriptHandler::createSymlinks" + ], + "post-install-cmd": [ + "@create-symlinks" + ], + "post-update-cmd": [ + "@create-symlinks" ] }, "license": [ @@ -400,10 +425,10 @@ ], "description": "Newfold Data Module", "support": { - "source": "https://github.com/newfold-labs/wp-module-data/tree/2.5.2", + "source": "https://github.com/newfold-labs/wp-module-data/tree/2.5.3", "issues": "https://github.com/newfold-labs/wp-module-data/issues" }, - "time": "2024-05-30T18:45:12+00:00" + "time": "2024-06-19T17:34:08+00:00" }, { "name": "newfold-labs/wp-module-install-checker", @@ -3210,16 +3235,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -3269,7 +3294,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -3285,20 +3310,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", "shasum": "" }, "require": { @@ -3347,7 +3372,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" }, "funding": [ { @@ -3363,20 +3388,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", "shasum": "" }, "require": { @@ -3428,7 +3453,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" }, "funding": [ { @@ -3444,20 +3469,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -3508,7 +3533,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -3524,20 +3549,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", "shasum": "" }, "require": { @@ -3584,7 +3609,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" }, "funding": [ { @@ -3600,20 +3625,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", "shasum": "" }, "require": { @@ -3664,7 +3689,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, "funding": [ { @@ -3680,20 +3705,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", - "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af", "shasum": "" }, "require": { @@ -3740,7 +3765,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0" }, "funding": [ { @@ -3756,7 +3781,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/process", @@ -4832,16 +4857,16 @@ }, { "name": "wp-cli/extension-command", - "version": "v2.1.21", + "version": "v2.1.22", "source": { "type": "git", "url": "https://github.com/wp-cli/extension-command.git", - "reference": "f9bc3fd2f2dabcbe9b3bc3dc9591535dd714fd3c" + "reference": "7baa058ae33e78a8e19f6a189203ed08e03a21be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/f9bc3fd2f2dabcbe9b3bc3dc9591535dd714fd3c", - "reference": "f9bc3fd2f2dabcbe9b3bc3dc9591535dd714fd3c", + "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/7baa058ae33e78a8e19f6a189203ed08e03a21be", + "reference": "7baa058ae33e78a8e19f6a189203ed08e03a21be", "shasum": "" }, "require": { @@ -4924,9 +4949,9 @@ "homepage": "https://github.com/wp-cli/extension-command", "support": { "issues": "https://github.com/wp-cli/extension-command/issues", - "source": "https://github.com/wp-cli/extension-command/tree/v2.1.21" + "source": "https://github.com/wp-cli/extension-command/tree/v2.1.22" }, - "time": "2024-05-02T13:35:09+00:00" + "time": "2024-06-04T12:24:31+00:00" }, { "name": "wp-cli/i18n-command", @@ -6202,5 +6227,5 @@ "platform-overrides": { "php": "7.3.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/includes/ECommerce.php b/includes/ECommerce.php index c81e0f0b..25157b4d 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -67,7 +67,7 @@ class ECommerce { 'woocommerce_cheque_settings', 'onboarding_experience_level', 'yoast_seo_signup_status', - 'showMigrationSteps', + 'nfd_show_migration_steps', 'update_site_server_clicked', ); @@ -108,6 +108,7 @@ public function __construct( Container $container ) { add_action( 'auth_cookie_expired', array( $this, 'show_store_setup' ) ); add_action( 'admin_head', array( $this, 'hide_wp_pointer_with_css' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'set_wpnav_collapse_setting' ) ); + add_action('admin_footer', array( $this, 'remove_woocommerce_ssl_notice' ), 20); if ( ( $container->plugin()->id === 'bluehost' && ( $canAccessGlobalCTB || $hasYithExtended ) ) || ( $container->plugin()->id === 'hostgator' && $hasYithExtended ) ) { add_filter( 'admin_menu', array( $this, 'custom_add_promotion_menu_item' ) ); @@ -321,7 +322,7 @@ public function register_settings() { ); \register_setting( 'general', - 'showMigrationSteps', + 'nfd_show_migration_steps', array( 'show_in_rest' => true, 'type' => 'boolean', @@ -586,6 +587,40 @@ public function hide_columns() { } } + /** + * Hide WooCommerce SSL notice + * + * @return void + */ + + public function remove_woocommerce_ssl_notice() { + + // Check if WooCommerce is active. + if (!class_exists('WooCommerce')) { + return; + } + + if (!is_ssl()) { + // Check if there are any WooCommerce admin notices, find the one with ssl notice link and hide it. + ?> + + )} {itemsToDisplay.length > 0 && ( - + {itemsToDisplay.map((item) => ( ))} diff --git a/src/components/OnboardingScreen.js b/src/components/OnboardingScreen.js index 1d08cef2..f2119c51 100644 --- a/src/components/OnboardingScreen.js +++ b/src/components/OnboardingScreen.js @@ -65,7 +65,7 @@ export function OnboardingScreen({ useEffect(() => { WordPressSdk.settings.get().then((res) => { - setIsMigrationCompleted( res.showMigrationSteps || false ); + setIsMigrationCompleted( res.nfd_show_migration_steps || false ); setWebServersUpdated( res.update_site_server_clicked ); if (res?.page_on_front && res?.show_on_front === "page") { setEditUrl( diff --git a/src/components/SiteStatus.js b/src/components/SiteStatus.js index debd6fbd..af770ec8 100644 --- a/src/components/SiteStatus.js +++ b/src/components/SiteStatus.js @@ -44,8 +44,14 @@ export function SiteStatus({ comingSoon, toggleComingSoon, notify }) { $statusText.style.setProperty("color", "var(--nfd-ecommerce-text-dark-success)"); } }); + + if (!comingSoon) { + return null; + } + return (
- + <Title size="4" className="nfd-leading-normal" data-testid="nfd-nowoo-store-title"> {__("Add a store to your site for FREE!", "wp-module-ecommerce")} - + {__( "Adding a store to your website is quick and easy! \nJust install the free WooCommerce plugin and get ready to start making money!", "wp-module-ecommerce" diff --git a/src/configs/OnboardingList.config.js b/src/configs/OnboardingList.config.js index 6fbaeb5d..3f9b11cc 100644 --- a/src/configs/OnboardingList.config.js +++ b/src/configs/OnboardingList.config.js @@ -57,7 +57,7 @@ const updateMigrateViewGuide = () => { }; const updateStoreSetup = (setIsMigrationCompleted) => { - WordPressSdk.settings.put({ showMigrationSteps: false }).then(() => { + WordPressSdk.settings.put({ nfd_show_migration_steps: false }).then(() => { WordPressSdk.settings.get(); setIsMigrationCompleted(false); }); @@ -81,13 +81,14 @@ export function OnboardingListDefinition(props) { cards: [ { name: "Update your website nameservers", + id: "nameservers", text: __( "Update your website nameservers", "wp-module-ecommerce" ), state: { isCompleted: (queries) => queries?.settings?.update_site_server_clicked || check_url_match(brandName), - isMigrated: (queries) => queries?.settings?.showMigrationSteps && props.isMigrationCompleted + isMigrated: (queries) => queries?.settings?.nfd_show_migration_steps && props.isMigrationCompleted }, shouldRender: (state) => (state.isMigrated), actions: { @@ -104,13 +105,14 @@ export function OnboardingListDefinition(props) { }, { name: "Connect this site to your domain", + id: "domain", text: __( "Connect this site to your domain", "wp-module-ecommerce" ), state: { isCompleted: () => check_url_match( brandName ), - isMigrated: (queries) => queries?.settings?.showMigrationSteps && props.isMigrationCompleted, + isMigrated: (queries) => queries?.settings?.nfd_show_migration_steps && props.isMigrationCompleted, }, "data-nfdhelpcenterquery": __( @@ -127,13 +129,14 @@ export function OnboardingListDefinition(props) { }, { name: "Need help with these steps?", + id: "help", text: __( "Need help with these steps?", "wp-module-ecommerce" ), state: { isCompleted: (queries) => (queries?.settings?.update_site_server_clicked && check_url_match(brandName)) || check_url_match(brandName), - isMigrated: (queries) => queries?.settings?.showMigrationSteps, + isMigrated: (queries) => queries?.settings?.nfd_show_migration_steps, className: () => "nfd-bg-canvas", hideCheck: () => true, showText: () => View Guide @@ -148,13 +151,14 @@ export function OnboardingListDefinition(props) { }, { name: "Continue with store setup", + id: "continue", text: __( "Continue with store setup", "wp-module-ecommerce" ), state: { isCompleted: (queries) => !props.isMigrationCompleted, - isMigrated: (queries) => queries?.settings?.showMigrationSteps && (queries?.settings?.update_site_server_clicked || check_url_match(brandName)), + isMigrated: (queries) => queries?.settings?.nfd_show_migration_steps && (queries?.settings?.update_site_server_clicked || check_url_match(brandName)), }, shouldRender: (state) => state.isMigrated && !state.isCompleted, actions: { @@ -166,6 +170,7 @@ export function OnboardingListDefinition(props) { }, { name: "Sign up for Bluehost WordPress Academy", + id: "academy", text: __( "Sign up for Bluehost WordPress Academy", "wp-module-ecommerce" @@ -187,6 +192,7 @@ export function OnboardingListDefinition(props) { }, { name: "New Order Received", + id: "neworder", text: __( "New Order Received", "wp-module-ecommerce" @@ -204,6 +210,7 @@ export function OnboardingListDefinition(props) { }, { name: "Add your store info", + id: "storeinfo", text: __("Add your store info", "wp-module-ecommerce"), state: { isAvailable: (queries) => queries?.plugins?.isWCActive, @@ -219,6 +226,7 @@ export function OnboardingListDefinition(props) { }, { name: "Connect a payment processor", + id: "paymentprocessor", text: __("Connect a payment processor", "wp-module-ecommerce"), state: { isAvailable: (queries) => @@ -243,6 +251,7 @@ export function OnboardingListDefinition(props) { }, { name: "Setup shipping options", + id: "shipping", text: __("Setup shipping options", "wp-module-ecommerce"), state: { isAvailable: (queries) => @@ -263,6 +272,7 @@ export function OnboardingListDefinition(props) { }, { name: "Configure tax settings", + id: "tax", text: __("Configure tax settings", "wp-module-ecommerce"), state: { isAvailable: (queries) => queries?.plugins?.isWCActive, @@ -278,6 +288,7 @@ export function OnboardingListDefinition(props) { }, { name: "Add a product", + id: "addproduct", text: __("Add a product", "wp-module-ecommerce"), state: { isActive: (queries) => queries?.plugins?.isWCActive, @@ -294,6 +305,7 @@ export function OnboardingListDefinition(props) { }, { name: "Sign up for Yoast SEO Academy", + id: "seoacademy", text: __("Sign up for Yoast SEO Academy", "wp-module-ecommerce"), state: { isAvailable: (queries) => queries?.settings?.isNovice, @@ -310,6 +322,7 @@ export function OnboardingListDefinition(props) { }, { name: "Add a new page to your site", + id: "newpage", text: NewfoldRuntime.hasCapability("isEcommerce") ? __("Add a new page to your store", "wp-module-ecommerce") : __("Add a new page to your site", "wp-module-ecommerce"), @@ -332,6 +345,7 @@ export function OnboardingListDefinition(props) { }, { name: "Upload media to your site", + id: "media", text: __("Upload media to your site", "wp-module-ecommerce"), state: { isCompleted: (queries) => queries?.media, @@ -350,6 +364,7 @@ export function OnboardingListDefinition(props) { }, { name: "Connect to your social media accounts", + id: "social", text: __( "Connect to your social media accounts", "wp-module-ecommerce" @@ -374,6 +389,7 @@ export function OnboardingListDefinition(props) { }, { name: "Enable Jetpack to connect to your social media accounts", + id: "jetpack", text: __( "Enable Jetpack to connect to your social media accounts", "wp-module-ecommerce" diff --git a/tests/cypress/integration/Home/ecommerce-coming-soon.cy.js b/tests/cypress/integration/Home/ecommerce-coming-soon.cy.js new file mode 100644 index 00000000..cc77c91a --- /dev/null +++ b/tests/cypress/integration/Home/ecommerce-coming-soon.cy.js @@ -0,0 +1,90 @@ +import { GetPluginId } from '../wp-module-support/pluginID.cy'; +import { + wpLogin, + comingSoon, + uninstallPlugins, +} from '../wp-module-support/utils.cy'; +import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy'; + +const customCommandTimeout = 20000; +const pluginId = GetPluginId(); +const hg_region = 'br'; + +describe( + 'e-commerce Home Page- Coming soon mode', + { testIsolation: true }, + () => { + beforeEach( () => { + wpLogin(); + uninstallPlugins(); + comingSoon( true ); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); + } ); + + it( 'Verify Congrats on your new site message, coming soon alert', () => { + cy.get( '.nfd-gap-4 .nfd-title.nfd-title--2', { + timeout: customCommandTimeout, + } ) + .eq( 0 ) + .should( 'exist' ); + cy.get( '.nfd-alert.nfd-alert--warning', { + timeout: customCommandTimeout, + } ) + .as( 'comingsoonalert' ) + .should( 'exist' ); + cy.get( '@comingsoonalert' ) + .find( '.nfd-validation-icon' ) + .should( 'exist' ); + cy.get( '@comingsoonalert' ) + .find( '.nfd-validation-message' ) + .should( 'exist' ); + } ); + + it( 'Verify Site Preview flex and View your site option', () => { + cy.get( '.nfd-justify-start > .nfd-flex-col > .nfd-absolute', { + timeout: customCommandTimeout, + } ) + .as( 'sitePreviewFlex' ) + .should( 'exist' ); + cy.get( '@sitePreviewFlex' ) + .trigger( 'mouseover' ) + .find( '[data-cy="view-site"]' ) + .should( 'exist' ) + .invoke( 'removeAttr', 'target' ) + .click(); + cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); + cy.go( 'back' ); + } ); + + it( 'Verify presense of Ready to go to live? canvas', () => { + cy.get( '.nfd-px-4', { timeout: customCommandTimeout } ) + .as( 'readyToGoNextLevel' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) + .find( '.nfd-flex-1 h1' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel' ) + .find( '.nfd-flex-1 span' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) + .find( '#view-site' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel' ) + .find( '#launch-site' ) + .should( 'exist' ); + } ); + + it( 'Verify Visit your site and Launch your site functionality', () => { + cy.get( '.nfd-flex-none > .nfd-button--secondary', { + timeout: customCommandTimeout, + } ) + .invoke( 'removeAttr', 'target' ) + .click(); + cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); + cy.go( 'back' ); + cy.get( '.nfd-flex-none > .nfd-button--upsell' ).click(); + cy.get('[data-testid="siteStatus"]').should('not.exist'); + cy.get( '.nfd-notification--success' ).should( 'exist' ); + } ); + } +); diff --git a/tests/cypress/integration/Home/ecommerce-live.cy.js b/tests/cypress/integration/Home/ecommerce-live.cy.js new file mode 100644 index 00000000..9ff3d278 --- /dev/null +++ b/tests/cypress/integration/Home/ecommerce-live.cy.js @@ -0,0 +1,40 @@ +import { GetPluginId } from '../wp-module-support/pluginID.cy'; +import { + wpLogin, + comingSoon, + uninstallPlugins, +} from '../wp-module-support/utils.cy'; + +const customCommandTimeout = 20000; +const pluginId = GetPluginId(); + +describe( 'e-commerce Home Page- Live Mode', { testIsolation: true }, () => { + beforeEach( () => { + wpLogin(); + uninstallPlugins(); + comingSoon( false ); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); + } ); + + it( 'Verify presense of Ready to go to next level? canvas', () => { + cy.get( '.nfd-flex.nfd-gap-4', { timeout: customCommandTimeout } ) + .eq( 2 ) + .as( 'readyToGoNextLevel' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) + .find( 'h1' ) + .should( 'exist' ); + cy.get( '@readyToGoNextLevel' ).find( 'div span' ).should( 'exist' ); + } ); + + it( 'Verify by default View Site option should be displayed', () => { + cy.get( '.nfd-button--primary', { + timeout: customCommandTimeout, + } ) + .eq( 1 ) + .should( 'exist' ) + .invoke( 'removeAttr', 'target' ) + .click(); + cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); + } ); +} ); diff --git a/tests/cypress/integration/Home/commerceHomePage.cy.js b/tests/cypress/integration/Home/ecommerce-next-steps.cy.js similarity index 63% rename from tests/cypress/integration/Home/commerceHomePage.cy.js rename to tests/cypress/integration/Home/ecommerce-next-steps.cy.js index 1e2d2c73..8293cb16 100644 --- a/tests/cypress/integration/Home/commerceHomePage.cy.js +++ b/tests/cypress/integration/Home/ecommerce-next-steps.cy.js @@ -1,8 +1,9 @@ import { GetPluginId } from '../wp-module-support/pluginID.cy'; import { + wpLogin, comingSoon, viewCompletedTasks, - viewRemainingTasks + viewRemainingTasks, } from '../wp-module-support/utils.cy'; import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy'; @@ -10,122 +11,7 @@ const customCommandTimeout = 20000; const pluginId = GetPluginId(); const hg_region = 'br'; -describe( 'Commerce Home Page- Coming soon mode', () => { - before( () => { - cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { - failOnNonZeroExit: false, - } ); - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - comingSoon( true ); - } ); - - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - } ); - - it( 'Verify Congrats on your new site message, coming soon alert', () => { - cy.get( '.nfd-gap-4 .nfd-title.nfd-title--2', { - timeout: customCommandTimeout, - } ) - .eq( 0 ) - .should( 'exist' ); - cy.get( '.nfd-alert.nfd-alert--warning', { - timeout: customCommandTimeout, - } ) - .as( 'comingsoonalert' ) - .should( 'exist' ); - cy.get( '@comingsoonalert' ) - .find( '.nfd-validation-icon' ) - .should( 'exist' ); - cy.get( '@comingsoonalert' ) - .find( '.nfd-validation-message' ) - .should( 'exist' ); - } ); - - it( 'Verify Site Preview flex and View your site option', () => { - cy.get( '.nfd-justify-start > .nfd-flex-col > .nfd-absolute', { - timeout: customCommandTimeout, - } ) - .as( 'sitePreviewFlex' ) - .should( 'exist' ); - cy.get( '@sitePreviewFlex' ) - .trigger( 'mouseover' ) - .find( '[data-cy="view-site"]' ) - .should( 'exist' ) - .invoke( 'removeAttr', 'target' ) - .click(); - cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); - cy.go( 'back' ); - } ); - - it( 'Verify presense of Ready to go to live? canvas', () => { - cy.get( '.nfd-px-4', { timeout: customCommandTimeout } ) - .as( 'readyToGoNextLevel' ) - .should( 'exist' ); - cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) - .find( '.nfd-flex-1 h1' ) - .should( 'exist' ); - cy.get( '@readyToGoNextLevel' ) - .find( '.nfd-flex-1 span' ) - .should( 'exist' ); - cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) - .find( '#view-site' ) - .should( 'exist' ) - cy.get( '@readyToGoNextLevel' ) - .find( '#launch-site' ) - .should( 'exist' ) - } ); - - it( 'Verify Visit your site and Launch your site functionality', () => { - cy.get( '.nfd-flex-none > .nfd-button--secondary', { - timeout: customCommandTimeout, - } ) - .invoke( 'removeAttr', 'target' ) - .click(); - cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); - cy.go( 'back' ); - cy.get( '.nfd-flex-none > .nfd-button--upsell' ).click(); - cy.get( '.nfd-notification--success' ).should( 'exist' ); - } ); -} ); - -describe( 'Commerce Home Page- Live Mode', () => { - before( () => { - cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { - failOnNonZeroExit: false, - } ); - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - comingSoon( false ); - } ); - - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - } ); - - it( 'Verify presense of Ready to go to next level? canvas', () => { - cy.get( '.nfd-flex.nfd-gap-4', { timeout: customCommandTimeout } ) - .eq( 2 ) - .as( 'readyToGoNextLevel' ) - .should( 'exist' ); - cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } ) - .find( 'h1' ) - .should( 'exist' ); - cy.get( '@readyToGoNextLevel' ).find( 'div span' ).should( 'exist' ); - } ); - - it( 'Verify by default View Site option should be displayed', () => { - cy.get( '.nfd-button--primary', { - timeout: customCommandTimeout, - } ) - .eq( 1 ) - .should( 'exist' ) - .invoke( 'removeAttr', 'target' ) - .click(); - cy.url().should( 'eq', Cypress.config().baseUrl + '/' ); - } ); -} ); - -describe( 'Commerce Home Page- Next Steps', () => { +describe( 'e-commerce Home Page- Next Steps', () => { const step_id = [ 'add-a-new-page-to-your-site', 'upload-media-to-your-site', @@ -145,6 +31,7 @@ describe( 'Commerce Home Page- Next Steps', () => { ]; before( () => { + wpLogin(); cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { failOnNonZeroExit: false, } ); @@ -202,6 +89,10 @@ describe( 'Commerce Home Page- Next Steps', () => { } ).click( { force: true } ); cy.get( '.navigation-buttons_next' ).click( { force: true } ); cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); + cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { + failOnNonZeroExit: false, + } ); + cy.wait( 2000 ); cy.reload(); cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) .as( 'nextSteps' ) diff --git a/tests/cypress/integration/Home/homePageWithWoo.cy.js b/tests/cypress/integration/Home/homePageWithWoo.cy.js index 04aa4d7b..b8058554 100644 --- a/tests/cypress/integration/Home/homePageWithWoo.cy.js +++ b/tests/cypress/integration/Home/homePageWithWoo.cy.js @@ -1,205 +1,211 @@ import { GetPluginId, getAppId } from '../wp-module-support/pluginID.cy'; import { - comingSoon, + wpLogin, installWoo, viewCompletedTasks, viewRemainingTasks, waitForNextSteps, + uninstallPlugins, } from '../wp-module-support/utils.cy'; const customCommandTimeout = 20000; const pluginId = GetPluginId(); const appId = getAppId(); -describe( 'Commerce Home Page- When WooCommerce is installed', () => { - before( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); - installWoo(); - comingSoon( true ); - } ); - - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - } ); - - after( () => { - cy.exec(`npx wp-env run cli wp plugin deactivate woocommerce`, { - failOnNonZeroExit: false, +describe( + 'e-commerce Home Page - When WooCommerce is installed', + { testIsolation: true }, + () => { + beforeEach( () => { + wpLogin(); + uninstallPlugins(); + installWoo(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); } ); - cy.visit('/wp-admin/admin.php?page=' + pluginId + '#/home'); - } ); - - it( 'Verify next steps "Add your store info"', () => { - waitForNextSteps(); - cy.get( '#add-your-store-info a', { - timeout: customCommandTimeout, - } ) - .as( 'storeInfoStep' ) - .should( 'exist' ) - .scrollIntoView() - .click(); - cy.get( `.${ appId }-app-subnavitem-Store.active` ).should( 'exist' ); - cy.get( 'h2' ).should( 'exist' ); - cy.get( '.nfd-border-t .nfd-button--primary' ).should( 'be.disabled' ); - - // Select country - cy.get( '[data-id="store-country-select"]' ).click(); - cy.contains( '.nfd-select__option', 'United States (US)' ).click(); - // Enter city - cy.get( '[name="woocommerce_store_address"]' ).type( - 'Sunflower Canal' - ); - cy.get( '[name="woocommerce_store_city"]' ).type( 'Safford' ); - // Select state - cy.get( '[data-id="state-select"]' ).click(); - cy.contains( '.nfd-select__option', 'Arizona' ).click(); - // Enter postcode - cy.get( '[name="woocommerce_store_postcode"]' ).type( '85546' ); - // Select Currency - cy.get( '[data-id="currency"]' ).click(); - cy.contains( - '.nfd-select__option', - 'United States (US) dollar ($)' - ).click(); - - cy.get( '.nfd-border-t .nfd-button--primary' ) - .should( 'not.be.disabled' ) - .click(); - - cy.get( '.nfd-notifications--bottom-left .nfd-notification--success', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '.nfd-w-0 p' ).should( 'exist' ); - - cy.get( `.${ appId }-app-navitem-Home` ).click(); - waitForNextSteps(); - cy.get( '@storeInfoStep', { timeout: customCommandTimeout } ).should( - 'not.exist' - ); - viewCompletedTasks(); - cy.get( '@storeInfoStep' ).should( 'exist' ); - viewRemainingTasks(); - } ); - - it( 'Verify next step "Connect a payment processor"', () => { - cy.reload(); - waitForNextSteps(); - cy.get( '#connect-a-payment-processor a', { - timeout: customCommandTimeout, - } ) - .as( 'paymentStep' ) - .should( 'exist' ) - .scrollIntoView() - .click(); - cy.get( `.${ appId }-app-subnavitem-Payments.active`, { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '#razorpay-section' ).as( 'razorpayBlock' ); - cy.get( '@razorpayBlock' ).find( '#install-razorpay' ).click(); - - cy.get( '[data-id="rzpTestModeToggle"]', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '[data-id="rzpTestModeToggle"]' ).click(); - cy.get( '[name="key_id"]' ).type( 'rzp_test_qn0AnShxeczQr4' ); - cy.get( '[name="key_secret"]' ).type( 'rzp_test_qn0AnShxeczQr4' ); - - cy.get( '.nfd-border-t .nfd-button--primary' ).click(); - - cy.get( '@razorpayBlock', { timeout: customCommandTimeout } ) - .find( '.nfd-badge--upsell', { timeout: customCommandTimeout } ) - .should( 'exist' ); - - cy.get( `.${ appId }-app-navitem-Home` ).click(); - waitForNextSteps(); - cy.get( '@paymentStep' ).should( 'not.exist' ); - viewCompletedTasks(); - cy.get( '@paymentStep' ).should( 'exist' ); - viewRemainingTasks(); - - // Delete razorpay settings from DB - cy.exec( - `npx wp-env run cli wp option delete nfd-ecommerce-captive-flow-razorpay` - ); - cy.exec( - `npx wp-env run cli wp option delete woocommerce_razorpay_settings` - ); - } ); - - it( ' Verify next step "Set up Shipping options" ', () => { - if ( pluginId == 'bluehost' ) { + + after( () => { + uninstallPlugins(); + } ); + + it( 'Verify next steps "Add your store info"', () => { + waitForNextSteps(); + cy.get( '#add-your-store-info a', { + timeout: customCommandTimeout, + } ) + .as( 'storeInfoStep' ) + .should( 'exist' ) + .scrollIntoView() + .click(); + cy.get( `.${ appId }-app-subnavitem-Store.active` ).should( + 'exist' + ); + cy.get( 'h2' ).should( 'exist' ); + cy.get( '.nfd-border-t .nfd-button--primary' ).should( + 'be.disabled' + ); + + // Select country + cy.get( '[data-id="store-country-select"]' ).click(); + cy.contains( '.nfd-select__option', 'United States (US)' ).click(); + // Enter city + cy.get( '[name="woocommerce_store_address"]' ).type( + 'Sunflower Canal' + ); + cy.get( '[name="woocommerce_store_city"]' ).type( 'Safford' ); + // Select state + cy.get( '[data-id="state-select"]' ).click(); + cy.contains( '.nfd-select__option', 'Arizona' ).click(); + // Enter postcode + cy.get( '[name="woocommerce_store_postcode"]' ).type( '85546' ); + // Select Currency + cy.get( '[data-id="currency"]' ).click(); + cy.contains( + '.nfd-select__option', + 'United States (US) dollar ($)' + ).click(); + + cy.get( '.nfd-border-t .nfd-button--primary' ) + .should( 'not.be.disabled' ) + .click(); + + cy.get( + '.nfd-notifications--bottom-left .nfd-notification--success', + { + timeout: customCommandTimeout, + } + ).should( 'exist' ); + cy.get( '.nfd-w-0 p' ).should( 'exist' ); + + cy.get( `.${ appId }-app-navitem-Home` ).click(); waitForNextSteps(); - cy.get( '#setup-shipping-options a', { + cy.get( '@storeInfoStep', { + timeout: customCommandTimeout, + } ).should( 'not.exist' ); + viewCompletedTasks(); + cy.get( '@storeInfoStep' ).should( 'exist' ); + viewRemainingTasks(); + } ); + + it( 'Verify next step "Connect a payment processor"', () => { + cy.reload(); + waitForNextSteps(); + cy.get( '#connect-a-payment-processor a', { timeout: customCommandTimeout, } ) .as( 'paymentStep' ) .should( 'exist' ) .scrollIntoView() .click(); + cy.get( `.${ appId }-app-subnavitem-Payments.active`, { + timeout: customCommandTimeout, + } ).should( 'exist' ); + cy.get( '#razorpay-section' ).as( 'razorpayBlock' ); + cy.get( '@razorpayBlock' ).find( '#install-razorpay' ).click(); - cy.get( '#install-shippo', { + cy.get( '[data-id="rzpTestModeToggle"]', { timeout: customCommandTimeout, - } ).click(); - cy.get( '#installing-shippo' ).should( 'not.exist' ); + } ).should( 'exist' ); + cy.get( '[data-id="rzpTestModeToggle"]' ).click(); + cy.get( '[name="key_id"]' ).type( 'rzp_test_qn0AnShxeczQr4' ); + cy.get( '[name="key_secret"]' ).type( 'rzp_test_qn0AnShxeczQr4' ); + + cy.get( '.nfd-border-t .nfd-button--primary' ).click(); - cy.window().then( ( win ) => { - cy.spy( win, 'open', ( url ) => { - win.location.href = - 'https://goshippo.com/oauth/register?next=/oauth/authorize'; - } ).as( 'windowOpen' ); - } ); + cy.get( '@razorpayBlock', { timeout: customCommandTimeout } ) + .find( '.nfd-badge--upsell', { timeout: customCommandTimeout } ) + .should( 'exist' ); - cy.get( '#connect-to-shippo-btn', { + cy.get( `.${ appId }-app-navitem-Home` ).click(); + waitForNextSteps(); + cy.get( '@paymentStep' ).should( 'not.exist' ); + viewCompletedTasks(); + cy.get( '@paymentStep' ).should( 'exist' ); + viewRemainingTasks(); + + // Delete razorpay settings from DB + cy.exec( + `npx wp-env run cli wp option delete nfd-ecommerce-captive-flow-razorpay woocommerce_razorpay_settings` + ); + } ); + + it( 'Verify next step "Set up Shipping options"', () => { + if ( pluginId == 'bluehost' ) { + waitForNextSteps(); + cy.get( '#setup-shipping-options a', { + timeout: customCommandTimeout, + } ) + .as( 'paymentStep' ) + .should( 'exist' ) + .scrollIntoView() + .click(); + + cy.get( '#install-shippo', { + timeout: customCommandTimeout, + } ).click(); + cy.get( '#installing-shippo' ).should( 'not.exist' ); + + cy.window().then( ( win ) => { + cy.spy( win, 'open', ( url ) => { + win.location.href = + 'https://goshippo.com/oauth/register?next=/oauth/authorize'; + } ).as( 'windowOpen' ); + } ); + + cy.get( '#connect-to-shippo-btn', { + timeout: customCommandTimeout, + } ).click(); + cy.get( '@windowOpen', { + timeout: customCommandTimeout, + } ).should( 'be.called' ); + } + } ); + + it( 'Verify next step "Configure tax settings"', () => { + waitForNextSteps(); + cy.get( '#configure-tax-settings a', { timeout: customCommandTimeout, - } ).click(); - cy.get( '@windowOpen', { timeout: customCommandTimeout } ).should( - 'be.called' + } ) + .as( 'taxStep' ) + .should( 'exist' ) + .scrollIntoView() + .click(); + cy.get( `.${ appId }-app-subnavitem-Store.active`, { + timeout: customCommandTimeout, + } ).should( 'exist' ); + cy.get( '#tax-yes' ).click(); + cy.get( '.nfd-border-t .nfd-button--primary' ).click(); + + cy.get( + '.nfd-notifications--bottom-left .nfd-notification--success', + { + timeout: customCommandTimeout, + } + ).should( 'exist' ); + cy.get( '.nfd-w-0 p' ).should( 'exist' ); + + cy.get( `.${ appId }-app-navitem-Home` ).click(); + cy.reload(); + waitForNextSteps(); + cy.get( '@taxStep', { timeout: 30000 } ).should( 'not.exist' ); + viewCompletedTasks(); + cy.get( '@taxStep' ).should( 'exist' ); + viewRemainingTasks(); + } ); + + it( 'Verify next step "Add a Product"', () => { + waitForNextSteps(); + cy.get( '#add-a-product a', { + timeout: customCommandTimeout, + } ) + .as( 'addProduct' ) + .should( 'exist' ) + .click(); + cy.url().should( + 'eq', + Cypress.config().baseUrl + + '/wp-admin/post-new.php?post_type=product&return_to_nfd=%2Fhome' ); - } - } ); - - it( 'Verify next step "Configure tax settings"', () => { - waitForNextSteps(); - cy.get( '#configure-tax-settings a', { - timeout: customCommandTimeout, - } ) - .as( 'taxStep' ) - .should( 'exist' ) - .scrollIntoView() - .click(); - cy.get( `.${ appId }-app-subnavitem-Store.active`, { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '#tax-yes' ).click(); - cy.get( '.nfd-border-t .nfd-button--primary' ).click(); - - cy.get( '.nfd-notifications--bottom-left .nfd-notification--success', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '.nfd-w-0 p' ).should( 'exist' ); - - cy.get( `.${ appId }-app-navitem-Home` ).click(); - cy.reload(); - waitForNextSteps(); - cy.get( '@taxStep', { timeout: 30000 } ).should( 'not.exist' ); - viewCompletedTasks(); - cy.get( '@taxStep' ).should( 'exist' ); - viewRemainingTasks(); - } ); - - it( 'Verify next step "Add a Product"', () => { - waitForNextSteps(); - cy.get( '#add-a-product a', { - timeout: customCommandTimeout, - } ) - .as( 'addProduct' ) - .should( 'exist' ) - .click(); - cy.url().should( - 'eq', - Cypress.config().baseUrl + - '/wp-admin/post-new.php?post_type=product&return_to_nfd=%2Fhome' - ); - cy.go( 'back' ); - } ); -} ); + cy.go( 'back' ); + } ); + } +); diff --git a/tests/cypress/integration/Home/migration.cy.js b/tests/cypress/integration/Home/migration.cy.js index b247d9a6..0815877f 100644 --- a/tests/cypress/integration/Home/migration.cy.js +++ b/tests/cypress/integration/Home/migration.cy.js @@ -1,6 +1,6 @@ import { GetPluginId } from '../wp-module-support/pluginID.cy'; import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy'; - +import { wpLogin } from '../wp-module-support/utils.cy'; const customCommandTimeout = 20000; const pluginId = GetPluginId(); const helpCenter = JSON.stringify( { @@ -8,63 +8,74 @@ const helpCenter = JSON.stringify( { canAccessHelpCenter: true, } ); -describe( 'Home page - post migration events with help center ', () => { - before( function () { - if ( pluginId !== 'bluehost' ) { - this.skip(); - } - cy.exec( `npx wp-env run cli wp option set showMigrationSteps "true"` ); - cy.exec( - `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, - { failOnNonZeroExit: false } - ); - cy.exec( - `npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ helpCenter }' --format=json`, - { timeout: customCommandTimeout } - ); - cy.reload(); - } ); - - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - } ); +describe( + 'Home page - post migration events with help center ', + { testIsolation: true }, + () => { + beforeEach( function () { + wpLogin(); + + if ( pluginId !== 'bluehost' ) { + this.skip(); + } + cy.exec( + `npx wp-env run cli wp option set nfd_show_migration_steps "true"` + ); + cy.exec( + `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, + { failOnNonZeroExit: false } + ); + cy.exec( + `npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ helpCenter }' --format=json`, + { timeout: customCommandTimeout } + ); + cy.reload(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); + } ); - it( 'Verify when update nameserver clicked', () => { - cy.get( '.nfd-grid.nfd-gap-4', { timeout: customCommandTimeout } ) - .scrollIntoView() - .should( 'exist' ); - cy.intercept( APIList.update_nameserver ).as( 'events' ); - cy.get( '.nfd-grid.nfd-gap-4 ul li a' ).eq( 0 ).click(); - EventsAPI( APIList.update_nameserver, pluginId ); - cy.get( '.nfd-help-center', { timeout: 30000 } ).should( - 'be.visible' - ); - cy.get( '.close-button' ).click(); - } ); + it( 'Verify when update nameserver clicked', () => { + cy.intercept( APIList.update_nameserver ).as( 'events' ); + cy.get( '#onboarding-list [data-testid="nameservers"]', { + timeout: customCommandTimeout, + } ) + .scrollIntoView() + .should( 'exist' ) + .click(); + EventsAPI( APIList.update_nameserver, pluginId ); + cy.get( '.nfd-help-center', { + timeout: customCommandTimeout, + } ).should( 'be.visible' ); + cy.get( '.close-button' ).click(); + } ); - it( 'Verify when connect domain to site clicked', () => { - cy.get( '.nfd-grid.nfd-gap-4', { timeout: customCommandTimeout } ) - .scrollIntoView() - .should( 'exist' ); - cy.intercept( APIList.connect_domain ).as( 'events' ); - cy.get( '.nfd-grid.nfd-gap-4 ul li a' ).eq( 1 ).click(); - EventsAPI( APIList.connect_domain, pluginId ); - cy.get( '.nfd-help-center', { timeout: 30000 } ).should( - 'be.visible' - ); - cy.get( '.close-button' ).click(); - } ); + it( 'Verify when connect domain to site clicked', () => { + cy.intercept( APIList.connect_domain ).as( 'events' ); + cy.get( '#onboarding-list [data-testid="domain"]', { + timeout: customCommandTimeout, + } ) + .scrollIntoView() + .should( 'exist' ) + .click(); + EventsAPI( APIList.connect_domain, pluginId ); + cy.get( '.nfd-help-center', { + timeout: customCommandTimeout, + } ).should( 'be.visible' ); + cy.get( '.close-button' ).click(); + } ); - it( 'Verify when continue with store setup clicked', () => { - cy.get( '.nfd-grid.nfd-gap-4', { timeout: customCommandTimeout } ) - .scrollIntoView() - .should( 'exist' ); - cy.get( '.nfd-grid.nfd-gap-4 ul li a' ).eq( 2 ).click(); - cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) - .scrollIntoView() - .should( 'exist' ); - cy.get( '#upload-media-to-your-site', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - } ); -} ); + it( 'Verify when continue with store setup clicked', () => { + cy.get( '#onboarding-list [data-testid="continue"]', { + timeout: customCommandTimeout, + } ) + .scrollIntoView() + .should( 'exist' ) + .click(); + cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) + .scrollIntoView() + .should( 'exist' ); + cy.get( '#upload-media-to-your-site', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + } ); + } +); diff --git a/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js b/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js index 28babddf..a29e4010 100644 --- a/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js +++ b/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js @@ -1,149 +1,119 @@ import { GetPluginId, getAppId } from '../wp-module-support/pluginID.cy'; -import { installWoo } from '../wp-module-support/utils.cy'; +import { + wpLogin, + uninstallPlugins, + installWoo, +} from '../wp-module-support/utils.cy'; const customCommandTimeout = 60000; const mediumWait = 30000; const pluginId = GetPluginId(); const appId = getAppId(); -describe( 'Verify Wondercart accessibility as per site capabilities', () => { - const cTBAndYithTrue = JSON.stringify( { - canAccessAI: true, - canAccessHelpCenter: true, - canAccessGlobalCTB: true, - hasEcomdash: false, - hasYithExtended: true, - isEcommerce: true, - isJarvis: true, - } ); +describe( + 'Verify Wondercart follows site capabilities', + { testIsolation: true }, + () => { + const CTBAndYithTrue = JSON.stringify( { + canAccessAI: true, + canAccessHelpCenter: true, + canAccessGlobalCTB: true, + hasEcomdash: false, + hasYithExtended: true, + isEcommerce: true, + isJarvis: true, + } ); - const cTBTrueYithFalse = JSON.stringify( { - canAccessAI: true, - canAccessHelpCenter: true, - canAccessGlobalCTB: true, - hasEcomdash: false, - hasYithExtended: false, - isEcommerce: false, - isJarvis: true, - } ); + const CTBTrueYithFalse = JSON.stringify( { + canAccessAI: true, + canAccessHelpCenter: true, + canAccessGlobalCTB: true, + hasEcomdash: false, + hasYithExtended: false, + isEcommerce: false, + isJarvis: true, + } ); - before( function () { - if ( pluginId !== 'bluehost' ) { - this.skip(); - } - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); - installWoo(); - } ); + before( function () { + if ( pluginId !== 'bluehost' ) { + this.skip(); + } + } ); - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - } ); + beforeEach( () => { + wpLogin(); + uninstallPlugins(); + installWoo(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId ); + } ); - after( () => { - cy.exec( - `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, - { failOnNonZeroExit: false } - ); - } ); - - it( 'Verify if Sales and Discounts sub tab is displayed', () => { - cy.exec( - `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, - { failOnNonZeroExit: false } - ); - cy.exec( - `npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBAndYithTrue }' --format=json`, - { timeout: customCommandTimeout } - ); - cy.reload(); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: mediumWait, - } ).click(); - cy.get( `.${ appId }-app-subnavitem-Sales` ).should( 'exist' ); - } ); - - it( 'Verify Buy Now is shown when canAccessGlobalCTB is true and commerce addon is false', () => { - cy.exec( - `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, - { failOnNonZeroExit: false } - ); - cy.exec( - `npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBTrueYithFalse }' --format=json`, - { timeout: customCommandTimeout } - ); - cy.reload(); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ).click(); - cy.get( `.${ appId }-app-subnavitem-Sales` ) - .as( 'salesTab' ) - .should( 'exist' ); - cy.get( '@salesTab' ).click(); - cy.get( '#buynow-wondercart', { timeout: mediumWait } ).should( - 'exist' - ); - } ); + it( 'Verify Buy Now is shown when canAccessGlobalCTB is true and commerce addon is false', () => { + // Buy now button is displayed when capabilities are false. + cy.log( 'Update capabilities transient: CTBTrueYithFalse' ); + cy.exec( + `npx wp-env run cli wp option update _transient_nfd_site_capabilities '${ CTBTrueYithFalse }' --format=json`, + { timeout: customCommandTimeout } + ); + cy.reload(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); - it( 'Verify clicking on Buy Now leads to cpanel login page', () => { - cy.reload(); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ).click(); - cy.get( `.${ appId }-app-subnavitem-Sales` ).click(); - cy.get( '#buynow-wondercart', { timeout: mediumWait } ).as( - 'buyButton' - ); + cy.get( `.${ appId }-app-subnavitem-Sales` ) + .as( 'salesTab' ) + .should( 'exist' ); + cy.get( '@salesTab' ).click(); + cy.get( '#buynow-wondercart', { timeout: mediumWait } ).as( + 'buyButton' + ); + cy.get( '@buyButton' ).scrollIntoView().should( 'be.visible' ); + // Verify Buy now button has correct link + cy.get( '@buyButton' ) + .should( 'have.attr', 'href' ) + .and( + 'include', + 'https://my.bluehost.com/hosting/app?utm_source=wp-marketplace&utm_medium=brand-plugin&utm_campaign=wordpress-ad&utm_content=buynow#/marketplace/product' + ); + } ); - cy.get( '@buyButton' ).should( 'be.visible' ); - cy.get( '@buyButton' ) - .should( 'have.attr', 'href' ) - .and( - 'include', - 'https://my.bluehost.com/hosting/app?utm_source=wp-marketplace&utm_medium=brand-plugin&utm_campaign=wordpress-ad&utm_content=buynow#/marketplace/product' + it( 'Verify Sales and Discounts sub tab content and functionality', () => { + // Install button is displayed when capabilities are true + cy.log( 'Update capabilities transient: CTBAndYithTrue' ); + cy.exec( + `npx wp-env run cli wp option update _transient_nfd_site_capabilities '${ CTBAndYithTrue }' --format=json`, + { timeout: customCommandTimeout } ); - } ); + cy.reload(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); - it( 'Verify Install Now is shown when customer has ecommerce addon', () => { - cy.exec( - `npx wp-env run cli wp option delete _transient_nfd_site_capabilities`, - { failOnNonZeroExit: false } - ); - cy.exec( - `npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBAndYithTrue }' --format=json`, - { timeout: customCommandTimeout } - ); - cy.reload(); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ).click(); - cy.get( `.${ appId }-app-subnavitem-Sales`, { timeout: mediumWait } ) - .as( 'salesTab' ) - .should( 'exist' ); - cy.get( '@salesTab' ).click(); - cy.get( '#installnow-wondercart', { timeout: mediumWait } ).should( - 'exist' - ); - } ); + // Verify Install Now exists when customer has ecommerce addon + cy.get( `.${ appId }-app-subnavitem-Sales`, { + timeout: mediumWait, + } ) + .as( 'salesTab' ) + .should( 'exist' ); + cy.get( '@salesTab' ).click(); + cy.get( '#installnow-wondercart', { timeout: mediumWait } ).should( + 'exist' + ); - it.skip( 'Verify clicking Install Now successfully installs Wonder Cart plugin', () => { - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ).click(); - cy.get( `.${ appId }-app-subnavitem-Sales` ).click(); - cy.get( '#installnow-wondercart', { timeout: mediumWait } ) - .scrollIntoView() - .click(); - cy.get( '.nfd-notification--success', { - timeout: customCommandTimeout, - }).should('exist'); - cy.get( `.${ appId }-app-site-info`, { - timeout: customCommandTimeout, - } ).should( 'exist' ); - cy.get( '#wonder-cart-init', { timeout: customCommandTimeout } ).should( - 'exist' - ); - } ); -} ); + // Verify clicking Install Now successfully installs Wonder Cart plugin + cy.get( '#installnow-wondercart', { timeout: mediumWait } ) + .scrollIntoView() + .click(); + cy.get( '.nfd-notification--success', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + cy.reload(); + // display installed plugins for debugging + cy.exec( `npx wp-env run cli wp plugin list`, { + failOnNonZeroExit: false, + } ).then( ( result ) => { + cy.log( result.stdout ); + expect( result.stdout ).to.contains( 'wonder-cart' ); + } ); + // Verify wonder cart content displays + cy.get( '#wonder-cart-init', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + } ); + } +); diff --git a/tests/cypress/integration/Store/storePage.cy.js b/tests/cypress/integration/Store/storePage.cy.js index be1c35b0..b07c0df2 100644 --- a/tests/cypress/integration/Store/storePage.cy.js +++ b/tests/cypress/integration/Store/storePage.cy.js @@ -1,63 +1,46 @@ import { GetPluginId, getAppId } from '../wp-module-support/pluginID.cy'; -import { comingSoon } from '../wp-module-support/utils.cy'; +import { wpLogin, uninstallPlugins } from '../wp-module-support/utils.cy'; const pluginId = GetPluginId(); const appId = getAppId(); const customCommandTimeout = 30000; -const longWait = 60000; -describe( 'Store Page- WooCommerce is deactivated/uninstalled', () => { - before( () => { - cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { - failOnNonZeroExit: false, +describe( + 'Store Page - WooCommerce is deactivated/uninstalled', + { testIsolation: true }, + () => { + before( () => { + wpLogin(); + uninstallPlugins(); + cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); } ); - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' ); - cy.get( `.${ appId }-app-site-info`, { timeout: longWait } ).should( - 'exist' - ); - comingSoon( false ); - } ); - beforeEach( () => { - cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/store' ); - } ); + it( 'Verify Store Page renders properly without Woo', () => { + cy.reload(); + // Payments tab is not displayed + cy.get( `.${ appId }-app-subnavitem-Payments` ).should( + 'not.exist' + ); - it( 'Verify that Payments tab is not displayed', () => { - cy.reload(); - cy.get( `.${ appId }-app-navitem-Store`, { - timeout: customCommandTimeout, - } ) - .next() - .find( '.nfd-m-0' ) - .each( ( item, index, list ) => { - expect( list ).to.have.length( 2 ); - } ); - cy.get( `.${ appId }-app-subnavitem-Products` ).should( 'exist' ); - cy.get( `.${ appId }-app-subnavitem-Store` ).should( 'exist' ); - cy.get( `.${ appId }-app-subnavitem-Payments` ).should( 'not.exist' ); - } ); - - it( 'Verify Store page title and sub titles', () => { - cy.get( '.nfd-app-section-header h2' ).should( 'exist' ); - cy.get( '.nfd-app-section-header' ) - .next() - .as( 'storeFlex' ) - .should( 'exist' ); - cy.get( '@storeFlex' ).find( 'span' ).should( 'exist' ); - } ); + // Title and description elements display + cy.get( '[data-testid="nfd-nowoo-store-title"]' ).should( 'exist' ); + cy.get( '[data-testid="nfd-nowoo-store-description"]' ).should( + 'exist' + ); - it( 'Verify Store and its sub tabs should have Install WooCommerce buttons', () => { - const storeNavElements = [ - `.${ appId }-app-navitem-Store`, - `.${ appId }-app-subnavitem-Products`, - `.${ appId }-app-subnavitem-Store`, - ]; + // Verify Store and its sub tabs should have Install WooCommerce buttons + const storeNavElements = [ + `.${ appId }-app-navitem-Store`, + `.${ appId }-app-subnavitem-Products`, + `.${ appId }-app-subnavitem-Store`, + ]; - storeNavElements.forEach( ( ele ) => { - cy.get( ele, { timeout: customCommandTimeout } ).click(); - cy.get( '.nfd-button--upsell', { - timeout: customCommandTimeout, - } ).should( 'exist' ); + storeNavElements.forEach( ( ele ) => { + cy.get( ele, { timeout: customCommandTimeout } ).click(); + cy.get( '.nfd-button--upsell', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + } ); } ); - } ); -} ); + } +); diff --git a/tests/cypress/integration/wp-module-support/utils.cy.js b/tests/cypress/integration/wp-module-support/utils.cy.js index bbf3c9fe..64bad108 100644 --- a/tests/cypress/integration/wp-module-support/utils.cy.js +++ b/tests/cypress/integration/wp-module-support/utils.cy.js @@ -5,10 +5,9 @@ const customCommandTimeout = 30000; const longWait = 120000; export const comingSoon = ( shouldBeComingSoon ) => { - cy.get( `.${ appId }-app-navitem-Settings`, { - timeout: customCommandTimeout, - } ).click(); - + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/settings' + ); cy.get( '[data-id="coming-soon-toggle"]', { timeout: customCommandTimeout, } ).as( 'comingSoonToggle' ); @@ -16,8 +15,9 @@ export const comingSoon = ( shouldBeComingSoon ) => { if ( shouldBeComingSoon ) { cy.get( '@comingSoonToggle' ) .invoke( 'attr', 'aria-checked' ) - .then( ( area_checked ) => { - if ( area_checked == 'false' ) { + .then( ( aria_checked ) => { + if ( aria_checked == 'false' ) { + cy.log( 'Enable Coming Soon Mode' ); cy.get( '@comingSoonToggle' ).click(); cy.get( '.nfd-notification--success', { timeout: customCommandTimeout, @@ -27,8 +27,9 @@ export const comingSoon = ( shouldBeComingSoon ) => { } else { cy.get( '@comingSoonToggle' ) .invoke( 'attr', 'aria-checked' ) - .then( ( area_checked ) => { - if ( area_checked == 'true' ) { + .then( ( aria_checked ) => { + if ( aria_checked == 'true' ) { + cy.log( 'Disable Coming Soon Mode' ); cy.get( '@comingSoonToggle' ).click(); cy.get( '.nfd-notification--success', { timeout: customCommandTimeout, @@ -39,14 +40,18 @@ export const comingSoon = ( shouldBeComingSoon ) => { }; export const installWoo = () => { - cy.exec( `npx wp-env run cli wp plugin install woocommerce`, { + cy.log( 'Installing WooCommerce' ); + cy.exec( `npx wp-env run cli wp plugin install woocommerce --activate`, { timeout: longWait, log: true, } ); +}; - cy.exec( `npx wp-env run cli wp plugin activate woocommerce`, { - timeout: longWait, - } ); +export const uninstallPlugins = () => { + cy.log( 'Uninstalling plugins' ); + cy.exec( + 'npx wp-env run cli wp plugin uninstall --all --deactivate --exclude=bluehost-wordpress-plugin,wp-plugin-hostgator,wp-plugin-crazy-domains,wp-plugin-web,wp-plugin-mojo' + ); }; export const viewCompletedTasks = () => { @@ -71,3 +76,14 @@ export const waitForNextSteps = () => { .scrollIntoView() .should( 'exist' ); }; + +export const deleteCapabilitiesTransient = () => { + cy.log( 'Deleting capabilities transient' ); + cy.exec( `npx wp-env run cli wp transient delete nfd_site_capabilities`, { + failOnNonZeroExit: false, + } ); +}; + +export const wpLogin = () => { + cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) ); +}; diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 9b955d7b..db5ebf91 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -28,63 +28,57 @@ import '@testing-library/cypress/add-commands'; -Cypress.Commands.add('login', (username, password) => { - cy - .getCookies() - .then(cookies => { - let hasMatch = false; - cookies.forEach((cookie) => { - if (cookie.name.substring(0, 20) === 'wordpress_logged_in_') { - hasMatch = true; - } - }); - if (!hasMatch) { - cy.visit('/wp-login.php').wait(1000); - cy.get('#user_login').type(username); - cy.get('#user_pass').type(`${password}{enter}`); +Cypress.Commands.add( 'login', ( username, password ) => { + cy.getCookies().then( ( cookies ) => { + let hasMatch = false; + cookies.forEach( ( cookie ) => { + if ( cookie.name.substring( 0, 20 ) === 'wordpress_logged_in_' ) { + hasMatch = true; } - }); -}); + } ); + if ( ! hasMatch ) { + cy.visit( '/wp-login.php' ).wait( 1000 ); + cy.get( '#user_login' ).type( username ); + cy.get( '#user_pass' ).type( `${ password }{enter}` ); + } + } ); +} ); -Cypress.Commands.add('logout', () => { - cy - .getCookies() - .then( - cookies => { - cookies.forEach( - cookie => { - cy.clearCookie(cookie.name); - } - ) - } - ); - }); +Cypress.Commands.add( 'logout', () => { + cy.getCookies().then( ( cookies ) => { + cookies.forEach( ( cookie ) => { + cy.clearCookie( cookie.name ); + } ); + } ); +} ); - /** -* @param {string} pluginName - The string -* Use deactivatePlugin('anyPluginName') from test to deactivate plugin -*/ - Cypress.Commands.add('deactivatePlugin', (pluginName) => { - if (pluginName.toLowerCase() === 'all') { - cy.exec('npx wp-env run cli wp plugin deactivate --all'); - } else { - cy.exec(`npx wp-env run cli wp plugin deactivate ${pluginName}`); - } - }); +/** + * Use deactivatePlugin('anyPluginName') from test to deactivate plugin + * + * @param {string} pluginName - The string + */ +Cypress.Commands.add( 'deactivatePlugin', ( pluginName ) => { + if ( pluginName.toLowerCase() === 'all' ) { + cy.exec( 'npx wp-env run cli wp plugin deactivate --all' ); + } else { + cy.exec( `npx wp-env run cli wp plugin deactivate ${ pluginName }` ); + } +} ); - /** - * @param {string} pluginName - The string - * Use activatePlugin('All') from test to activate all plugins - * Use activatePlugin('anyPluginName') from test to activate plugin - */ - Cypress.Commands.add('activatePlugin', (pluginName) => { - if (pluginName.toLowerCase() !== 'all') { - cy.exec(`npx wp-env run cli wp plugin activate ${pluginName}`, { - failOnNonZeroExit: false, - }); - } else { - cy.exec('npx wp-env run cli wp plugin activate --all', { - failOnNonZeroExit: false, - }); - } - }); +/** + * Use activatePlugin('All') from test to activate all plugins + * Use activatePlugin('anyPluginName') from test to activate plugin + * + * @param {string} pluginName - The string + */ +Cypress.Commands.add( 'activatePlugin', ( pluginName ) => { + if ( pluginName.toLowerCase() !== 'all' ) { + cy.exec( `npx wp-env run cli wp plugin activate ${ pluginName }`, { + failOnNonZeroExit: false, + } ); + } else { + cy.exec( 'npx wp-env run cli wp plugin activate --all', { + failOnNonZeroExit: false, + } ); + } +} ); diff --git a/tests/cypress/support/index.js b/tests/cypress/support/index.js index 369d8872..bd36195e 100644 --- a/tests/cypress/support/index.js +++ b/tests/cypress/support/index.js @@ -15,16 +15,12 @@ import 'cypress-axe'; import './commands'; -require('@replayio/cypress/support'); +require( '@replayio/cypress/support' ); -const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/ -Cypress.on('uncaught:exception', (err) => { +const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/; +Cypress.on( 'uncaught:exception', ( err ) => { /* returning false here prevents Cypress from failing the test */ - if (resizeObserverLoopErrRe.test(err.message)) { - return false + if ( resizeObserverLoopErrRe.test( err.message ) ) { + return false; } -}) - -before(() => { - cy.login(Cypress.env('wpUsername'), Cypress.env('wpPassword')); -}); +} );