From 3dc00f620ad05a98ac8098a6ec59ffc2973ed393 Mon Sep 17 00:00:00 2001 From: Amrutha Bhat Shivaswamy Date: Wed, 18 Sep 2024 15:49:32 +0530 Subject: [PATCH 1/5] cypress test script for Migration flow --- .../integration/Migration/migrationAM.cy.js | 41 ++++++++ .../wp-module-support/pluginID.cy.js | 8 ++ .../integration/wp-module-support/utils.cy.js | 93 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 tests/cypress/integration/Migration/migrationAM.cy.js create mode 100644 tests/cypress/integration/wp-module-support/pluginID.cy.js create mode 100644 tests/cypress/integration/wp-module-support/utils.cy.js diff --git a/tests/cypress/integration/Migration/migrationAM.cy.js b/tests/cypress/integration/Migration/migrationAM.cy.js new file mode 100644 index 0000000..b9636d1 --- /dev/null +++ b/tests/cypress/integration/Migration/migrationAM.cy.js @@ -0,0 +1,41 @@ +import { GetPluginId } from '../wp-module-support/pluginID.cy'; +import { wpLogin } from '../wp-module-support/utils.cy'; +const customCommandTimeout = 120000; +const pluginId = GetPluginId(); +const helpCenter = JSON.stringify( { + canAccessAI: true, + canAccessHelpCenter: true, +} ); + +describe( + 'Verify Migration- emulating AM flow', + { testIsolation: true }, + () => { + before( () => { + wpLogin(); + + if ( pluginId !== 'bluehost' ) { + this.skip(); + } + cy.exec( + `npx wp-env run cli wp option set nfd_migrate_site "true"` + ); + + cy.reload(); + } ); + + it('Verify Migration page is loaded', ()=>{ + cy.intercept( + 'GET', + 'https://migrate.bluehost.com/api/v2/initial-data' + ).as( 'Migration-initialise' ); + cy.visit( '/wp-admin/?page=nfd-onboarding#/sitegen/step/migration' ); + cy.wait( '@Migration-initialise', { timeout: customCommandTimeout } ) + .then( ( interception ) => { + expect( interception.response.statusCode ).to.eq( 200 ); + }) + .then(()=>{ + cy.url().should('contain','migrate/bluehost?d_id='); + }) + }); + }); \ No newline at end of file diff --git a/tests/cypress/integration/wp-module-support/pluginID.cy.js b/tests/cypress/integration/wp-module-support/pluginID.cy.js new file mode 100644 index 0000000..04dceca --- /dev/null +++ b/tests/cypress/integration/wp-module-support/pluginID.cy.js @@ -0,0 +1,8 @@ +// +export const GetPluginId = () => { + return Cypress.env('pluginId'); +} + +export const getAppId = () => { + return Cypress.env('appId'); +} \ No newline at end of file diff --git a/tests/cypress/integration/wp-module-support/utils.cy.js b/tests/cypress/integration/wp-module-support/utils.cy.js new file mode 100644 index 0000000..7f12a1b --- /dev/null +++ b/tests/cypress/integration/wp-module-support/utils.cy.js @@ -0,0 +1,93 @@ +import { getAppId } from './pluginID.cy'; + +const appId = getAppId(); +const customCommandTimeout = 30000; +const longWait = 120000; + +export const comingSoon = ( shouldBeComingSoon ) => { + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/settings' + ); + cy.get( '[data-id="coming-soon-toggle"]', { + timeout: customCommandTimeout, + } ).as( 'comingSoonToggle' ); + + if ( shouldBeComingSoon ) { + cy.get( '@comingSoonToggle' ) + .invoke( 'attr', 'aria-checked' ) + .then( ( aria_checked ) => { + if ( aria_checked == 'false' ) { + cy.log( 'Enable Coming Soon Mode' ); + cy.get( '@comingSoonToggle' ).click(); + cy.get( '.nfd-notification--success', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + } + } ); + } else { + cy.get( '@comingSoonToggle' ) + .invoke( 'attr', 'aria-checked' ) + .then( ( aria_checked ) => { + if ( aria_checked == 'true' ) { + cy.log( 'Disable Coming Soon Mode' ); + cy.get( '@comingSoonToggle' ).click(); + cy.get( '.nfd-notification--success', { + timeout: customCommandTimeout, + } ).should( 'exist' ); + } + } ); + } +}; + +export const installWoo = () => { + cy.log( 'Installing WooCommerce' ); + cy.exec( `npx wp-env run cli wp plugin install woocommerce --activate`, { + timeout: longWait, + log: true, + } ); +}; + +export const uninstallPlugins = () => { + cy.log( 'Uninstalling plugins' ); + cy.exec( + 'npx wp-env run cli wp plugin uninstall --all --deactivate --exclude=bluehost-wordpress-plugin,wp-plugin-hostgator,wp-plugin-crazy-domains,wp-plugin-web,wp-plugin-mojo', + { + failOnNonZeroExit: false, + timeout: longWait, + } + ); +}; + +export const viewCompletedTasks = () => { + cy.get( '.nfd-card.nfd-p-0', { + timeout: customCommandTimeout, + } ) + .next() + .click(); +}; + +export const viewRemainingTasks = () => { + cy.get( '.nfd-card.nfd-p-0', { + timeout: customCommandTimeout, + } ) + .next() + .click(); +}; + +export const waitForNextSteps = () => { + cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) + .as( 'nextSteps' ) + .scrollIntoView() + .should( 'exist' ); +}; + +export const deleteCapabilitiesTransient = () => { + cy.log( 'Deleting capabilities transient' ); + cy.exec( `npx wp-env run cli wp transient delete nfd_site_capabilities`, { + failOnNonZeroExit: false, + } ); +}; + +export const wpLogin = () => { + cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) ); +}; From 527a653e907d3baf4a5972ed8614eeb64914cd21 Mon Sep 17 00:00:00 2001 From: Amrutha Bhat Shivaswamy Date: Wed, 18 Sep 2024 20:21:32 +0530 Subject: [PATCH 2/5] PRESSO-2083: skip for non bluehost brand --- tests/cypress/integration/Migration/migrationAM.cy.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/Migration/migrationAM.cy.js b/tests/cypress/integration/Migration/migrationAM.cy.js index b9636d1..67b4097 100644 --- a/tests/cypress/integration/Migration/migrationAM.cy.js +++ b/tests/cypress/integration/Migration/migrationAM.cy.js @@ -12,11 +12,11 @@ describe( { testIsolation: true }, () => { before( () => { - wpLogin(); - if ( pluginId !== 'bluehost' ) { this.skip(); } + wpLogin(); + cy.exec( `npx wp-env run cli wp option set nfd_migrate_site "true"` ); @@ -25,6 +25,9 @@ describe( } ); it('Verify Migration page is loaded', ()=>{ + if ( pluginId !== 'bluehost' ) { + this.skip(); + } cy.intercept( 'GET', 'https://migrate.bluehost.com/api/v2/initial-data' From 5089a064a0e3a315fa804ea5b7a01a35627737ec Mon Sep 17 00:00:00 2001 From: Amrutha Bhat Shivaswamy Date: Thu, 19 Sep 2024 13:00:03 +0530 Subject: [PATCH 3/5] PRESS0-2083 skip for non bluehost brand --- .../Migration/landIntoMigrationFromAM.cy.js | 44 +++++++++++++++++++ .../integration/Migration/migrationAM.cy.js | 44 ------------------- 2 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js delete mode 100644 tests/cypress/integration/Migration/migrationAM.cy.js diff --git a/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js new file mode 100644 index 0000000..d678da5 --- /dev/null +++ b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js @@ -0,0 +1,44 @@ +import { GetPluginId } from '../wp-module-support/pluginID.cy'; +import { wpLogin } from '../wp-module-support/utils.cy'; +const customCommandTimeout = 120000; +const pluginId = GetPluginId(); +const helpCenter = JSON.stringify( { + canAccessAI: true, + canAccessHelpCenter: true, +} ); +if ( pluginId == 'bluehost' ) { + describe( + 'Verify Migration- emulating AM flow', + { testIsolation: true }, + () => { + before( () => { + wpLogin(); + + cy.exec( + `npx wp-env run cli wp option set nfd_migrate_site "true"` + ); + + cy.reload(); + } ); + + it( 'Verify Migration page is loaded', () => { + cy.intercept( + 'GET', + 'https://migrate.bluehost.com/api/v2/initial-data' + ).as( 'Migration-initialise' ); + cy.visit( + '/wp-admin/?page=nfd-onboarding#/sitegen/step/migration' + ); + cy.wait( '@Migration-initialise', { + timeout: customCommandTimeout, + } ) + .then( ( interception ) => { + expect( interception.response.statusCode ).to.eq( 200 ); + } ) + .then( () => { + cy.url().should( 'contain', 'migrate/bluehost?d_id=' ); + } ); + } ); + } + ); +} diff --git a/tests/cypress/integration/Migration/migrationAM.cy.js b/tests/cypress/integration/Migration/migrationAM.cy.js deleted file mode 100644 index 67b4097..0000000 --- a/tests/cypress/integration/Migration/migrationAM.cy.js +++ /dev/null @@ -1,44 +0,0 @@ -import { GetPluginId } from '../wp-module-support/pluginID.cy'; -import { wpLogin } from '../wp-module-support/utils.cy'; -const customCommandTimeout = 120000; -const pluginId = GetPluginId(); -const helpCenter = JSON.stringify( { - canAccessAI: true, - canAccessHelpCenter: true, -} ); - -describe( - 'Verify Migration- emulating AM flow', - { testIsolation: true }, - () => { - before( () => { - if ( pluginId !== 'bluehost' ) { - this.skip(); - } - wpLogin(); - - cy.exec( - `npx wp-env run cli wp option set nfd_migrate_site "true"` - ); - - cy.reload(); - } ); - - it('Verify Migration page is loaded', ()=>{ - if ( pluginId !== 'bluehost' ) { - this.skip(); - } - cy.intercept( - 'GET', - 'https://migrate.bluehost.com/api/v2/initial-data' - ).as( 'Migration-initialise' ); - cy.visit( '/wp-admin/?page=nfd-onboarding#/sitegen/step/migration' ); - cy.wait( '@Migration-initialise', { timeout: customCommandTimeout } ) - .then( ( interception ) => { - expect( interception.response.statusCode ).to.eq( 200 ); - }) - .then(()=>{ - cy.url().should('contain','migrate/bluehost?d_id='); - }) - }); - }); \ No newline at end of file From e037ba50e08ccdff31da62a58f7ea2bf297c630b Mon Sep 17 00:00:00 2001 From: Amrutha Bhat Shivaswamy Date: Fri, 20 Sep 2024 16:49:44 +0530 Subject: [PATCH 4/5] PRESS0-2083 Removed unused functions --- .../Migration/landIntoMigrationFromAM.cy.js | 7 +- .../integration/wp-module-support/utils.cy.js | 86 +------------------ 2 files changed, 3 insertions(+), 90 deletions(-) diff --git a/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js index d678da5..4ec4a44 100644 --- a/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js +++ b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js @@ -2,10 +2,7 @@ import { GetPluginId } from '../wp-module-support/pluginID.cy'; import { wpLogin } from '../wp-module-support/utils.cy'; const customCommandTimeout = 120000; const pluginId = GetPluginId(); -const helpCenter = JSON.stringify( { - canAccessAI: true, - canAccessHelpCenter: true, -} ); + if ( pluginId == 'bluehost' ) { describe( 'Verify Migration- emulating AM flow', @@ -41,4 +38,4 @@ if ( pluginId == 'bluehost' ) { } ); } ); -} +} \ No newline at end of file diff --git a/tests/cypress/integration/wp-module-support/utils.cy.js b/tests/cypress/integration/wp-module-support/utils.cy.js index 7f12a1b..0999e78 100644 --- a/tests/cypress/integration/wp-module-support/utils.cy.js +++ b/tests/cypress/integration/wp-module-support/utils.cy.js @@ -4,90 +4,6 @@ const appId = getAppId(); const customCommandTimeout = 30000; const longWait = 120000; -export const comingSoon = ( shouldBeComingSoon ) => { - cy.visit( - '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/settings' - ); - cy.get( '[data-id="coming-soon-toggle"]', { - timeout: customCommandTimeout, - } ).as( 'comingSoonToggle' ); - - if ( shouldBeComingSoon ) { - cy.get( '@comingSoonToggle' ) - .invoke( 'attr', 'aria-checked' ) - .then( ( aria_checked ) => { - if ( aria_checked == 'false' ) { - cy.log( 'Enable Coming Soon Mode' ); - cy.get( '@comingSoonToggle' ).click(); - cy.get( '.nfd-notification--success', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - } - } ); - } else { - cy.get( '@comingSoonToggle' ) - .invoke( 'attr', 'aria-checked' ) - .then( ( aria_checked ) => { - if ( aria_checked == 'true' ) { - cy.log( 'Disable Coming Soon Mode' ); - cy.get( '@comingSoonToggle' ).click(); - cy.get( '.nfd-notification--success', { - timeout: customCommandTimeout, - } ).should( 'exist' ); - } - } ); - } -}; - -export const installWoo = () => { - cy.log( 'Installing WooCommerce' ); - cy.exec( `npx wp-env run cli wp plugin install woocommerce --activate`, { - timeout: longWait, - log: true, - } ); -}; - -export const uninstallPlugins = () => { - cy.log( 'Uninstalling plugins' ); - cy.exec( - 'npx wp-env run cli wp plugin uninstall --all --deactivate --exclude=bluehost-wordpress-plugin,wp-plugin-hostgator,wp-plugin-crazy-domains,wp-plugin-web,wp-plugin-mojo', - { - failOnNonZeroExit: false, - timeout: longWait, - } - ); -}; - -export const viewCompletedTasks = () => { - cy.get( '.nfd-card.nfd-p-0', { - timeout: customCommandTimeout, - } ) - .next() - .click(); -}; - -export const viewRemainingTasks = () => { - cy.get( '.nfd-card.nfd-p-0', { - timeout: customCommandTimeout, - } ) - .next() - .click(); -}; - -export const waitForNextSteps = () => { - cy.get( '#next-steps-section', { timeout: customCommandTimeout } ) - .as( 'nextSteps' ) - .scrollIntoView() - .should( 'exist' ); -}; - -export const deleteCapabilitiesTransient = () => { - cy.log( 'Deleting capabilities transient' ); - cy.exec( `npx wp-env run cli wp transient delete nfd_site_capabilities`, { - failOnNonZeroExit: false, - } ); -}; - export const wpLogin = () => { cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) ); -}; +}; \ No newline at end of file From fe9811e98f821dd3235da0da240cbff562e7e617 Mon Sep 17 00:00:00 2001 From: Amrutha Bhat Shivaswamy Date: Fri, 20 Sep 2024 17:34:19 +0530 Subject: [PATCH 5/5] PRESS0-2083 Removed unused functions --- .../integration/Migration/landIntoMigrationFromAM.cy.js | 2 +- tests/cypress/integration/wp-module-support/utils.cy.js | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js index 4ec4a44..fc1c3d8 100644 --- a/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js +++ b/tests/cypress/integration/Migration/landIntoMigrationFromAM.cy.js @@ -16,7 +16,7 @@ if ( pluginId == 'bluehost' ) { ); cy.reload(); - } ); + } ) it( 'Verify Migration page is loaded', () => { cy.intercept( diff --git a/tests/cypress/integration/wp-module-support/utils.cy.js b/tests/cypress/integration/wp-module-support/utils.cy.js index 0999e78..07f26bd 100644 --- a/tests/cypress/integration/wp-module-support/utils.cy.js +++ b/tests/cypress/integration/wp-module-support/utils.cy.js @@ -1,9 +1,3 @@ -import { getAppId } from './pluginID.cy'; - -const appId = getAppId(); -const customCommandTimeout = 30000; -const longWait = 120000; - export const wpLogin = () => { cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) ); }; \ No newline at end of file