diff --git a/tests/cypress/integration/Home/commerceHomePage.cy.js b/tests/cypress/integration/Home/commerceHomePage.cy.js index 8a4c46bb..e1b91ff4 100644 --- a/tests/cypress/integration/Home/commerceHomePage.cy.js +++ b/tests/cypress/integration/Home/commerceHomePage.cy.js @@ -2,7 +2,7 @@ import { GetPluginId } from '../wp-module-support/pluginID.cy'; import { comingSoon, viewCompletedTasks, - viewRemainingTasks, + viewRemainingTasks } from '../wp-module-support/utils.cy'; import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy'; @@ -116,9 +116,10 @@ describe( 'Commerce Home Page- Live Mode', () => { } ); it( 'Verify by default View Site option should be displayed', () => { - cy.contains( '.nfd-button--primary', 'View Site', { + cy.get( '.nfd-button--primary', { timeout: customCommandTimeout, } ) + .eq( 1 ) .should( 'exist' ) .invoke( 'removeAttr', 'target' ) .click(); @@ -127,15 +128,35 @@ describe( 'Commerce Home Page- Live Mode', () => { } ); describe( 'Commerce Home Page- Next Steps', () => { + const step_id = [ + 'add-a-new-page-to-your-site', + 'upload-media-to-your-site', + 'enable-jetpack-to-connect-to-your-social-media-accounts', + ]; + + const novice_step_id = [ + 'sign-up-for-yoast-seo-academy', + 'add-a-new-page-to-your-site', + 'upload-media-to-your-site', + 'enable-jetpack-to-connect-to-your-social-media-accounts', + ]; + + const novice_step_id_bh = [ + 'sign-up-for-bluehost-wordpress-academy', + ...novice_step_id, + ]; + before( () => { cy.exec( `npx wp-env run cli wp plugin deactivate woocommerce`, { failOnNonZeroExit: false, } ); - cy.exec(`npx wp-env run cli wp option set mm_brand ${ pluginId }`); + cy.exec( `npx wp-env run cli wp option set mm_brand ${ pluginId }` ); if ( pluginId == 'hostgator' ) { - cy.exec(`npx wp-env run cli wp option set hg_region ${ hg_region }`); + cy.exec( + `npx wp-env run cli wp option set hg_region ${ hg_region }` + ); } } ); @@ -157,38 +178,24 @@ describe( 'Commerce Home Page- Next Steps', () => { } ); it( 'Verify Next steps for your site when woocommerce is not active', () => { - const steps = [ - 'Add a new page to your site', - 'Upload media to your site', - 'Enable Jetpack to connect to your social media accounts', - ]; - cy.get( '.nfd-grid.nfd-gap-4', { timeout: customCommandTimeout } ) + cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) .as( 'nextSteps' ) .should( 'exist' ); cy.get( '@nextSteps' ).find( 'h1' ).should( 'exist' ); cy.get( '@nextSteps' ).find( 'p' ).should( 'exist' ); cy.get( '@nextSteps' ) .find( 'ul li' ) - .each( ( item, index, list ) => { + .each( ( ele, index, list ) => { expect( list ).to.have.length( 3 ); - - expect( Cypress.$( item ).text() ).to.eq( steps[ index ] ); + cy.get( ele ) + .invoke( 'attr', 'id' ) + .then( ( domId ) => { + expect( domId ).to.eq( step_id[ index ] ); + } ); } ); } ); it( 'Verify Next steps when experience level is novice', () => { - const other_steps = [ - 'Sign up for Yoast SEO Academy', - 'Add a new page to your site', - 'Upload media to your site', - 'Enable Jetpack to connect to your social media accounts', - ]; - - const steps = [ - 'Sign up for Bluehost WordPress Academy', - ...other_steps, - ]; - cy.visit( '/wp-admin/index.php?page=nfd-onboarding#/wp-setup/step/get-started/experience' ); @@ -201,22 +208,28 @@ describe( 'Commerce Home Page- Next Steps', () => { failOnNonZeroExit: false, } ); cy.wait( 2000 ); - cy.get( '.nfd-grid.nfd-gap-4', { timeout: customCommandTimeout } ) + cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) .as( 'nextSteps' ) .should( 'exist' ) .scrollIntoView(); cy.get( '@nextSteps' ) .find( 'ul li' ) - .each( ( item, index, list ) => { + .each( ( ele, index, list ) => { if ( pluginId == 'bluehost' ) { expect( list ).to.have.length( 5 ); - expect( Cypress.$( item ).text() ).to.eq( steps[ index ] ); + cy.get( ele ) + .invoke( 'attr', 'id' ) + .then( ( domId ) => { + expect( domId ).to.eq( novice_step_id_bh[ index ] ); + } ); } else { expect( list ).to.have.length( 4 ); - expect( Cypress.$( item ).text() ).to.eq( - other_steps[ index ] - ); + cy.get( ele ) + .invoke( 'attr', 'id' ) + .then( ( domId ) => { + expect( domId ).to.eq( novice_step_id[ index ] ); + } ); } } ); } ); @@ -224,11 +237,9 @@ describe( 'Commerce Home Page- Next Steps', () => { it( 'Verify Signup for Bluehost WordPress Academy step', () => { if ( pluginId == 'bluehost' ) { cy.intercept( APIList.bh_academy ).as( 'events' ); - cy.contains( - '.nfd-grid.nfd-gap-4 ul li a', - 'Sign up for Bluehost WordPress Academy', - { timeout: customCommandTimeout } - ) + cy.get( `#${ novice_step_id_bh[ 0 ] } a`, { + timeout: customCommandTimeout, + } ) .as( 'nextSteps' ) .should( 'exist' ) .scrollIntoView() @@ -250,11 +261,9 @@ describe( 'Commerce Home Page- Next Steps', () => { it( 'Verify Signup for Wordpress SEO Academy step', () => { cy.intercept( APIList.yoast_seo_academy ).as( 'events' ); - cy.contains( - '.nfd-grid.nfd-gap-4 ul li a', - 'Sign up for Yoast SEO Academy', - { timeout: customCommandTimeout } - ) + cy.get( `#${ novice_step_id_bh[ 1 ] } a`, { + timeout: customCommandTimeout, + } ) .as( 'nextSteps' ) .should( 'exist' ) .scrollIntoView() @@ -276,7 +285,7 @@ describe( 'Commerce Home Page- Next Steps', () => { cy.get( '@nextSteps' ).should( 'not.exist' ); viewCompletedTasks(); - cy.get('@nextSteps').should('exist'); + cy.get( '@nextSteps' ).should( 'exist' ); viewRemainingTasks(); } ); @@ -284,13 +293,9 @@ describe( 'Commerce Home Page- Next Steps', () => { cy.get( '.nfd-grid.nfd-gap-4 ul li', { timeout: customCommandTimeout, } ); - cy.contains( - '.nfd-grid.nfd-gap-4 ul li a', - 'Add a new page to your site', - { - timeout: customCommandTimeout, - } - ) + cy.get( `#${ novice_step_id_bh[ 2 ] } a`, { + timeout: customCommandTimeout, + } ) .as( 'addPage' ) .scrollIntoView() .click(); @@ -303,12 +308,12 @@ describe( 'Commerce Home Page- Next Steps', () => { cy.wait( 2000 ); cy.get( '@addPage' ).should( 'not.exist' ); viewCompletedTasks(); - cy.get( '@addPage' ).should( 'exist' ); - viewRemainingTasks(); + cy.get( '@addPage' ).should( 'exist' ); + viewRemainingTasks(); } ); it( 'Verify Option Upload Media to your site', () => { - cy.contains( 'Upload media to your site', { + cy.get( `#${ novice_step_id_bh[ 3 ] } a`, { timeout: customCommandTimeout, } ) .as( 'uploadMedia' ) diff --git a/tests/cypress/integration/Home/homePageWithWoo.cy.js b/tests/cypress/integration/Home/homePageWithWoo.cy.js index 29d4a6f2..c2b781d6 100644 --- a/tests/cypress/integration/Home/homePageWithWoo.cy.js +++ b/tests/cypress/integration/Home/homePageWithWoo.cy.js @@ -4,7 +4,7 @@ import { installWoo, viewCompletedTasks, viewRemainingTasks, - waitForNextSteps + waitForNextSteps, } from '../wp-module-support/utils.cy'; const customCommandTimeout = 20000; @@ -23,8 +23,8 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { } ); it( 'Verify next steps "Add your store info"', () => { - waitForNextSteps() - cy.contains( '.nfd-grid.nfd-gap-4 ul li a', 'Add your store info', { + waitForNextSteps(); + cy.get( '#add-your-store-info a', { timeout: customCommandTimeout, } ) .as( 'storeInfoStep' ) @@ -77,24 +77,18 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { it( 'Verify next step "Connect a payment processor"', () => { cy.reload(); waitForNextSteps(); - cy.contains( - '.nfd-grid.nfd-gap-4 ul li a', - 'Connect a payment processor', - { - timeout: customCommandTimeout, - } - ) + 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.contains( 'section', 'Razorpay' ).as( 'razorpayBlock' ); - cy.get( '@razorpayBlock' ).find( '.nfd-button--primary' ).click(); + timeout: customCommandTimeout, + } ).should( 'exist' ); + cy.get( '#razorpay-section' ).as( 'razorpayBlock' ); + cy.get( '@razorpayBlock' ).find( '#install-razorpay' ).click(); cy.get( '[data-id="rzpTestModeToggle"]', { timeout: customCommandTimeout, @@ -105,8 +99,8 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { cy.get( '.nfd-border-t .nfd-button--primary' ).click(); - cy.get( '@razorpayBlock' , { timeout: customCommandTimeout } ) - .find( '.nfd-badge--upsell' , { timeout: customCommandTimeout }) + cy.get( '@razorpayBlock', { timeout: customCommandTimeout } ) + .find( '.nfd-badge--upsell', { timeout: customCommandTimeout } ) .should( 'exist' ); cy.get( `.${ appId }-app-navitem-Home` ).click(); @@ -128,26 +122,18 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { it( ' Verify next step "Set up Shipping options" ', () => { if ( pluginId == 'bluehost' ) { waitForNextSteps(); - cy.contains( - '.nfd-grid.nfd-gap-4 ul li a', - 'Setup shipping options', - { - timeout: customCommandTimeout, - } - ) + cy.get( '#setup-shipping-options a', { + timeout: customCommandTimeout, + } ) .as( 'paymentStep' ) .should( 'exist' ) .scrollIntoView() .click(); - cy.get( '.nfd-app-section-content .nfd-button--primary', { + cy.get( '#install-shippo', { timeout: customCommandTimeout, - } ) - .contains( 'Install' ) - .click(); - cy.get( '.nfd-app-section-content .nfd-button--primary' ) - .contains( 'Installing' ) - .should( 'not.exist' ); + } ).click(); + cy.get( '#installing-shippo' ).should( 'not.exist' ); cy.window().then( ( win ) => { cy.spy( win, 'open', ( url ) => { @@ -156,27 +142,27 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { } ).as( 'windowOpen' ); } ); - cy.get( '.nfd-app-section-content .nfd-button--primary', { + cy.get( '#connect-to-shippo-btn', { timeout: customCommandTimeout, - } ) - .contains( 'Connect' ) - .click(); + } ).click(); cy.get( '@windowOpen', { timeout: customCommandTimeout } ).should( 'be.called' ); } } ); - it.skip( 'Verify next step "Configure tax settings"', () => { + it( 'Verify next step "Configure tax settings"', () => { waitForNextSteps(); - cy.contains( '.nfd-grid.nfd-gap-4 ul li a', 'Configure tax settings', { + 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( `.${ appId }-app-subnavitem-Store.active`, { + timeout: customCommandTimeout, + } ).should( 'exist' ); cy.get( '#tax-yes' ).click(); cy.get( '.nfd-border-t .nfd-button--primary' ).click(); @@ -186,10 +172,9 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { cy.get( '.nfd-w-0 p' ).should( 'exist' ); cy.get( `.${ appId }-app-navitem-Home` ).click(); - waitForNextSteps() - cy.get( '@taxStep', { timeout: 30000 } ).should( - 'not.exist' - ); + cy.reload(); + waitForNextSteps(); + cy.get( '@taxStep', { timeout: 30000 } ).should( 'not.exist' ); viewCompletedTasks(); cy.get( '@taxStep' ).should( 'exist' ); viewRemainingTasks(); @@ -197,12 +182,12 @@ describe( 'Commerce Home Page- When WooCommerce is installed', () => { it( 'Verify next step "Add a Product"', () => { waitForNextSteps(); - cy.contains( '.nfd-grid.nfd-gap-4 ul li a', 'Add a product', { + cy.get( '#add-a-product a', { timeout: customCommandTimeout, - }) + } ) .as( 'addProduct' ) .should( 'exist' ) - .click(); + .click(); cy.url().should( 'eq', Cypress.config().baseUrl + diff --git a/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js b/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js index 6b421bc2..dc774f4a 100644 --- a/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js +++ b/tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js @@ -8,23 +8,23 @@ 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, + 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, + canAccessAI: true, + canAccessHelpCenter: true, + canAccessGlobalCTB: true, + hasEcomdash: false, + hasYithExtended: false, + isEcommerce: false, + isJarvis: true, } ); before( function () { @@ -79,12 +79,12 @@ describe( 'Verify Wondercart accessibility as per site capabilities', () => { .as( 'salesTab' ) .should( 'exist' ); cy.get( '@salesTab' ).click(); - cy.get( '.nfd-button--upsell', { timeout: mediumWait } ).should( + cy.get( '#buynow-wondercart', { timeout: mediumWait } ).should( 'exist' ); } ); - it('Verify clicking on Buy Now leads to cpanel login page', () => { + it( 'Verify clicking on Buy Now leads to cpanel login page', () => { cy.reload(); cy.get( `.${ appId }-app-navitem-Store`, { timeout: customCommandTimeout, @@ -93,9 +93,9 @@ describe( 'Verify Wondercart accessibility as per site capabilities', () => { timeout: customCommandTimeout, } ).click(); cy.get( `.${ appId }-app-subnavitem-Sales` ).click(); - cy.get( '.nfd-button--upsell', { timeout: mediumWait } ) - .eq( 1 ) - .as( 'buyButton' ); + cy.get( '#buynow-wondercart', { timeout: mediumWait } ).as( + 'buyButton' + ); cy.get( '@buyButton' ).should( 'be.visible' ); cy.get( '@buyButton' ) @@ -123,7 +123,7 @@ describe( 'Verify Wondercart accessibility as per site capabilities', () => { .as( 'salesTab' ) .should( 'exist' ); cy.get( '@salesTab' ).click(); - cy.get( '.nfd-button--upsell', { timeout: mediumWait } ).should( + cy.get( '#installnow-wondercart', { timeout: mediumWait } ).should( 'exist' ); } ); @@ -133,8 +133,7 @@ describe( 'Verify Wondercart accessibility as per site capabilities', () => { timeout: customCommandTimeout, } ).click(); cy.get( `.${ appId }-app-subnavitem-Sales` ).click(); - cy.get( '.nfd-button--upsell', { timeout: mediumWait } ) - .eq( 0 ) + cy.get( '#installnow-wondercart', { timeout: mediumWait } ) .scrollIntoView() .click(); cy.get( '.nfd-notification--success', { diff --git a/tests/cypress/integration/wp-module-support/utils.cy.js b/tests/cypress/integration/wp-module-support/utils.cy.js index 9617df82..bbf3c9fe 100644 --- a/tests/cypress/integration/wp-module-support/utils.cy.js +++ b/tests/cypress/integration/wp-module-support/utils.cy.js @@ -2,7 +2,6 @@ import { getAppId } from './pluginID.cy'; const appId = getAppId(); const customCommandTimeout = 30000; -const mediumWait = 60000; const longWait = 120000; export const comingSoon = ( shouldBeComingSoon ) => { @@ -41,9 +40,10 @@ export const comingSoon = ( shouldBeComingSoon ) => { export const installWoo = () => { cy.exec( `npx wp-env run cli wp plugin install woocommerce`, { - timeout: longWait, log: true + timeout: longWait, + log: true, } ); - + cy.exec( `npx wp-env run cli wp plugin activate woocommerce`, { timeout: longWait, } ); @@ -66,7 +66,7 @@ export const viewRemainingTasks = () => { }; export const waitForNextSteps = () => { - cy.get( '.nfd-grid.nfd-gap-4' , { timeout: customCommandTimeout } ) + cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) .as( 'nextSteps' ) .scrollIntoView() .should( 'exist' );