foreman_snapshot_management 4.3.0 → 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.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_snapshot_management/version.rb +1 -1
  3. data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +0 -7
  4. data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +0 -1
  5. data/webpack/components/SnapshotManagement/__tests__/SnapshotManagement.test.js +35 -0
  6. data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +0 -3
  7. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +33 -67
  8. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormField.js +62 -0
  9. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormHelper.js +64 -0
  10. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +72 -24
  11. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +1 -0
  12. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +36 -9
  13. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +185 -229
  14. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +55 -22
  15. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +73 -54
  16. data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +6 -0
  17. data/webpack/components/SnapshotManagement/index.js +0 -1
  18. data/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +28 -17
  19. data/webpack/test_setup.js +0 -5
  20. metadata +6 -7
  21. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +0 -571
  22. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +0 -57
  23. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +0 -1081
  24. data/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +0 -122
@@ -1,13 +1,8 @@
1
- import {
2
- testComponentSnapshotsWithFixtures,
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 fixtures = {
36
- 'without optional Props': { host, ...funcDummies },
37
- loading: { host, isLoading: true, ...funcDummies },
38
- working: { host, isWorking: true, ...funcDummies },
39
- error: {
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
- let store;
73
- let component;
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
- beforeEach(() => {
76
- store = mockStore({
77
- myState: 'sample text',
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
- component = renderer.create(
80
- <Provider store={store}>
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
  });
@@ -11,3 +11,9 @@
11
11
  .action-buttons {
12
12
  width: 20%;
13
13
  }
14
+
15
+ .snapshot-action-buttons {
16
+ display: flex;
17
+ flex-direction: row;
18
+ flex-wrap: nowrap;
19
+ }
@@ -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 { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
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
- describe('renders', () =>
71
- testComponentSnapshotsWithFixtures(SnapshotManagementCard, fixtures));
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
  });
@@ -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.3.0
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-08-05 00:00:00.000000000 Z
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.16
141
+ rubygems_version: 4.0.20
143
142
  specification_version: 4
144
143
  summary: Snapshot Management for virtual machines
145
144
  test_files: