Skip to content

Commit

Permalink
Merge pull request #307 from newfold-labs/press0-1325
Browse files Browse the repository at this point in the history
Post Migration scripts
  • Loading branch information
sangeetha-nayak authored May 29, 2024
2 parents 24ef99c + a375e24 commit 0195790
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 45 deletions.
6 changes: 2 additions & 4 deletions tests/cypress/integration/Home/commerceHomePage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ describe( 'Commerce Home Page- Coming soon mode', () => {
.find( '.nfd-flex-1 span' )
.should( 'exist' );
cy.get( '@readyToGoNextLevel', { timeout: customCommandTimeout } )
.find( '.nfd-flex-none > .nfd-button--secondary' )
.find( '#view-site' )
.should( 'exist' )
.and( 'have.text', 'View your site' );
cy.get( '@readyToGoNextLevel' )
.find( '.nfd-flex-none .nfd-button--upsell' )
.find( '#launch-site' )
.should( 'exist' )
.and( 'have.text', 'Launch your site' );
} );

it( 'Verify Visit your site and Launch your site functionality', () => {
Expand Down
70 changes: 70 additions & 0 deletions tests/cypress/integration/Home/migration.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { GetPluginId } from '../wp-module-support/pluginID.cy';
import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy';

const customCommandTimeout = 20000;
const pluginId = GetPluginId();
const helpCenter = JSON.stringify( {
canAccessAI: true,
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' );
} );

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: 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: 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( '#add-a-product', { timeout: customCommandTimeout } ).should(
'exist'
);
} );
} );
93 changes: 52 additions & 41 deletions tests/cypress/integration/wp-module-support/eventsAPIs.cy.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
export const APIList = {
'bh_academy' : '/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
'yoast_seo_academy' : '/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
}

export const EventsAPI = (events_name, pluginId) => {
cy.intercept(events_name).as('events');
cy.wait('@events').then((requestObject) => {
const responseBody = requestObject.request.body;
cy.log(JSON.stringify(responseBody))
const responseData = responseBody.data;

if (events_name == 'bh_academy') {

expect(responseBody.category).equal(
'next_step'
);
expect(responseBody.action).equal(
'next_step_bh_wp_academy_clicked'
);

expect(responseData.page).equal(
cy.url()
)
}

if (events_name == 'yoast_seo_academy') {

expect(responseBody.category).equal(
'next_step'
);
expect(responseBody.action).equal(
'next_step_yoast_academy_clicked'
);

expect(responseData.page).equal(
cy.url()
)
}

});
}
bh_academy:
'/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
yoast_seo_academy:
'/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
update_nameserver:
'/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
connect_domain:
'/index.php?rest_route=%2Fnewfold-data%2Fv1%2Fevents&_locale=user',
};

export const EventsAPI = ( events_name, pluginId ) => {
cy.intercept( events_name ).as( 'events' );
cy.wait( '@events', { timeout: 15000 } ).then( ( requestObject ) => {
const responseBody = requestObject.request.body;
const responseData = responseBody.data;

if ( events_name == 'bh_academy' ) {
expect( responseBody.category ).equal( 'next_step' );
expect( responseBody.action ).equal(
'next_step_bh_wp_academy_clicked'
);

expect( responseData.page ).equal( cy.url() );
}

if ( events_name == 'yoast_seo_academy' ) {
expect( responseBody.category ).equal( 'next_step' );
expect( responseBody.action ).equal(
'next_step_yoast_academy_clicked'
);
expect( responseData.page ).equal( cy.url() );
}

if ( events_name == 'update_nameserver' ) {
expect( responseBody.category ).equal( 'next_step' );
expect( responseBody.action ).equal(
'next_step_update_nameserver_clicked'
);

expect( responseData.page ).equal( cy.url() );
}

if ( events_name == 'connect_domain' ) {
expect( responseBody.category ).equal( 'next_step' );
expect( responseBody.action ).equal(
'next_step_connect_domain_clicked'
);

expect( responseData.page ).equal( cy.url() );
}
} );
};

0 comments on commit 0195790

Please sign in to comment.