foreman_snapshot_management 4.2.2 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/foreman_snapshot_management/version.rb +1 -1
- data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +0 -7
- data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +0 -1
- data/webpack/components/SnapshotManagement/__tests__/SnapshotManagement.test.js +35 -0
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +0 -3
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +39 -74
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormField.js +62 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormHelper.js +64 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +72 -24
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +40 -28
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +37 -9
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/index.js +8 -2
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/useSnapshotFormModal.js +11 -2
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +185 -229
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +55 -22
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +73 -54
- data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +6 -0
- data/webpack/components/SnapshotManagement/index.js +0 -1
- data/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +28 -17
- data/webpack/global_index.js +6 -3
- data/webpack/global_test_setup.js +3 -1
- data/webpack/test_setup.js +0 -5
- metadata +6 -7
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +0 -571
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +0 -44
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +0 -1081
- data/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +0 -122
data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
// shallowRenderComponentWithFixtures,
|
|
4
|
-
} from 'react-redux-test-utils';
|
|
5
|
-
// import configureStore from 'redux-mock-store';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
6
3
|
|
|
7
4
|
import SnapshotList from '../SnapshotList';
|
|
8
5
|
|
|
9
|
-
// const mockStore = configureStore([]);
|
|
10
|
-
|
|
11
6
|
const funcDummies = {
|
|
12
7
|
loadSnapshots: hostId => null,
|
|
13
8
|
deleteAction: hostId => null,
|
|
@@ -32,57 +27,81 @@ const testSnapshots = [
|
|
|
32
27
|
created_at: '2021-04-28 10:22:06 UTC',
|
|
33
28
|
},
|
|
34
29
|
];
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
host,
|
|
41
|
-
hasError: true,
|
|
42
|
-
error: { message: 'TEST' },
|
|
43
|
-
...funcDummies,
|
|
44
|
-
},
|
|
45
|
-
'snapshot list': { host, snapshots: testSnapshots, ...funcDummies },
|
|
46
|
-
'without any permissions': {
|
|
47
|
-
host,
|
|
48
|
-
snapshots: testSnapshots,
|
|
49
|
-
canUpdate: false,
|
|
50
|
-
canRevert: false,
|
|
51
|
-
canDelete: false,
|
|
52
|
-
...funcDummies,
|
|
53
|
-
},
|
|
54
|
-
'without delete permission': {
|
|
55
|
-
host,
|
|
56
|
-
snapshots: testSnapshots,
|
|
57
|
-
canUpdate: true,
|
|
58
|
-
canRevert: true,
|
|
59
|
-
canDelete: false,
|
|
60
|
-
...funcDummies,
|
|
61
|
-
},
|
|
62
|
-
'without editableSnapshotName capability': {
|
|
63
|
-
host,
|
|
64
|
-
snapshots: testSnapshots,
|
|
65
|
-
capabilities: { editableSnapshotName: false },
|
|
66
|
-
...funcDummies,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
30
|
+
const permissions = { canUpdate: true, canRevert: true, canDelete: true };
|
|
31
|
+
const renderList = props =>
|
|
32
|
+
render(
|
|
33
|
+
<SnapshotList host={host} isLoading={false} {...funcDummies} {...props} />
|
|
34
|
+
);
|
|
69
35
|
|
|
70
36
|
describe('SnapshotList', () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
it('renders without optional props', () => {
|
|
38
|
+
renderList();
|
|
39
|
+
expect(screen.queryByText('test')).not.toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders loading state', () => {
|
|
43
|
+
renderList({ isLoading: true });
|
|
44
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
45
|
+
});
|
|
74
46
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
47
|
+
it('renders working state', () => {
|
|
48
|
+
renderList({ isWorking: true, snapshots: testSnapshots });
|
|
49
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders error', () => {
|
|
53
|
+
renderList({ hasError: true, error: { message: 'TEST' } });
|
|
54
|
+
expect(screen.getByText(/TEST/)).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('renders the snapshot list', () => {
|
|
58
|
+
renderList({ snapshots: testSnapshots, ...permissions });
|
|
59
|
+
expect(screen.getByText('test')).toBeInTheDocument();
|
|
60
|
+
expect(screen.getByText('Hello')).toBeInTheDocument();
|
|
61
|
+
expect(screen.getByText('123 testSnapshot')).toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('renders unique ouia ids for row buttons', () => {
|
|
65
|
+
const { container } = renderList({
|
|
66
|
+
snapshots: testSnapshots,
|
|
67
|
+
...permissions,
|
|
78
68
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<SnapshotList />
|
|
82
|
-
</Provider>
|
|
69
|
+
const ids = [...container.querySelectorAll('[data-ouia-component-id]')].map(
|
|
70
|
+
el => el.getAttribute('data-ouia-component-id')
|
|
83
71
|
);
|
|
72
|
+
expect(ids.length).toBeGreaterThan(0);
|
|
73
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
74
|
+
expect(ids).toContain('snapshot-delete-button-snapshot-15776');
|
|
75
|
+
expect(ids).toContain('snapshot-delete-button-snapshot-17285');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('renders without any permissions', () => {
|
|
79
|
+
renderList({
|
|
80
|
+
snapshots: testSnapshots,
|
|
81
|
+
canUpdate: false,
|
|
82
|
+
canRevert: false,
|
|
83
|
+
canDelete: false,
|
|
84
|
+
});
|
|
85
|
+
expect(screen.getByText('test')).toBeInTheDocument();
|
|
86
|
+
expect(screen.queryAllByRole('button')).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('renders without delete permission', () => {
|
|
90
|
+
renderList({ snapshots: testSnapshots, ...permissions, canDelete: false });
|
|
91
|
+
expect(
|
|
92
|
+
screen.queryAllByRole('button', { name: 'Delete' })
|
|
93
|
+
).toHaveLength(0);
|
|
94
|
+
expect(
|
|
95
|
+
screen.getAllByRole('button', { name: 'Rollback' }).length
|
|
96
|
+
).toBeGreaterThan(0);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('renders without editableSnapshotName capability', () => {
|
|
100
|
+
renderList({
|
|
101
|
+
snapshots: testSnapshots,
|
|
102
|
+
...permissions,
|
|
103
|
+
capabilities: { editableSnapshotName: false },
|
|
104
|
+
});
|
|
105
|
+
expect(screen.getByText('test')).toBeInTheDocument();
|
|
84
106
|
});
|
|
85
|
-
*/
|
|
86
|
-
describe('renders', () =>
|
|
87
|
-
testComponentSnapshotsWithFixtures(SnapshotList, fixtures));
|
|
88
107
|
});
|
|
@@ -16,7 +16,6 @@ const mapStateToProps = state => ({
|
|
|
16
16
|
isWorking: Selector.selectIsWorking(state),
|
|
17
17
|
hasError: Selector.selectHasError(state),
|
|
18
18
|
error: Selector.selectError(state),
|
|
19
|
-
needsReload: Selector.selectNeedsReload(state),
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
// dispatch actions from Component to Store
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
2
3
|
|
|
3
4
|
import SnapshotManagementCard from '../SnapshotManagementCard';
|
|
4
5
|
|
|
6
|
+
jest.mock('../../SnapshotManagement', () => () => (
|
|
7
|
+
<div data-testid="snapshot-management" />
|
|
8
|
+
));
|
|
9
|
+
|
|
5
10
|
jest.mock(
|
|
6
11
|
'../../SnapshotManagement/components/hooks/useSnapshotSubmit',
|
|
7
12
|
() => ({
|
|
@@ -52,21 +57,27 @@ const hostDetailsNotSupported = {
|
|
|
52
57
|
capabilities: ['build', 'new_volume', 'new_interface', 'image'],
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
const fixtures = {
|
|
56
|
-
'without optional Props': {},
|
|
57
|
-
'with Props': { hostDetails },
|
|
58
|
-
'with VMWare capabilities': {
|
|
59
|
-
hostDetails: hostDetailsVmware,
|
|
60
|
-
},
|
|
61
|
-
'with Proxmox capabilities': {
|
|
62
|
-
hostDetails: hostDetailsProxmox,
|
|
63
|
-
},
|
|
64
|
-
'with NotSupported CR capabilities': {
|
|
65
|
-
hostDetails: hostDetailsNotSupported,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
60
|
describe('SnapshotManagementCard', () => {
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
it('renders nothing without optional props', () => {
|
|
62
|
+
const { container } = render(<SnapshotManagementCard />);
|
|
63
|
+
expect(container).toBeEmptyDOMElement();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('renders nothing with NotSupported CR capabilities', () => {
|
|
67
|
+
const { container } = render(
|
|
68
|
+
<SnapshotManagementCard hostDetails={hostDetailsNotSupported} />
|
|
69
|
+
);
|
|
70
|
+
expect(container).toBeEmptyDOMElement();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it.each([
|
|
74
|
+
['basic props', hostDetails],
|
|
75
|
+
['VMWare capabilities', hostDetailsVmware],
|
|
76
|
+
['Proxmox capabilities', hostDetailsProxmox],
|
|
77
|
+
])('renders the card with %s', (_name, details) => {
|
|
78
|
+
const { getByTestId } = render(
|
|
79
|
+
<SnapshotManagementCard hostDetails={details} />
|
|
80
|
+
);
|
|
81
|
+
expect(getByTestId('snapshot-management')).toBeInTheDocument();
|
|
82
|
+
});
|
|
72
83
|
});
|
data/webpack/global_index.js
CHANGED
|
@@ -9,6 +9,9 @@ import SnapshotManagementCard from './components/SnapshotManagementCard';
|
|
|
9
9
|
import BulkCreateSnapshotMenuItem from './components/SnapshotManagement/components/BulkActions/BulkCreateSnapshotMenuItem/BulkCreateSnapshotMenuItem';
|
|
10
10
|
import BulkSnapshotModalScene from './components/SnapshotManagement/components/BulkActions/BulkSnapshotModalScene/BulkSnapshotModalScene';
|
|
11
11
|
|
|
12
|
+
const CARD_FILL_PRIORITY = 1000;
|
|
13
|
+
const BULK_ACTION_FILL_PRIORITY = 500;
|
|
14
|
+
|
|
12
15
|
// register reducers
|
|
13
16
|
Object.entries(reducers).forEach(([key, reducer]) =>
|
|
14
17
|
registerReducer(key, reducer)
|
|
@@ -19,19 +22,19 @@ addGlobalFill(
|
|
|
19
22
|
'host-overview-cards',
|
|
20
23
|
'foreman_snapshot_management-card',
|
|
21
24
|
<SnapshotManagementCard key="foreman_snapshot_management-card" />,
|
|
22
|
-
|
|
25
|
+
CARD_FILL_PRIORITY
|
|
23
26
|
);
|
|
24
27
|
|
|
25
28
|
addGlobalFill(
|
|
26
29
|
'_all-hosts-modals',
|
|
27
30
|
'foreman_snapshot_management-bulk-modal',
|
|
28
31
|
<BulkSnapshotModalScene key="foreman_snapshot_management-bulk-modal" />,
|
|
29
|
-
|
|
32
|
+
BULK_ACTION_FILL_PRIORITY
|
|
30
33
|
);
|
|
31
34
|
|
|
32
35
|
addGlobalFill(
|
|
33
36
|
'hosts-index-kebab',
|
|
34
37
|
'foreman_snapshot_management-bulk-create',
|
|
35
38
|
<BulkCreateSnapshotMenuItem key="foreman_snapshot_management-bulk-create" />,
|
|
36
|
-
|
|
39
|
+
BULK_ACTION_FILL_PRIORITY
|
|
37
40
|
);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// runs before each test to make sure console.error output will
|
|
2
2
|
// fail a test (i.e. default PropType missing). Check the error
|
|
3
3
|
// output and traceback for actual error.
|
|
4
|
+
const JEST_TIMEOUT_MS = 10000;
|
|
5
|
+
|
|
4
6
|
global.console.error = (error, stack) => {
|
|
5
7
|
/* eslint-disable-next-line no-console */
|
|
6
8
|
if (stack) console.log(stack); // Prints out original stack trace
|
|
@@ -8,4 +10,4 @@ global.console.error = (error, stack) => {
|
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
// Increase jest timeout as some tests using multiple http mocks can time out on CI systems.
|
|
11
|
-
jest.setTimeout(
|
|
13
|
+
jest.setTimeout(JEST_TIMEOUT_MS);
|
data/webpack/test_setup.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import 'core-js/shim';
|
|
2
2
|
import 'regenerator-runtime/runtime';
|
|
3
3
|
|
|
4
|
-
import { configure } from 'enzyme';
|
|
5
|
-
import Adapter from 'enzyme-adapter-react-16';
|
|
6
|
-
|
|
7
|
-
configure({ adapter: new Adapter() });
|
|
8
|
-
|
|
9
4
|
// Mocking translation function
|
|
10
5
|
global.__ = text => text; // eslint-disable-line
|
|
11
6
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_snapshot_management
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ATIX AG
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Foreman plugin to manage snapshots of virtual machines.
|
|
13
13
|
email:
|
|
@@ -86,6 +86,7 @@ files:
|
|
|
86
86
|
- webpack/components/SnapshotManagement/SnapshotManagementConstants.js
|
|
87
87
|
- webpack/components/SnapshotManagement/SnapshotManagementReducer.js
|
|
88
88
|
- webpack/components/SnapshotManagement/SnapshotManagementSelectors.js
|
|
89
|
+
- webpack/components/SnapshotManagement/__tests__/SnapshotManagement.test.js
|
|
89
90
|
- webpack/components/SnapshotManagement/__tests__/SnapshotManagementActions.test.js
|
|
90
91
|
- webpack/components/SnapshotManagement/__tests__/SnapshotManagementReducer.test.js
|
|
91
92
|
- webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementActions.test.js.snap
|
|
@@ -94,27 +95,25 @@ files:
|
|
|
94
95
|
- webpack/components/SnapshotManagement/components/BulkActions/BulkSnapshotModalScene/BulkSnapshotModalScene.js
|
|
95
96
|
- webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js
|
|
96
97
|
- webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormConstants.js
|
|
98
|
+
- webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormField.js
|
|
99
|
+
- webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormHelper.js
|
|
97
100
|
- webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js
|
|
98
|
-
- webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap
|
|
99
101
|
- webpack/components/SnapshotManagement/components/SnapshotForm/index.js
|
|
100
102
|
- webpack/components/SnapshotManagement/components/SnapshotForm/snapshotForm.scss
|
|
101
103
|
- webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js
|
|
102
104
|
- webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModalConstants.js
|
|
103
105
|
- webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js
|
|
104
|
-
- webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap
|
|
105
106
|
- webpack/components/SnapshotManagement/components/SnapshotFormModal/index.js
|
|
106
107
|
- webpack/components/SnapshotManagement/components/SnapshotFormModal/useSnapshotFormModal.js
|
|
107
108
|
- webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js
|
|
108
109
|
- webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
|
|
109
110
|
- webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js
|
|
110
|
-
- webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap
|
|
111
111
|
- webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss
|
|
112
112
|
- webpack/components/SnapshotManagement/components/hooks/useSnapshotSubmit.js
|
|
113
113
|
- webpack/components/SnapshotManagement/index.js
|
|
114
114
|
- webpack/components/SnapshotManagement/snapshotManagement.scss
|
|
115
115
|
- webpack/components/SnapshotManagementCard/SnapshotManagementCard.js
|
|
116
116
|
- webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js
|
|
117
|
-
- webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap
|
|
118
117
|
- webpack/components/SnapshotManagementCard/index.js
|
|
119
118
|
- webpack/global_index.js
|
|
120
119
|
- webpack/global_test_setup.js
|
|
@@ -139,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
139
138
|
- !ruby/object:Gem::Version
|
|
140
139
|
version: '0'
|
|
141
140
|
requirements: []
|
|
142
|
-
rubygems_version: 4.0.
|
|
141
|
+
rubygems_version: 4.0.20
|
|
143
142
|
specification_version: 4
|
|
144
143
|
summary: Snapshot Management for virtual machines
|
|
145
144
|
test_files:
|