Skip to content

Commit

Permalink
AP: Fix the loading state text for the Application Passwords check (#…
Browse files Browse the repository at this point in the history
…97340)

* Fix the loading state text for the Application Passwords check

* Fix tests

* Uses the useHasEnTranslation hook
  • Loading branch information
valterlorran authored Dec 13, 2024
1 parent e6ee88d commit bf5ac71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEnabled } from '@automattic/calypso-config';
import { useHasEnTranslation } from '@automattic/i18n-utils';
import { NextButton } from '@automattic/onboarding';
import { useTranslate } from 'i18n-calypso';
import { FC } from 'react';
Expand All @@ -25,6 +26,8 @@ interface CredentialsFormProps {

export const CredentialsForm: FC< CredentialsFormProps > = ( { onSubmit, onSkip } ) => {
const translate = useTranslate();
const hasEnTranslation = useHasEnTranslation();

const { control, errors, accessMethod, isBusy, submitHandler, canBypassVerification } =
useCredentialsForm( onSubmit );

Expand All @@ -43,6 +46,10 @@ export const CredentialsForm: FC< CredentialsFormProps > = ( { onSubmit, onSkip

const getContinueButtonText = () => {
if ( isBusy && ! canBypassVerification ) {
const hasScanningTranslation = hasEnTranslation( 'Scanning site' );
if ( applicationPasswordEnabled && hasScanningTranslation ) {
return translate( 'Scanning site' );
}
return translate( 'Verifying credentials' );
}
if ( canBypassVerification ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe( 'SiteMigrationCredentials', () => {
} );
} );

it( 'shows "Verifying credentials" on the Continue button during submission with application password', async () => {
it( 'shows "Scanning site" on the Continue button during submission with application password', async () => {
const submit = jest.fn();
render( { navigation: { submit } } );
const pendingPromise = new Promise( () => {} );
Expand All @@ -446,7 +446,7 @@ describe( 'SiteMigrationCredentials', () => {
userEvent.click( continueButton() );

await waitFor( () => {
expect( continueButton( /Verifying credentials/ ) ).toBeVisible();
expect( continueButton( /Scanning site/ ) ).toBeVisible();
} );
} );

Expand Down Expand Up @@ -605,7 +605,7 @@ describe( 'SiteMigrationCredentials', () => {
} );
} );

it( 'shows "Verifying credentials" on the Continue button during submission when fetching site info with application password', async () => {
it( 'shows "Scanning site" on the Continue button during submission when fetching site info with application password', async () => {
const submit = jest.fn();
render( { navigation: { submit } } );
const pendingPromise = new Promise( () => {} );
Expand All @@ -621,7 +621,7 @@ describe( 'SiteMigrationCredentials', () => {
await userEvent.click( continueButton() );

await waitFor( () => {
expect( continueButton( /Verifying credentials/ ) ).toBeVisible();
expect( continueButton( /Scanning site/ ) ).toBeVisible();
} );
} );

Expand Down

0 comments on commit bf5ac71

Please sign in to comment.