Adds data-cy attributes to some login components

This commit is contained in:
mabashian
2021-03-19 15:55:22 -04:00
parent 854da96976
commit 1d01efa024

View File

@@ -120,10 +120,13 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
helperText = i18n._(t`There was a problem signing in. Please try again.`); helperText = i18n._(t`There was a problem signing in. Please try again.`);
} }
const HeaderBrand = <Brand src={logo} alt={alt || brandName} />; const HeaderBrand = (
<Brand data-cy="brand-logo" src={logo} alt={alt || brandName} />
);
const Header = <LoginHeader headerBrand={HeaderBrand} />; const Header = <LoginHeader headerBrand={HeaderBrand} />;
const Footer = ( const Footer = (
<LoginFooter <LoginFooter
data-cy="login-footer"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: sanitizeHtml(loginInfo), __html: sanitizeHtml(loginInfo),
}} }}
@@ -133,6 +136,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
return ( return (
<Login header={Header} footer={Footer}> <Login header={Header} footer={Footer}>
<LoginMainHeader <LoginMainHeader
data-cy="login-header"
title={ title={
brandName brandName
? i18n._(t`Welcome to Ansible ${brandName}! Please Sign In.`) ? i18n._(t`Welcome to Ansible ${brandName}! Please Sign In.`)
@@ -149,6 +153,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
> >
{formik => ( {formik => (
<LoginForm <LoginForm
data-cy="login-form"
className={authError ? 'pf-m-error' : ''} className={authError ? 'pf-m-error' : ''}
helperText={helperText} helperText={helperText}
isLoginButtonDisabled={isAuthenticating} isLoginButtonDisabled={isAuthenticating}
@@ -178,6 +183,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
variant="error" variant="error"
title={i18n._(t`Error!`)} title={i18n._(t`Error!`)}
onClose={dismissLoginInfoError} onClose={dismissLoginInfoError}
data-cy="login-info-error"
> >
{i18n._( {i18n._(
t`Failed to fetch custom login configuration settings. System defaults will be shown instead.` t`Failed to fetch custom login configuration settings. System defaults will be shown instead.`
@@ -194,7 +200,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
const loginUrl = socialAuthOptions[authKey].login_url; const loginUrl = socialAuthOptions[authKey].login_url;
if (authKey === 'azuread-oauth2') { if (authKey === 'azuread-oauth2') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-azure"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with Azure AD`)}> <Tooltip content={i18n._(t`Sign in with Azure AD`)}>
<AzureIcon /> <AzureIcon />
</Tooltip> </Tooltip>
@@ -203,7 +213,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github') { if (authKey === 'github') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with GitHub`)}> <Tooltip content={i18n._(t`Sign in with GitHub`)}>
<GithubIcon /> <GithubIcon />
</Tooltip> </Tooltip>
@@ -212,7 +226,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github-org') { if (authKey === 'github-org') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github-org"
href={loginUrl}
key={authKey}
>
<Tooltip <Tooltip
content={i18n._(t`Sign in with GitHub Organizations`)} content={i18n._(t`Sign in with GitHub Organizations`)}
> >
@@ -223,7 +241,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github-team') { if (authKey === 'github-team') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github-team"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with GitHub Teams`)}> <Tooltip content={i18n._(t`Sign in with GitHub Teams`)}>
<GithubIcon /> <GithubIcon />
</Tooltip> </Tooltip>
@@ -232,7 +254,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github-enterprise') { if (authKey === 'github-enterprise') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise"
href={loginUrl}
key={authKey}
>
<Tooltip <Tooltip
content={i18n._(t`Sign in with GitHub Enterprise`)} content={i18n._(t`Sign in with GitHub Enterprise`)}
> >
@@ -243,7 +269,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github-enterprise-org') { if (authKey === 'github-enterprise-org') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise-org"
href={loginUrl}
key={authKey}
>
<Tooltip <Tooltip
content={i18n._( content={i18n._(
t`Sign in with GitHub Enterprise Organizations` t`Sign in with GitHub Enterprise Organizations`
@@ -256,7 +286,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'github-enterprise-team') { if (authKey === 'github-enterprise-team') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise-team"
href={loginUrl}
key={authKey}
>
<Tooltip <Tooltip
content={i18n._( content={i18n._(
t`Sign in with GitHub Enterprise Teams` t`Sign in with GitHub Enterprise Teams`
@@ -269,7 +303,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
} }
if (authKey === 'google-oauth2') { if (authKey === 'google-oauth2') {
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-google"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with Google`)}> <Tooltip content={i18n._(t`Sign in with Google`)}>
<GoogleIcon /> <GoogleIcon />
</Tooltip> </Tooltip>
@@ -279,7 +317,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
if (authKey.startsWith('saml')) { if (authKey.startsWith('saml')) {
const samlIDP = authKey.split(':')[1] || null; const samlIDP = authKey.split(':')[1] || null;
return ( return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}> <LoginMainFooterLinksItem
data-cy="social-auth-saml"
href={loginUrl}
key={authKey}
>
<Tooltip <Tooltip
content={ content={
samlIDP samlIDP