Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESS0-1256 Remove text dependency, Replace text identifiers with id #297

Merged
merged 7 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 57 additions & 52 deletions tests/cypress/integration/Home/commerceHomePage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand All @@ -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 }`
);
}
} );

Expand All @@ -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'
);
Expand All @@ -201,34 +208,38 @@ 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 ] );
} );
}
} );
} );

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()
Expand All @@ -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()
Expand All @@ -276,21 +285,17 @@ describe( 'Commerce Home Page- Next Steps', () => {

cy.get( '@nextSteps' ).should( 'not.exist' );
viewCompletedTasks();
cy.get('@nextSteps').should('exist');
cy.get( '@nextSteps' ).should( 'exist' );
viewRemainingTasks();
} );

it( 'Verify Add a new page to your site step', () => {
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();
Expand All @@ -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' )
Expand Down
77 changes: 31 additions & 46 deletions tests/cypress/integration/Home/homePageWithWoo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
installWoo,
viewCompletedTasks,
viewRemainingTasks,
waitForNextSteps
waitForNextSteps,
} from '../wp-module-support/utils.cy';

const customCommandTimeout = 20000;
Expand All @@ -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' )
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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 ) => {
Expand All @@ -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();

Expand All @@ -186,23 +172,22 @@ 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();
} );

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 +
Expand Down
Loading
Loading