From 6a79fe592f1719cc17fab869cfe652a53e95faf4 Mon Sep 17 00:00:00 2001 From: Mark Biek Date: Mon, 13 May 2024 10:31:39 -0400 Subject: [PATCH] Remove migration instruction i2 flag code We had been using the `migration-flow/remove-processing-step` flag to gate the updates to the migration flow where we skip the Processing and bundleTransfer steps. We've determined that this change is helping get users through the flow so we're removing the flag. --- .../declarative-flow/site-migration-flow.ts | 65 ++----------------- .../test/site-migration-flow.tsx | 33 +--------- config/development.json | 1 - config/horizon.json | 1 - config/production.json | 1 - config/stage.json | 1 - config/test.json | 1 - config/wpcalypso.json | 1 - 8 files changed, 6 insertions(+), 98 deletions(-) diff --git a/client/landing/stepper/declarative-flow/site-migration-flow.ts b/client/landing/stepper/declarative-flow/site-migration-flow.ts index 3179065361cc5..2d4008f4eed02 100644 --- a/client/landing/stepper/declarative-flow/site-migration-flow.ts +++ b/client/landing/stepper/declarative-flow/site-migration-flow.ts @@ -1,4 +1,3 @@ -import { isEnabled } from '@automattic/calypso-config'; import { PLAN_MIGRATION_TRIAL_MONTHLY } from '@automattic/calypso-products'; import { useSelect } from '@wordpress/data'; import { useEffect } from 'react'; @@ -6,7 +5,6 @@ import { HOSTING_INTENT_MIGRATE } from 'calypso/data/hosting/use-add-hosting-tri import { useIsSiteOwner } from 'calypso/landing/stepper/hooks/use-is-site-owner'; import { useQuery } from 'calypso/landing/stepper/hooks/use-query'; import { addQueryArgs } from 'calypso/lib/url'; -import wpcom from 'calypso/lib/wp'; import { useSiteData } from '../hooks/use-site-data'; import { useSiteSlugParam } from '../hooks/use-site-slug-param'; import { useStartUrl } from '../hooks/use-start-url'; @@ -29,12 +27,8 @@ const siteMigration: Flow = { return [ STEPS.SITE_MIGRATION_IDENTIFY, STEPS.SITE_MIGRATION_IMPORT_OR_MIGRATE, - STEPS.BUNDLE_TRANSFER, - STEPS.SITE_MIGRATION_PLUGIN_INSTALL, - STEPS.PROCESSING, STEPS.SITE_MIGRATION_UPGRADE_PLAN, STEPS.SITE_MIGRATION_ASSIGN_TRIAL_PLAN, - STEPS.SITE_MIGRATION_INSTRUCTIONS, STEPS.SITE_MIGRATION_INSTRUCTIONS_I2, STEPS.ERROR, STEPS.SITE_MIGRATION_ASSISTED_MIGRATION, @@ -98,28 +92,12 @@ const siteMigration: Flow = { window.location.assign( to ); }; - const saveSiteSettings = async ( siteSlug: string, settings: Record< string, unknown > ) => { - return wpcom.req.post( - `/sites/${ siteSlug }/settings`, - { - apiVersion: '1.4', - }, - { - ...settings, - } - ); - }; - // TODO - We may need to add `...params: string[]` back once we start adding more steps. async function submit( providedDependencies: ProvidedDependencies = {} ) { recordSubmitStep( providedDependencies, intent, flowName, currentStep ); const siteSlug = ( providedDependencies?.siteSlug as string ) || siteSlugParam || ''; const siteId = getSiteIdBySlug( siteSlug ); - const transferStepSlug = isEnabled( 'migration-flow/remove-processing-step' ) - ? STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug - : STEPS.BUNDLE_TRANSFER.slug; - switch ( currentStep ) { case STEPS.SITE_MIGRATION_IDENTIFY.slug: { const { from, platform, action } = providedDependencies as { @@ -167,56 +145,25 @@ const siteMigration: Flow = { // Take the user to the upgrade plan step. if ( providedDependencies?.destination === 'upgrade' ) { - // TODO - Once the upgrade plan step is available, we'll want to change this to use the slug constant. - return navigate( 'site-migration-upgrade-plan', { + return navigate( STEPS.SITE_MIGRATION_UPGRADE_PLAN.slug, { siteId, siteSlug, } ); } // Continue with the migration flow. - return navigate( transferStepSlug, { + return navigate( STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug, { siteId, siteSlug, } ); } - case STEPS.BUNDLE_TRANSFER.slug: { - return navigate( STEPS.PROCESSING.slug, { bundleProcessing: true } ); - } - - case STEPS.SITE_MIGRATION_PLUGIN_INSTALL.slug: { - return navigate( STEPS.PROCESSING.slug, { pluginInstall: true } ); - } - - case STEPS.PROCESSING.slug: { - // Any process errors go to the error step. - if ( providedDependencies?.error ) { - return navigate( STEPS.ERROR.slug ); - } - - // If the plugin was installed successfully, go to the migration instructions. - if ( providedDependencies?.pluginInstall ) { - if ( siteSlug ) { - // Remove the in_site_migration_flow option at the end of the flow. - await saveSiteSettings( siteSlug, { - in_site_migration_flow: '', - } ); - } - - return navigate( STEPS.SITE_MIGRATION_INSTRUCTIONS.slug ); - } - - // Otherwise processing has finished from the BundleTransfer step and we need to install the plugin. - return navigate( STEPS.SITE_MIGRATION_PLUGIN_INSTALL.slug ); - } - case STEPS.SITE_MIGRATION_ASSIGN_TRIAL_PLAN.slug: { if ( providedDependencies?.error ) { return navigate( STEPS.ERROR.slug ); } - return navigate( transferStepSlug, { + return navigate( STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug, { siteId, siteSlug, } ); @@ -226,7 +173,7 @@ const siteMigration: Flow = { if ( providedDependencies?.goToCheckout ) { const redirectAfterCheckout = providedDependencies?.userAcceptedDeal ? STEPS.SITE_MIGRATION_ASSISTED_MIGRATION.slug - : transferStepSlug; + : STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug; const destination = addQueryArgs( { @@ -258,10 +205,6 @@ const siteMigration: Flow = { return; } } - - case STEPS.SITE_MIGRATION_INSTRUCTIONS.slug: { - return exitFlow( `/home/${ siteSlug }` ); - } } } diff --git a/client/landing/stepper/declarative-flow/test/site-migration-flow.tsx b/client/landing/stepper/declarative-flow/test/site-migration-flow.tsx index 4a08f0aaf590a..a5eb4ae49739f 100644 --- a/client/landing/stepper/declarative-flow/test/site-migration-flow.tsx +++ b/client/landing/stepper/declarative-flow/test/site-migration-flow.tsx @@ -1,7 +1,6 @@ /** * @jest-environment jsdom */ -import config from '@automattic/calypso-config'; import { PLAN_MIGRATION_TRIAL_MONTHLY } from '@automattic/calypso-products'; import { isCurrentUserLoggedIn } from '@automattic/data-stores/src/user/selectors'; import { waitFor } from '@testing-library/react'; @@ -15,7 +14,6 @@ import siteMigrationFlow from '../site-migration-flow'; import { getAssertionConditionResult, getFlowLocation, renderFlow } from './helpers'; // we need to save the original object for later to not affect tests from other files const originalLocation = window.location; -const originalIsEnabled = config.isEnabled; jest.mock( '../../utils/checkout' ); jest.mock( '@automattic/data-stores/src/user/selectors' ); @@ -43,11 +41,6 @@ describe( 'Site Migration Flow', () => { const testSettingsEndpoint = '/rest/v1.4/sites/example.wordpress.com/settings'; nock( apiBaseUrl ).get( testSettingsEndpoint ).reply( 200, {} ); nock( apiBaseUrl ).post( testSettingsEndpoint ).reply( 200, {} ); - jest - .spyOn( config, 'isEnabled' ) - .mockImplementation( ( key ) => - key === 'migration-flow/remove-processing-step' ? false : originalIsEnabled( key ) - ); } ); afterEach( () => { @@ -172,31 +165,9 @@ describe( 'Site Migration Flow', () => { } ); } ); - it( 'migrate redirects from the import-from page to bundleTransfer step if new instructions not enabled', () => { - const { runUseStepNavigationSubmit } = renderFlow( siteMigrationFlow ); - - runUseStepNavigationSubmit( { - currentStep: STEPS.BUNDLE_TRANSFER.slug, - dependencies: { - destination: 'migrate', - }, - } ); - - expect( getFlowLocation() ).toEqual( { - path: `/${ STEPS.PROCESSING.slug }`, - state: { - bundleProcessing: true, - }, - } ); - } ); - it( 'migrate redirects from the import-from page to new instructions if flag enabled', () => { const { runUseStepNavigationSubmit } = renderFlow( siteMigrationFlow ); - ( config.isEnabled as jest.Mock ).mockImplementation( ( key: string ) => - key === 'migration-flow/remove-processing-step' ? true : originalIsEnabled( key ) - ); - runUseStepNavigationSubmit( { currentStep: STEPS.SITE_MIGRATION_IMPORT_OR_MIGRATE.slug, } ); @@ -224,7 +195,7 @@ describe( 'Site Migration Flow', () => { } ); expect( goToCheckout ).toHaveBeenCalledWith( { - destination: `/setup/site-migration/${ STEPS.BUNDLE_TRANSFER.slug }?siteSlug=example.wordpress.com&from=https%3A%2F%2Fsite-to-be-migrated.com`, + destination: `/setup/site-migration/${ STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug }?siteSlug=example.wordpress.com&from=https%3A%2F%2Fsite-to-be-migrated.com`, extraQueryParams: { hosting_intent: HOSTING_INTENT_MIGRATE }, flowName: 'site-migration', siteSlug: 'example.wordpress.com', @@ -258,7 +229,7 @@ describe( 'Site Migration Flow', () => { } ); expect( getFlowLocation() ).toEqual( { - path: '/bundleTransfer', + path: `/${ STEPS.SITE_MIGRATION_INSTRUCTIONS_I2.slug }`, state: { siteSlug: 'example.wordpress.com' }, } ); } ); diff --git a/config/development.json b/config/development.json index d9880a9ebc1c9..035dfed928df7 100644 --- a/config/development.json +++ b/config/development.json @@ -139,7 +139,6 @@ "me/account-close": true, "me/account/color-scheme-picker": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "network-connection": true, "oauth": false, diff --git a/config/horizon.json b/config/horizon.json index 5d452385ea06a..37d8c48800d84 100644 --- a/config/horizon.json +++ b/config/horizon.json @@ -86,7 +86,6 @@ "marketplace-test": false, "me/account/color-scheme-picker": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "network-connection": true, "onboarding/design-choices": true, diff --git a/config/production.json b/config/production.json index 11fc4e7e01b87..28a75c4aeece1 100644 --- a/config/production.json +++ b/config/production.json @@ -112,7 +112,6 @@ "me/account-close": true, "me/account/color-scheme-picker": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "onboarding/design-choices": true, "onboarding/import": true, diff --git a/config/stage.json b/config/stage.json index 1e4c5ccd8c35e..23e821cfec626 100644 --- a/config/stage.json +++ b/config/stage.json @@ -107,7 +107,6 @@ "me/account-close": true, "me/account/color-scheme-picker": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "onboarding/design-choices": true, "onboarding/import": true, diff --git a/config/test.json b/config/test.json index 21852aef4e934..a2da2bd41620a 100644 --- a/config/test.json +++ b/config/test.json @@ -83,7 +83,6 @@ "marketplace-personal-premium": false, "me/account-close": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "network-connection": true, "p2-enabled": false, diff --git a/config/wpcalypso.json b/config/wpcalypso.json index 4ae8b47a55852..3bf85f79e5161 100644 --- a/config/wpcalypso.json +++ b/config/wpcalypso.json @@ -106,7 +106,6 @@ "me/account-close": true, "me/account/color-scheme-picker": true, "me/vat-details": true, - "migration-flow/remove-processing-step": true, "my-sites/add-ons": true, "network-connection": true, "onboarding/design-choices": true,