Add data-testid to buttons used by e2e tests

This commit is contained in:
Marcus Eide
2020-03-27 13:42:27 +01:00
parent 3d1d34bf96
commit a17f237b75
5 changed files with 35 additions and 10 deletions
@@ -16,7 +16,8 @@
import React, { FC, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Snackbar } from '@material-ui/core';
import { Snackbar, IconButton } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import { Alert } from '@material-ui/lab';
import { ErrorApi, ErrorContext } from '@backstage/core';
@@ -73,7 +74,19 @@ const ErrorDisplay: FC<Props> = ({ forwarder }) => {
message={firstError.toString()}
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
>
<Alert onClose={handleClose} severity="error">
<Alert
action={
<IconButton
color="inherit"
size="small"
onClick={handleClose}
data-testid="error-button-close"
>
<CloseIcon />
</IconButton>
}
severity="error"
>
{firstError.toString()}
</Alert>
</Snackbar>
@@ -27,7 +27,7 @@ import {
TextField,
List,
ListItem,
Link
Link,
} from '@material-ui/core';
import InfoCard from '../../../layout/InfoCard/InfoCard';
@@ -37,7 +37,9 @@ enum AuthType {
const LoginPage: FC<{}> = () => {
const [githubUsername, setGithubUsername] = useState(String);
const [githubPersonalAuthToken, setGithubPersonalAuthToken] = useState(String);
const [githubPersonalAuthToken, setGithubPersonalAuthToken] = useState(
String,
);
const [loginDetails, setLoginDetails] = useState(Object);
const saveGithubInfo = (info: {}) => {
@@ -70,11 +72,11 @@ const LoginPage: FC<{}> = () => {
'Content-Type': 'application/x-www-form-urlencoded',
}),
})
.then((response) => {
.then(response => {
if (response.status === 200) return response.json();
throw Error(`${response.status} ${response.statusText}`);
})
.then((data) => {
.then(data => {
const info = {
username: username,
token: token,
@@ -158,6 +160,7 @@ const LoginPage: FC<{}> = () => {
</ListItem>
<ListItem>
<Button
data-testid="github-auth-button"
variant="outlined"
color="primary"
onClick={() => authenticate(AuthType.GitHub)}
@@ -174,4 +177,4 @@ const LoginPage: FC<{}> = () => {
);
};
export default LoginPage;
export default LoginPage;
@@ -78,7 +78,11 @@ const SupportButton: FC<Props> = ({
return (
<Fragment>
<Button color="primary" onClick={onClickHandler}>
<Button
data-testid="support-button"
color="primary"
onClick={onClickHandler}
>
<HelpIcon className={classes.leftIcon} />
Support
</Button>
+1 -1
View File
@@ -94,7 +94,7 @@ export const SidebarItem: FC<SidebarItemProps> = ({
onClick={onClick}
underline="none"
>
<div className={classes.iconContainer}>
<div data-testid="login-button" className={classes.iconContainer}>
<Icon fontSize="small" />
</div>
<Typography variant="subtitle1" className={classes.label}>
@@ -26,7 +26,12 @@ const ErrorButton: FC<{}> = () => {
};
return (
<Button variant="contained" color="primary" onClick={handleClick}>
<Button
data-testid="error-button"
variant="contained"
color="primary"
onClick={handleClick}
>
Trigger an error!
</Button>
);