Skip to content

Commit

Permalink
fix error message in conf managment and add test (#3443)
Browse files Browse the repository at this point in the history
  • Loading branch information
eze9252 authored and gabiwassan committed Aug 5, 2021
1 parent 593cf89 commit 0e27c63
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`WzConfigurationAlerts component mount OK renders correctly to match the snapshot 1`] = `
<ContextProvider
value={
Object {
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"subscription": Subscription {
"handleChangeWrapper": [Function],
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"unsubscribe": null,
},
}
}
>
<Connect(WithLoading(Connect(WzConfigurationAlerts)))
agent={
Object {
"id": "000",
}
}
clusterNodeSelected="master-node"
currentConfig={
Object {
"analysis-alerts": Object {
"alerts": Object {
"email_alert_level": 12,
"log_alert_level": 3,
},
},
"analysis-labels": Object {
"labels": Array [],
},
"csyslog-csyslog": "Fetch configuration. 3013 - Error connecting with socket",
"mail-alerts": "Fetch configuration. 3013 - Error connecting with socket",
"monitor-reports": Object {},
}
}
refreshTime={false}
wazuhNotReadyYet=""
/>
</ContextProvider>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import WzConfigurationAlerts from './alerts';
import { shallow } from 'enzyme';
import { Provider } from 'react-redux';
import configureMockStore from 'redux-mock-store';

jest.mock('../../../../../../kibana-services', () => ({
getUiSettings:() => ({
get:() => {
return false
}
}),
}));

const mockProps = {
"clusterNodeSelected":"master-node",
"agent":{
"id":"000"
},
"refreshTime":false,
"currentConfig":{
"analysis-alerts":{
"alerts":{
"email_alert_level":12,
"log_alert_level":3
}
},
"analysis-labels":{
"labels":[

]
},
"mail-alerts":"Fetch configuration. 3013 - Error connecting with socket",
"monitor-reports":{

},
"csyslog-csyslog":"Fetch configuration. 3013 - Error connecting with socket"
},
"wazuhNotReadyYet":""
}


const mockStore = configureMockStore();
const store = mockStore({});

describe('WzConfigurationAlerts component mount OK', () => {

it('renders correctly to match the snapshot', () => {
const wrapper = shallow(
<Provider store={store}>
<WzConfigurationAlerts {...mockProps} />
</Provider>
);
expect(wrapper).toMatchSnapshot();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ class WzNoConfig extends Component {
<EuiFlexItem>
<div style={{ textAlign: 'center' }}>
<EuiIcon type="help" style={{ marginRight: '4px' }} />
{(error === 'not-present' && (
<span>Configuration not available</span>
)) || <span>Error fetching configuration</span>}
{help && <WzHelpButtonPopover links={help} />}
<EuiHorizontalRule margin="s" />
{(error === 'not-present' && (
<p>This section is not present on the configuration file.</p>
)) || (
<span>
There was a problem while fetching the configuration for this
section.
section. It may be a server problem or the configuration doesn't exist.
</span>
)}
<EuiSpacer size="s" />
Expand Down

0 comments on commit 0e27c63

Please sign in to comment.