clearing error message when upload component mounts (#20268) (#20345)

* clearing error message when upload component mounts

* fixing tests
This commit is contained in:
Bill McConaghy 2018-06-29 12:06:59 -04:00 committed by GitHub
parent 97cf9c4a06
commit 498c054f89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View file

@ -54,22 +54,25 @@ describe('UploadLicense', () => {
services.kbnUrl.change.mockReset();
});
it('should display an error when submitting invalid JSON', async () => {
store.dispatch(uploadLicense('INVALID', 'trial'));
const rendered = mount(component);
store.dispatch(uploadLicense('INVALID', 'trial'));
rendered.update();
expect(rendered).toMatchSnapshot();
});
it('should display an error when ES says license is invalid', async () => {
const rendered = mount(component);
const invalidLicense = JSON.stringify({ license: { type: 'basic' } });
server.respond(UPLOAD_LICENSE_INVALID);
await uploadLicense(invalidLicense)(store.dispatch, null, services);
const rendered = mount(component);
rendered.update();
expect(rendered).toMatchSnapshot();
});
it('should display an error when ES says license is expired', async () => {
const rendered = mount(component);
const invalidLicense = JSON.stringify({ license: { type: 'basic' } });
server.respond(UPLOAD_LICENSE_EXPIRED);
await uploadLicense(invalidLicense)(store.dispatch, null, services);
const rendered = mount(component);
rendered.update();
expect(rendered).toMatchSnapshot();
});
it('should display a modal when license requires acknowledgement', async () => {
@ -93,10 +96,11 @@ describe('UploadLicense', () => {
expect(services.kbnUrl.change).toHaveBeenCalledWith(BASE_PATH);
});
it('should display error when ES returns error', async () => {
const rendered = mount(component);
const license = JSON.stringify({ license: { type: 'basic' } });
server.respond(UPLOAD_LICENSE_TLS_NOT_ENABLED);
await uploadLicense(license)(store.dispatch, null, services);
const rendered = mount(component);
rendered.update();
expect(rendered).toMatchSnapshot();
});
});

View file

@ -22,6 +22,9 @@ import {
} from '@elastic/eui';
export class UploadLicense extends React.PureComponent {
componentDidMount() {
this.props.addUploadErrorMessage('');
}
send = acknowledge => {
const file = this.file;
const fr = new FileReader();
@ -89,7 +92,6 @@ export class UploadLicense extends React.PureComponent {
this.props.addUploadErrorMessage('You must select a license file.');
}
};
render() {
const { currentLicenseType, applying } = this.props;
return (