-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from newfold-labs/press0-1325
Post Migration scripts
- Loading branch information
Showing
3 changed files
with
124 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
93
tests/cypress/integration/wp-module-support/eventsAPIs.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ); | ||
} | ||
} ); | ||
}; |