foreman_rh_cloud 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -0
- data/app/controllers/foreman_inventory_upload/tasks_controller.rb +25 -0
- data/app/controllers/insights_cloud/settings_controller.rb +24 -0
- data/app/controllers/insights_cloud/tasks_controller.rb +1 -2
- data/app/helpers/foreman_inventory_upload_host_helper.rb +10 -1
- data/app/models/insights_facet.rb +5 -1
- data/app/models/inventory_sync/inventory_status.rb +30 -0
- data/app/models/setting/rh_cloud.rb +1 -0
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
- data/config/routes.rb +3 -0
- data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +5 -0
- data/lib/foreman_inventory_upload.rb +4 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +25 -3
- data/lib/foreman_rh_cloud.rb +13 -0
- data/lib/foreman_rh_cloud/engine.rb +7 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud.rb +8 -8
- data/lib/insights_cloud/async/insights_full_sync.rb +17 -10
- data/lib/insights_cloud/async/insights_scheduled_sync.rb +23 -0
- data/lib/inventory_sync/async/host_result.rb +50 -0
- data/lib/inventory_sync/async/inventory_full_sync.rb +99 -0
- data/test/controllers/insights_sync/settings_controller_test.rb +30 -0
- data/test/factories/insights_factories.rb +31 -0
- data/test/jobs/insights_full_sync_test.rb +4 -2
- data/test/jobs/inventory_full_sync_test.rb +91 -0
- data/test/unit/insights_facet_test.rb +16 -0
- data/test/unit/slice_generator_test.rb +15 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +3 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +5 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +15 -13
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +6 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +3 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +52 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +59 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +33 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +63 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +41 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +20 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +6 -1
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -1
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +2 -0
- data/webpack/ForemanRhCloudPages.js +7 -0
- data/webpack/ForemanRhCloudTestHelpers.js +12 -3
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +33 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +60 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +10 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +28 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +6 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +18 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +46 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +56 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +21 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +15 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +31 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +33 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +9 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +21 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +45 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +17 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +38 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +3 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +32 -28
- data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +7 -2
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +49 -44
- data/webpack/InsightsCloudSync/index.js +2 -1
- data/webpack/__mocks__/foremanReact/constants.js +5 -0
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
- data/webpack/__tests__/ForemanRhCloudSelectors.test.js +4 -1
- data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +12 -2
- data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +9 -9
- data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +24 -2
- data/webpack/index.js +2 -12
- metadata +59 -2
@@ -1,18 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
#full-screen-terminal {
|
2
|
+
.modal-dialog {
|
3
|
+
width: 95%;
|
4
|
+
height: 95%;
|
5
|
+
margin: 30px 0 0 30px;
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
.modal-body {
|
8
|
+
padding: 0;
|
9
|
+
display: flex;
|
10
|
+
height: -webkit-fill-available;
|
11
|
+
height: -moz-available;
|
12
|
+
height: fill-available;
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
.terminal {
|
15
|
+
margin: 0 -20px;
|
16
|
+
height: 100%;
|
17
|
+
}
|
16
18
|
}
|
17
19
|
}
|
18
20
|
}
|
@@ -14,6 +14,11 @@ Object {
|
|
14
14
|
],
|
15
15
|
"state": Object {
|
16
16
|
"ForemanRhCloud": Object {
|
17
|
+
"InsightsCloudSync": Object {
|
18
|
+
"settings": Object {
|
19
|
+
"insightsSyncEnabled": false,
|
20
|
+
},
|
21
|
+
},
|
17
22
|
"inventoryUpload": Object {
|
18
23
|
"accountsList": Object {
|
19
24
|
"accounts": Object {},
|
@@ -24,6 +29,7 @@ Object {
|
|
24
29
|
"inventoryFilter": Object {
|
25
30
|
"filterTerm": "some_new_filter",
|
26
31
|
},
|
32
|
+
"inventorySync": Object {},
|
27
33
|
},
|
28
34
|
},
|
29
35
|
},
|
@@ -14,7 +14,7 @@ exports[`PageHeader rendering render without Props 1`] = `
|
|
14
14
|
<h1
|
15
15
|
className="inventory_title"
|
16
16
|
>
|
17
|
-
Red Hat Inventory
|
17
|
+
Red Hat Inventory
|
18
18
|
</h1>
|
19
19
|
</Col>
|
20
20
|
</Row>
|
@@ -51,8 +51,8 @@ exports[`PageHeader rendering render without Props 1`] = `
|
|
51
51
|
<Col
|
52
52
|
bsClass="col"
|
53
53
|
componentClass="div"
|
54
|
-
xs={
|
55
|
-
xsOffset={
|
54
|
+
xs={6}
|
55
|
+
xsOffset={2}
|
56
56
|
>
|
57
57
|
<ToolbarButtons />
|
58
58
|
</Col>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Button, Icon, Spinner } from 'patternfly-react';
|
4
|
+
import { STATUS } from 'foremanReact/constants';
|
5
|
+
import SyncModal from './components/Modal';
|
6
|
+
import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';
|
7
|
+
|
8
|
+
class SyncButton extends React.Component {
|
9
|
+
state = {
|
10
|
+
showModal: false,
|
11
|
+
};
|
12
|
+
|
13
|
+
toggleModal = () => {
|
14
|
+
this.setState({ showModal: !this.state.showModal });
|
15
|
+
};
|
16
|
+
|
17
|
+
render() {
|
18
|
+
const { cloudToken, handleSync, status } = this.props;
|
19
|
+
|
20
|
+
const handleClick = !cloudToken ? this.toggleModal : handleSync;
|
21
|
+
return (
|
22
|
+
<React.Fragment>
|
23
|
+
<SyncModal show={this.state.showModal} toggleModal={this.toggleModal} />
|
24
|
+
<Button className="sync_button" onClick={handleClick} bsSize="lg">
|
25
|
+
{!cloudToken && (
|
26
|
+
<span>
|
27
|
+
<Icon name="warning" />{' '}
|
28
|
+
</span>
|
29
|
+
)}
|
30
|
+
{status === STATUS.PENDING ? (
|
31
|
+
<Spinner loading size="xs" />
|
32
|
+
) : (
|
33
|
+
<Icon name="refresh" />
|
34
|
+
)}
|
35
|
+
{SYNC_BUTTON_TEXT}
|
36
|
+
</Button>
|
37
|
+
</React.Fragment>
|
38
|
+
);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
SyncButton.propTypes = {
|
43
|
+
cloudToken: PropTypes.string.isRequired,
|
44
|
+
handleSync: PropTypes.func.isRequired,
|
45
|
+
status: PropTypes.string,
|
46
|
+
};
|
47
|
+
|
48
|
+
SyncButton.defaultProps = {
|
49
|
+
status: null,
|
50
|
+
};
|
51
|
+
|
52
|
+
export default SyncButton;
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import API from 'foremanReact/API';
|
3
|
+
import { addToast } from 'foremanReact/redux/actions/toasts';
|
4
|
+
import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
|
5
|
+
import Toast from './components/Toast';
|
6
|
+
import {
|
7
|
+
INVENTORY_SYNC_REQUEST,
|
8
|
+
INVENTORY_SYNC_SUCCESS,
|
9
|
+
INVENTORY_SYNC_FAILURE,
|
10
|
+
} from './SyncButtonConstants';
|
11
|
+
|
12
|
+
export const handleSync = () => async dispatch => {
|
13
|
+
dispatch({
|
14
|
+
type: INVENTORY_SYNC_REQUEST,
|
15
|
+
payload: {},
|
16
|
+
});
|
17
|
+
try {
|
18
|
+
const {
|
19
|
+
data: { syncHosts, disconnectHosts },
|
20
|
+
} = await API.post(inventoryUrl('tasks'));
|
21
|
+
dispatch({
|
22
|
+
type: INVENTORY_SYNC_SUCCESS,
|
23
|
+
payload: {
|
24
|
+
syncHosts,
|
25
|
+
disconnectHosts,
|
26
|
+
},
|
27
|
+
});
|
28
|
+
|
29
|
+
dispatch(
|
30
|
+
addToast({
|
31
|
+
sticky: true,
|
32
|
+
type: 'success',
|
33
|
+
message: (
|
34
|
+
<Toast syncHosts={syncHosts} disconnectHosts={disconnectHosts} />
|
35
|
+
),
|
36
|
+
})
|
37
|
+
);
|
38
|
+
} catch ({
|
39
|
+
message,
|
40
|
+
response: { data: { message: toastMessage } = {} } = {},
|
41
|
+
}) {
|
42
|
+
dispatch({
|
43
|
+
type: INVENTORY_SYNC_FAILURE,
|
44
|
+
payload: {
|
45
|
+
error: message,
|
46
|
+
},
|
47
|
+
});
|
48
|
+
|
49
|
+
if (toastMessage) {
|
50
|
+
dispatch(
|
51
|
+
addToast({
|
52
|
+
sticky: true,
|
53
|
+
type: 'error',
|
54
|
+
message: toastMessage,
|
55
|
+
})
|
56
|
+
);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
};
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import { STATUS } from 'foremanReact/constants';
|
3
|
+
import {
|
4
|
+
INVENTORY_SYNC_REQUEST,
|
5
|
+
INVENTORY_SYNC_SUCCESS,
|
6
|
+
INVENTORY_SYNC_FAILURE,
|
7
|
+
} from './SyncButtonConstants';
|
8
|
+
|
9
|
+
export default (
|
10
|
+
state = Immutable({}),
|
11
|
+
{ type, payload: { syncHosts, disconnectHosts, error } = {} }
|
12
|
+
) => {
|
13
|
+
switch (type) {
|
14
|
+
case INVENTORY_SYNC_REQUEST:
|
15
|
+
return state.merge({
|
16
|
+
...state,
|
17
|
+
status: STATUS.PENDING,
|
18
|
+
error: null,
|
19
|
+
});
|
20
|
+
case INVENTORY_SYNC_SUCCESS:
|
21
|
+
return state.merge({
|
22
|
+
...state,
|
23
|
+
status: STATUS.RESOLVED,
|
24
|
+
syncHosts,
|
25
|
+
disconnectHosts,
|
26
|
+
});
|
27
|
+
case INVENTORY_SYNC_FAILURE:
|
28
|
+
return state.merge({
|
29
|
+
...state,
|
30
|
+
status: STATUS.ERROR,
|
31
|
+
error,
|
32
|
+
});
|
33
|
+
default:
|
34
|
+
return state;
|
35
|
+
}
|
36
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { selectForemanInventoryUpload } from '../../../../../ForemanRhCloudSelectors';
|
2
|
+
|
3
|
+
export const selectInventorySync = state =>
|
4
|
+
selectForemanInventoryUpload(state).inventorySync;
|
5
|
+
|
6
|
+
export const selectStatus = state => selectInventorySync(state).status;
|
7
|
+
|
8
|
+
export const selectError = state => selectInventorySync(state).error;
|
9
|
+
|
10
|
+
export const selectSyncHosts = state => selectInventorySync(state).syncHosts;
|
11
|
+
|
12
|
+
export const selectDisconnectHosts = state =>
|
13
|
+
selectInventorySync(state).disconnectHosts;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import { noop } from 'patternfly-react';
|
3
|
+
|
4
|
+
import SyncButton from '../SyncButton';
|
5
|
+
|
6
|
+
const fixtures = {
|
7
|
+
'render with Props': { cloudToken: '1234', handleSync: noop },
|
8
|
+
};
|
9
|
+
|
10
|
+
describe('SyncButton', () => {
|
11
|
+
describe('rendering', () =>
|
12
|
+
testComponentSnapshotsWithFixtures(SyncButton, fixtures));
|
13
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import API from 'foremanReact/API';
|
3
|
+
import { handleSync } from '../SyncButtonActions';
|
4
|
+
import { successResponse } from './SyncButtonFixtures';
|
5
|
+
|
6
|
+
jest.mock('foremanReact/API');
|
7
|
+
API.post.mockImplementation(async () => successResponse);
|
8
|
+
|
9
|
+
const fixtures = {
|
10
|
+
'should handleSync': () => handleSync(),
|
11
|
+
};
|
12
|
+
|
13
|
+
describe('SyncButton actions', () => testActionSnapshotWithFixtures(fixtures));
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer from '../SyncButtonReducer';
|
3
|
+
import { syncHosts, disconnectHosts, error } from './SyncButtonFixtures';
|
4
|
+
import {
|
5
|
+
INVENTORY_SYNC_REQUEST,
|
6
|
+
INVENTORY_SYNC_SUCCESS,
|
7
|
+
INVENTORY_SYNC_FAILURE,
|
8
|
+
} from '../SyncButtonConstants';
|
9
|
+
|
10
|
+
const fixtures = {
|
11
|
+
'should return the initial state': {},
|
12
|
+
'should handle INVENTORY_SYNC_REQUEST': {
|
13
|
+
action: {
|
14
|
+
type: INVENTORY_SYNC_REQUEST,
|
15
|
+
payload: {},
|
16
|
+
},
|
17
|
+
},
|
18
|
+
'should handle INVENTORY_SYNC_SUCCESS': {
|
19
|
+
action: {
|
20
|
+
type: INVENTORY_SYNC_SUCCESS,
|
21
|
+
payload: { syncHosts, disconnectHosts },
|
22
|
+
},
|
23
|
+
},
|
24
|
+
'should handle INVENTORY_SYNC_FAILURE': {
|
25
|
+
action: {
|
26
|
+
type: INVENTORY_SYNC_FAILURE,
|
27
|
+
payload: { error },
|
28
|
+
},
|
29
|
+
},
|
30
|
+
};
|
31
|
+
|
32
|
+
describe('AccountList reducer', () =>
|
33
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import { inventoryStateWrapper } from '../../../../../../ForemanRhCloudTestHelpers';
|
3
|
+
import {
|
4
|
+
status,
|
5
|
+
error,
|
6
|
+
syncHosts,
|
7
|
+
disconnectHosts,
|
8
|
+
} from './SyncButtonFixtures';
|
9
|
+
import {
|
10
|
+
selectInventorySync,
|
11
|
+
selectStatus,
|
12
|
+
selectError,
|
13
|
+
selectSyncHosts,
|
14
|
+
selectDisconnectHosts,
|
15
|
+
} from '../SyncButtonSelectors';
|
16
|
+
|
17
|
+
const state = inventoryStateWrapper({
|
18
|
+
inventorySync: {
|
19
|
+
status,
|
20
|
+
error,
|
21
|
+
syncHosts,
|
22
|
+
disconnectHosts,
|
23
|
+
},
|
24
|
+
});
|
25
|
+
|
26
|
+
const fixtures = {
|
27
|
+
'should return InventorySync': () => selectInventorySync(state),
|
28
|
+
'should return InventorySync status': () => selectStatus(state),
|
29
|
+
'should return InventorySync error': () => selectError(state),
|
30
|
+
'should return InventorySync SyncHosts': () => selectSyncHosts(state),
|
31
|
+
'should return InventorySync disconnectHosts': () =>
|
32
|
+
selectDisconnectHosts(state),
|
33
|
+
};
|
34
|
+
|
35
|
+
describe('SyncButton selectors', () =>
|
36
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SyncButton rendering render with Props 1`] = `
|
4
|
+
<Fragment>
|
5
|
+
<SyncModal
|
6
|
+
show={false}
|
7
|
+
toggleModal={[Function]}
|
8
|
+
/>
|
9
|
+
<Button
|
10
|
+
active={false}
|
11
|
+
block={false}
|
12
|
+
bsClass="btn"
|
13
|
+
bsSize="lg"
|
14
|
+
bsStyle="default"
|
15
|
+
className="sync_button"
|
16
|
+
disabled={false}
|
17
|
+
onClick={[Function]}
|
18
|
+
>
|
19
|
+
<Icon
|
20
|
+
name="refresh"
|
21
|
+
type="fa"
|
22
|
+
/>
|
23
|
+
Sync inventory status
|
24
|
+
</Button>
|
25
|
+
</Fragment>
|
26
|
+
`;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SyncButton actions should handleSync 1`] = `
|
4
|
+
Array [
|
5
|
+
Array [
|
6
|
+
Object {
|
7
|
+
"payload": Object {},
|
8
|
+
"type": "INVENTORY_SYNC_REQUEST",
|
9
|
+
},
|
10
|
+
],
|
11
|
+
Array [
|
12
|
+
Object {
|
13
|
+
"payload": Object {
|
14
|
+
"disconnectHosts": 0,
|
15
|
+
"syncHosts": 1,
|
16
|
+
},
|
17
|
+
"type": "INVENTORY_SYNC_SUCCESS",
|
18
|
+
},
|
19
|
+
],
|
20
|
+
Array [
|
21
|
+
Object {
|
22
|
+
"payload": Object {
|
23
|
+
"message": Object {
|
24
|
+
"message": <Toast
|
25
|
+
disconnectHosts={0}
|
26
|
+
syncHosts={1}
|
27
|
+
/>,
|
28
|
+
"sticky": true,
|
29
|
+
"type": "success",
|
30
|
+
},
|
31
|
+
},
|
32
|
+
"type": "TOASTS_ADD",
|
33
|
+
},
|
34
|
+
],
|
35
|
+
]
|
36
|
+
`;
|