diff --git a/tests/cypress/fixtures/migrate-connect.json b/tests/cypress/fixtures/migrate-connect.json new file mode 100644 index 000000000..920af5173 --- /dev/null +++ b/tests/cypress/fixtures/migrate-connect.json @@ -0,0 +1,8 @@ +{ + "success": true, + "data": { + "message": "Connect plugin is installed and ready to start the migration.", + "response": true, + "redirect_url": "https:\/\/app.instawp.io\/migrate\/bluehost?d_id=1bb9623e-5208-40f7-9383-cd91df2fe58c" + } +} diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js index e8216c2a0..e1ca3335d 100644 --- a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js @@ -5,6 +5,7 @@ import { DarkBGCheck, LightBGCheck, } from '../wp-module-support/siteGen.cy'; +import { apiList, migrationConnection } from '../wp-module-support/MockApi.cy'; describe( 'SiteGen Fork Step', function () { before( () => { @@ -59,7 +60,7 @@ describe( 'SiteGen Fork Step', function () { arr.each( ( $element ) => { const dataSlugText = $element.attr( 'data-flow' ); if ( dataSlugText == 'sitegen' ) { - $element.click(); + $element.trigger( 'click' ); cy.url().should( 'include', 'sitegen/step/welcome', { timeout: 10000, } ); @@ -74,4 +75,54 @@ describe( 'SiteGen Fork Step', function () { .should( 'exist' ) .should( 'contain', 'Already have a WordPress site' ); } ); + + it( 'Verify by default import your WP account leads to transfer site link' , () => { + cy.window().then( ( win ) => { + cy.spy( win, 'open', ( url ) => { + win.location.href = + 'https://bluehost.com/my-account/hosting/details/sites/add/transfer'; + } ).as( 'windowOpen' ); + } ); + + cy.get( '.nfd-onboarding-step--site-gen__fork__importsite' ) + .scrollIntoView() + .click(); + + cy.get( '@windowOpen' ).should( 'be.called' ); + } ); + + it( 'Verify Import site leads to migration process initiation screen when can migrate capability is set' , () => { + cy.exec( + `npx wp-env run cli wp option update _transient_nfd_site_capabilities '{"hasAISiteGen": true, "canAccessAI": true, "canMigrateSite": true}' --format=json`, + { timeout: 20000 } + ); + cy.reload() + cy.intercept( apiList.migrateConnect, ( req ) => { + migrationConnection( req ); + } ).as( 'migrateCall' ); + cy.get( '.nfd-onboarding-step--site-gen__fork__importsite' , { + timeout: 10000, + } ) + .scrollIntoView() + .should( 'exist' ) + .click(); + cy.get( '.nfd-onboarding-step__heading__title', { + timeout: 10000, + } ).should( 'exist' ); + cy.get( + '.nfd-onboarding-step--site-gen__migration--container__loader', { timeout : 10000 } + ).should( 'exist' ); + cy.get( + '.nfd-onboarding-step--site-gen__migration--container__importtext' + ).should( 'exist' ); + + AdminBarCheck(); + DarkBGCheck(); + LightBGCheck(); + cy.wait( '@migrateCall', { timeout: 10000 } ); + } ); + + it( 'Verify migration connection request is successful and redirection happens' , () => { + cy.url().should( 'contain', 'app.instawp.io/migrate' ); + } ); } ); diff --git a/tests/cypress/integration/wp-module-support/MockApi.cy.js b/tests/cypress/integration/wp-module-support/MockApi.cy.js index e7c96ba90..39e908ce2 100644 --- a/tests/cypress/integration/wp-module-support/MockApi.cy.js +++ b/tests/cypress/integration/wp-module-support/MockApi.cy.js @@ -11,6 +11,7 @@ const homepages_mock = require( '../../fixtures/homepages.json' ); const theme_style_mock = require( '../../fixtures/theme-style.json' ); const customize_data_mock = require( '../../fixtures/customize-data.json' ); const homepage_regenerate_mock = require( '../../fixtures/homepage-regenerate.json' ); +const migrate_connect_mock = require( '../../fixtures/migrate-connect.json' ); export const apiList = { sitegen: @@ -23,6 +24,8 @@ export const apiList = { '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fthemes%2Fvariations&variations=false&flow=sitegen&_locale=user', customizedata: '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fcustomize-data&flow=sitegen&_locale=user', + migrateConnect: + '/index.php?rest_route=%2Fnewfold-migration%2Fv1%2Fmigrate%2Fconnect&_locale=user', }; export const siteGenMockAll = ( req ) => { @@ -91,3 +94,12 @@ export const homePagesRegenerate = ( req ) => { }, } ); }; + +export const migrationConnection = ( req ) => { + req.reply( { + method: 'GET', + statusCode: 200, + body: migrate_connect_mock, + delay: 8000, + } ); +};