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.`);
}
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 Footer = (
<LoginFooter
data-cy="login-footer"
dangerouslySetInnerHTML={{
__html: sanitizeHtml(loginInfo),
}}
@ -133,6 +136,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
return (
<Login header={Header} footer={Footer}>
<LoginMainHeader
data-cy="login-header"
title={
brandName
? i18n._(t`Welcome to Ansible ${brandName}! Please Sign In.`)
@ -149,6 +153,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
>
{formik => (
<LoginForm
data-cy="login-form"
className={authError ? 'pf-m-error' : ''}
helperText={helperText}
isLoginButtonDisabled={isAuthenticating}
@ -178,6 +183,7 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
variant="error"
title={i18n._(t`Error!`)}
onClose={dismissLoginInfoError}
data-cy="login-info-error"
>
{i18n._(
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;
if (authKey === 'azuread-oauth2') {
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`)}>
<AzureIcon />
</Tooltip>
@ -203,7 +213,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-github"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with GitHub`)}>
<GithubIcon />
</Tooltip>
@ -212,7 +226,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github-org') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-github-org"
href={loginUrl}
key={authKey}
>
<Tooltip
content={i18n._(t`Sign in with GitHub Organizations`)}
>
@ -223,7 +241,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github-team') {
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`)}>
<GithubIcon />
</Tooltip>
@ -232,7 +254,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github-enterprise') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise"
href={loginUrl}
key={authKey}
>
<Tooltip
content={i18n._(t`Sign in with GitHub Enterprise`)}
>
@ -243,7 +269,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github-enterprise-org') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise-org"
href={loginUrl}
key={authKey}
>
<Tooltip
content={i18n._(
t`Sign in with GitHub Enterprise Organizations`
@ -256,7 +286,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'github-enterprise-team') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-github-enterprise-team"
href={loginUrl}
key={authKey}
>
<Tooltip
content={i18n._(
t`Sign in with GitHub Enterprise Teams`
@ -269,7 +303,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
}
if (authKey === 'google-oauth2') {
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-google"
href={loginUrl}
key={authKey}
>
<Tooltip content={i18n._(t`Sign in with Google`)}>
<GoogleIcon />
</Tooltip>
@ -279,7 +317,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
if (authKey.startsWith('saml')) {
const samlIDP = authKey.split(':')[1] || null;
return (
<LoginMainFooterLinksItem href={loginUrl} key={authKey}>
<LoginMainFooterLinksItem
data-cy="social-auth-saml"
href={loginUrl}
key={authKey}
>
<Tooltip
content={
samlIDP