Skip to content

Commit 16a4798

Browse files
authored
Show Jetpack login label (#107243)
1 parent d9e570a commit 16a4798

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

client/blocks/login/login-form.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ export class LoginForm extends Component {
434434
return this.renderChangeUsername();
435435
}
436436

437-
const showLabel = ! this.props.isJetpack || this.props.isWoo;
438-
439437
return (
440438
// Since the input receives focus on page load, screen reader users don't have any context
441439
// for what credentials to use. Unlike other users, they won't have seen the informative
@@ -444,9 +442,7 @@ export class LoginForm extends Component {
444442
<span className="screen-reader-text">
445443
{ this.props.translate( 'WordPress.com email address or username' ) }
446444
</span>
447-
{ showLabel && (
448-
<span aria-hidden="true">{ this.props.translate( 'Email address or username' ) }</span>
449-
) }
445+
<span aria-hidden="true">{ this.props.translate( 'Email address or username' ) }</span>
450446
</>
451447
);
452448
}

client/blocks/login/test/login-form.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,33 @@ describe( 'LoginForm', () => {
141141
const btn = screen.getByRole( 'button', { name: /Log In/i } );
142142
expect( btn ).toBeInTheDocument();
143143
} );
144+
145+
test( 'shows the visual email-or-username label for Jetpack logins', async () => {
146+
render( <LoginForm isJetpack />, {
147+
initialState: {
148+
login: { socialAccountLink: { isLinking: false } },
149+
route: { query: { current: {}, initial: {} } },
150+
},
151+
} );
152+
153+
const label = screen.getByText( 'Email address or username', {
154+
selector: 'span[aria-hidden="true"]',
155+
} );
156+
expect( label ).toBeInTheDocument();
157+
} );
158+
159+
test( 'shows the username-only label when query flag is set', async () => {
160+
render( <LoginForm />, {
161+
initialState: {
162+
route: {
163+
query: {
164+
current: { username_only: 'true' },
165+
initial: {},
166+
},
167+
},
168+
},
169+
} );
170+
171+
expect( screen.getByText( 'Your username' ) ).toBeInTheDocument();
172+
} );
144173
} );

0 commit comments

Comments
 (0)