Skip to content

Commit

Permalink
Fix: wrong redirect after how to migrate step (#94151)
Browse files Browse the repository at this point in the history
* redirect to credentials step after How To Migrate

* tests

* Fix the hosted flow tests

* Add the test case when the flag is disabled

* Prevent the tests from disabling the flag for other tests

---------

Co-authored-by: Andrés Blanco <[email protected]>
Co-authored-by: Valter Lorran <[email protected]>
  • Loading branch information
3 people authored Sep 3, 2024
1 parent 9e0835e commit 54af538
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/landing/stepper/declarative-flow/site-migration-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,19 @@ const siteMigration: Flow = {

// Do it for me option.
if ( providedDependencies?.how === HOW_TO_MIGRATE_OPTIONS.DO_IT_FOR_ME ) {
if ( config.isEnabled( 'automated-migration/collect-credentials' ) ) {
return navigate(
addQueryArgs(
{
siteSlug,
from: fromQueryParam,
siteId,
},
STEPS.SITE_MIGRATION_CREDENTIALS.slug
)
);
}

return navigate( STEPS.SITE_MIGRATION_ASSISTED_MIGRATION.slug, {
siteId,
siteSlug,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @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';
Expand Down Expand Up @@ -180,6 +181,7 @@ describe( 'Hosted site Migration Flow', () => {
} );

it( 'migrate redirects from the how-to-migrate (do it for me) page to assisted migration page', () => {
config.disable( 'automated-migration/collect-credentials' );
const { runUseStepNavigationSubmit } = renderFlow( hostedSiteMigrationFlow );

runUseStepNavigationSubmit( {
Expand All @@ -196,6 +198,24 @@ describe( 'Hosted site Migration Flow', () => {
siteSlug: 'example.wordpress.com',
},
} );
config.enable( 'automated-migration/collect-credentials' );
} );

it( 'migrate redirects from the how-to-migrate (do it for me) page to credential collection step', () => {
const { runUseStepNavigationSubmit } = renderFlow( hostedSiteMigrationFlow );

runUseStepNavigationSubmit( {
currentStep: STEPS.SITE_MIGRATION_HOW_TO_MIGRATE.slug,
dependencies: {
destination: 'migrate',
how: HOW_TO_MIGRATE_OPTIONS.DO_IT_FOR_ME,
},
} );

expect( getFlowLocation() ).toEqual( {
path: `/${ STEPS.SITE_MIGRATION_CREDENTIALS.slug }?siteSlug=example.wordpress.com`,
state: null,
} );
} );

it( 'migrate redirects from the how-to-migrate (upgrade needed) page to site-migration-upgrade-plan step', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ describe( 'Site Migration Flow', () => {
} );

it( 'migrate redirects from the how-to-migrate (do it for me) page to assisted migration page', () => {
config.disable( 'automated-migration/collect-credentials' );
const { runUseStepNavigationSubmit } = renderFlow( siteMigrationFlow );

runUseStepNavigationSubmit( {
Expand All @@ -240,6 +241,24 @@ describe( 'Site Migration Flow', () => {
siteSlug: 'example.wordpress.com',
},
} );
config.enable( 'automated-migration/collect-credentials' );
} );

it( 'migrate redirects from the how-to-migrate (do it for me) page to credential collection step', () => {
const { runUseStepNavigationSubmit } = renderFlow( siteMigrationFlow );

runUseStepNavigationSubmit( {
currentStep: STEPS.SITE_MIGRATION_HOW_TO_MIGRATE.slug,
dependencies: {
destination: 'migrate',
how: HOW_TO_MIGRATE_OPTIONS.DO_IT_FOR_ME,
},
} );

expect( getFlowLocation() ).toEqual( {
path: `/${ STEPS.SITE_MIGRATION_CREDENTIALS.slug }?siteSlug=example.wordpress.com`,
state: null,
} );
} );

it( 'migrate redirects from the how-to-migrate (upgrade needed) page to site-migration-upgrade-plan step', () => {
Expand Down

0 comments on commit 54af538

Please sign in to comment.