forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Monitoring] Protect against these fields not existing in Logstash No…
…des listing (elastic#34939) * Protect against these fields not existing * Add basic unit tests to ensure this behavior does not regress * Expand this test to ensure we don't break on other pieces of data missing * Use N/A if there is no value (rather than 0)
- Loading branch information
1 parent
af49025
commit 2c73730
Showing
3 changed files
with
314 additions
and
6 deletions.
There are no files selected for viewing
219 changes: 219 additions & 0 deletions
219
.../plugins/monitoring/public/components/logstash/listing/__snapshots__/listing.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
x-pack/plugins/monitoring/public/components/logstash/listing/listing.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallowWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { Listing } from './listing'; | ||
|
||
const expectedData = [ | ||
{ | ||
'jvm': { | ||
'mem': { | ||
'heap_used_percent': 27 | ||
} | ||
}, | ||
'logstash': { | ||
'pipeline': { | ||
'batch_size': 125, | ||
'workers': 4 | ||
}, | ||
'http_address': '127.0.0.1:9600', | ||
'name': 'Elastic-MBP.local', | ||
'host': 'Elastic-MBP.local', | ||
'version': '8.0.0', | ||
'uuid': '4134a00e-89e4-4896-a3d4-c3a9aa03a594', | ||
'status': 'green' | ||
}, | ||
'process': { | ||
'cpu': { | ||
'percent': 0 | ||
} | ||
}, | ||
'os': { | ||
'cpu': { | ||
'load_average': { | ||
'1m': 2.54248046875 | ||
} | ||
} | ||
}, | ||
'events': { | ||
'out': 3505 | ||
}, | ||
'reloads': { | ||
'failures': 0, | ||
'successes': 0 | ||
}, | ||
'availability': true | ||
} | ||
]; | ||
|
||
describe('Listing', () => { | ||
it('should render with expected props', () => { | ||
const props = { | ||
data: expectedData, | ||
angular: { | ||
scope: null, | ||
kbnUrl: null | ||
}, | ||
sorting: { | ||
sort: 'asc' | ||
} | ||
}; | ||
|
||
const component = shallowWithIntl(<Listing.WrappedComponent {...props} />); | ||
expect(component.find('EuiMonitoringTable')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with certain data pieces missing', () => { | ||
const props = { | ||
data: expectedData.map(item => { | ||
const { os, process, logstash, jvm, events, ...rest } = item; // eslint-disable-line no-unused-vars | ||
return rest; | ||
}), | ||
angular: { | ||
scope: null, | ||
kbnUrl: null | ||
}, | ||
sorting: { | ||
sort: 'asc' | ||
} | ||
}; | ||
|
||
const component = shallowWithIntl(<Listing.WrappedComponent {...props} />); | ||
expect(component.find('EuiMonitoringTable')).toMatchSnapshot(); | ||
}); | ||
}); |