1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Add close button to job detail and test

This commit is contained in:
Marliana Lara 2019-06-13 13:47:48 -04:00
parent cda5cc25b8
commit 416d30a189
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 35 additions and 6 deletions

View File

@ -10,7 +10,7 @@ describe('<Jobs />', () => {
); );
}); });
test('should display correct breadcrumb heading', () => { test('should display a breadcrumb heading', () => {
const history = createMemoryHistory({ const history = createMemoryHistory({
initialEntries: ['/jobs'], initialEntries: ['/jobs'],
}); });
@ -30,7 +30,7 @@ describe('<Jobs />', () => {
} }
} }
); );
expect(wrapper.find('BreadcrumbHeading').text()).toEqual('Jobs'); expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
wrapper.unmount(); wrapper.unmount();
}); });
}); });

View File

@ -12,4 +12,13 @@ describe('<JobDetail />', () => {
<JobDetail job={ mockDetails } /> <JobDetail job={ mockDetails } />
); );
}); });
test('should display a Close button', () => {
const wrapper = mountWithContexts(
<JobDetail job={ mockDetails } />
);
expect(wrapper.find('Button[aria-label="close"]').length).toBe(1);
wrapper.unmount();
});
}); });

View File

@ -1,7 +1,14 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { CardBody } from '@patternfly/react-core'; import { Link, withRouter } from 'react-router-dom';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { CardBody, Button } from '@patternfly/react-core';
import styled from 'styled-components';
const ActionButtonWrapper = styled.div`
display: flex;
justify-content: flex-end;
`;
class JobDetail extends Component { class JobDetail extends Component {
constructor (props) { constructor (props) {
super(props); super(props);
@ -9,15 +16,28 @@ class JobDetail extends Component {
render () { render () {
const { const {
job job,
i18n
} = this.props; } = this.props;
return ( return (
<CardBody> <CardBody>
<b>{job.name}</b> <b>{job.name}</b>
<ActionButtonWrapper>
<Button
variant='secondary'
aria-label="close"
component={Link}
to={`/jobs`}
>
{i18n._(t`Close`)}
</Button>
</ActionButtonWrapper>
</CardBody> </CardBody>
); );
} }
} }
export default JobDetail; export default withI18n()(withRouter(JobDetail));