foreman_resource_quota 0.6.5 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fc7d72bb33cb797328a1656add6ef5861b91c7ad4273da69a1faf53cfe3005c
4
- data.tar.gz: ed425c2df6ba263e4314bb6ccef97812102d0703ab41c08d4aaebfc382df4bf4
3
+ metadata.gz: 8179972413d4f04ee5cc81b49025482480803dcd13c9942678203cf4eb5a9fce
4
+ data.tar.gz: de0849b8a95e7aab562aaf026c058996503c7922ce5136422eb009801480765d
5
5
  SHA512:
6
- metadata.gz: 99e464800af7f2e48219666453d1c7958d7826478c60ef09753764af87e034374fd651c07d22d0c23b6a3b770bb84e8589684050a41b6f3ab9d1214378762213
7
- data.tar.gz: c60c8b5231acb3ec2d9a2dcc41c46884c30ebe82b200212bcace9cd706419975c5b0206bddca6ee750e91ec8afdabb09cf18754a3e6136d22e76a9d72723d61a
6
+ metadata.gz: 4120e5a54d42f798bc402ea58c53632889c88437c6b76f35e74e16e02be8bfb944a50b4ca7c10b1ca8e28a29bb634bc513deef23413629a8ccc670e67a15464c
7
+ data.tar.gz: 114e6a1274553f091a01ec06cf27f1f4272e58175757bb6bb7339cbafb0c81cbccb9ac50e36d09db3919fe1e0ba2a6ac4211bd33cc78779ff839bdf21392749d
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanResourceQuota
4
- VERSION = '0.6.5'
4
+ VERSION = '0.7.0'
5
5
  end
data/package.json CHANGED
@@ -24,19 +24,16 @@
24
24
  "@theforeman/vendor": ">= 12.0.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@babel/core": "^7.28.0",
28
- "@sheerun/mutationobserver-shim": "^0.3.3",
27
+ "@babel/core": "^8.0.1",
29
28
  "@testing-library/react": "^16.3.0",
30
- "@testing-library/user-event": "^14.6.1",
31
29
  "@theforeman/builder": ">= 15.0.0",
32
30
  "@theforeman/eslint-plugin-foreman": ">= 15.0.0",
33
31
  "@theforeman/find-foreman": ">= 15.0.0",
34
32
  "@theforeman/test": ">= 15.0.0",
35
33
  "@theforeman/vendor-dev": ">= 15.0.0",
36
- "babel-eslint": "^10.0.3",
37
34
  "eslint": "^10.0.0",
38
35
  "prettier": "^1.19.1",
39
- "stylelint": "^17.0.0",
40
- "stylelint-config-standard": "^40.0.0"
36
+ "stylelint": "^18.0.0",
37
+ "stylelint-config-standard": "^41.0.0"
41
38
  }
42
39
  }
@@ -1,35 +1,34 @@
1
1
  import React from 'react';
2
2
  import '@testing-library/jest-dom';
3
3
 
4
- import { mount, testComponentSnapshotsWithFixtures } from '@theforeman/test';
5
- // Notice: (not) importing Modal affects the snapshot test since it fills
6
- // the components data dynamically in snapshots as soon as it can find the component.
7
- import { Modal } from '@patternfly/react-core';
4
+ import { render, screen, fireEvent, within } from '@testing-library/react';
8
5
 
9
6
  import { withMockedProvider, withRedux } from '../../../test_helper';
10
- import ResourceQuotaForm from '../../ResourceQuotaForm';
11
7
  import ResourceQuotaEmptyState from '../index';
12
8
 
13
9
  const TestComponent = withRedux(withMockedProvider(ResourceQuotaEmptyState));
14
10
 
15
11
  describe('ResourceQuotaEmptyState', () => {
16
- testComponentSnapshotsWithFixtures(ResourceQuotaEmptyState, {
17
- 'should render': {}, // component has no props
12
+ test('renders the create button without an open modal', () => {
13
+ render(<TestComponent />);
14
+
15
+ expect(
16
+ screen.getByRole('button', { name: 'Create resource quota' })
17
+ ).toBeInTheDocument();
18
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
18
19
  });
19
20
 
20
21
  test('opens the modal on clicking "Create resource quota" button', () => {
21
- const wrapper = mount(<TestComponent />);
22
-
23
- expect(wrapper.find(Modal).prop('isOpen')).toBe(false); // check we provide the correct input to Modal
24
- expect(wrapper.find(ResourceQuotaForm).exists()).toBe(false);
22
+ render(<TestComponent />);
25
23
 
26
- wrapper
27
- .find('button')
28
- .filterWhere(button => button.text() === 'Create resource quota')
29
- .simulate('click');
30
- wrapper.update();
24
+ fireEvent.click(
25
+ screen.getByRole('button', { name: 'Create resource quota' })
26
+ );
31
27
 
32
- expect(wrapper.find(Modal).prop('isOpen')).toBe(true);
33
- expect(wrapper.find(ResourceQuotaForm).exists()).toBe(true);
28
+ const dialog = screen.getByRole('dialog');
29
+ expect(dialog).toBeInTheDocument();
30
+ expect(within(dialog).getByText('Properties')).toBeInTheDocument();
31
+ expect(within(dialog).getByText('Name *')).toBeInTheDocument();
32
+ expect(within(dialog).getByText('Description')).toBeInTheDocument();
34
33
  });
35
34
  });
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Button, Modal, ModalVariant } from '@patternfly/react-core';
3
+ import { ClusterIcon } from '@patternfly/react-icons';
3
4
 
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
  import { getDocsURL } from 'foremanReact/common/helpers';
@@ -50,8 +51,7 @@ const ResourceQuotaEmptyState = () => {
50
51
  return (
51
52
  <div>
52
53
  <EmptyStatePattern
53
- icon="pficon pficon-cluster"
54
- iconType="pf"
54
+ icon={<ClusterIcon />}
55
55
  header={__('Resource Quotas')}
56
56
  description={description}
57
57
  action={ActionButton}
@@ -1,50 +1,49 @@
1
- /* eslint-disable promise/prefer-await-to-then */
2
- // Configure Enzyme
3
- import { mount } from '@theforeman/test';
4
1
  import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
5
4
  import { Provider } from 'react-redux';
6
5
  import store from 'foremanReact/redux';
7
- import LabelIcon from 'foremanReact/components/common/LabelIcon';
8
6
  import StatusPropertiesLabel from './StatusPropertiesLabel';
9
7
 
10
8
  const defaultProps = {
11
9
  color: 'blue',
12
- iconChild: <LabelIcon text="test" />,
10
+ iconChild: <span data-testid="status-icon" />,
13
11
  statusContent: 'some content',
14
12
  linkUrl: '/test/link',
15
13
  tooltipText: 'Some nice tooltip',
16
14
  };
17
15
 
18
16
  describe('StatusPropertiesLabel', () => {
19
- const wrapper = mount(
20
- <Provider store={store}>
21
- <StatusPropertiesLabel {...defaultProps} />
22
- </Provider>
23
- );
17
+ beforeEach(() => {
18
+ render(
19
+ <Provider store={store}>
20
+ <StatusPropertiesLabel {...defaultProps} />
21
+ </Provider>
22
+ );
23
+ });
24
+
25
+ it('renders the status content as a link', () => {
26
+ const link = screen.getByRole('link');
27
+ expect(link).toHaveTextContent(defaultProps.statusContent);
28
+ expect(link).toHaveAttribute('href', defaultProps.linkUrl);
29
+ });
30
+
31
+ it('renders a blue label', () => {
32
+ const label = screen.getByRole('link').closest('.pf-v5-c-label');
33
+ expect(label).toHaveClass('pf-m-blue');
34
+ });
24
35
 
25
- it('includes components', () => {
26
- expect(wrapper.find('Tooltip').exists()).toBe(true);
27
- expect(wrapper.find('Tooltip')).toHaveLength(1);
28
- expect(wrapper.find('Label').exists()).toBe(true);
29
- expect(wrapper.find('Label')).toHaveLength(1);
30
- expect(wrapper.find('Link').exists()).toBe(true);
31
- expect(wrapper.find('Link')).toHaveLength(1);
36
+ it('renders the icon inside the label', () => {
37
+ expect(
38
+ screen.getByRole('link').closest('.pf-v5-c-label')
39
+ ).toContainElement(screen.getByTestId('status-icon'));
32
40
  });
33
41
 
34
- it('passes properties', () => {
35
- // ToolTip
36
- const tooltip = wrapper.find('Tooltip');
37
- expect(tooltip.props()).toHaveProperty('content');
38
- expect(tooltip.prop('content')).toContain(defaultProps.tooltipText);
39
- // Label
40
- const label = wrapper.find('Label');
41
- expect(label.props()).toHaveProperty('icon');
42
- expect(label.prop('icon')).toEqual(defaultProps.iconChild);
43
- expect(label.props()).toHaveProperty('color');
44
- expect(label.prop('color')).toEqual(defaultProps.color);
45
- // Link
46
- const link = wrapper.find('Link');
47
- expect(link.props()).toHaveProperty('to');
48
- expect(link.prop('to')).toEqual(defaultProps.linkUrl);
42
+ it('shows the tooltip text on hover', async () => {
43
+ // PF Tooltip listens for mouseenter on the label root, which doesn't bubble
44
+ fireEvent.mouseEnter(screen.getByRole('link').closest('.pf-v5-c-label'));
45
+ expect(
46
+ await screen.findByText(defaultProps.tooltipText)
47
+ ).toBeInTheDocument();
49
48
  });
50
49
  });
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import '@testing-library/jest-dom';
3
3
  import { render, screen, fireEvent } from '@testing-library/react';
4
4
 
5
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
6
5
  import LabelIcon from 'foremanReact/components/common/LabelIcon';
7
6
 
8
7
  import UnitInputField from '../UnitInputField';
@@ -21,30 +20,29 @@ const getDefaultProps = () => ({
21
20
  maxValue: 5,
22
21
  });
23
22
 
24
- const fixtureDefault = {
25
- 'should render default': {
26
- ...getDefaultProps(),
27
- },
28
- };
29
-
30
- const fixtureSingleUnit = {
31
- 'should render without dropdown (single unit)': {
32
- ...getDefaultProps(),
33
- units: [{ symbol: 'cores', factor: 1 }],
34
- },
35
- };
36
-
37
- const fixtureDisabled = {
38
- 'should render as disabled field': {
39
- ...getDefaultProps(),
40
- isDisabled: true,
41
- },
42
- };
43
-
44
23
  describe('UnitInputField', () => {
45
- testComponentSnapshotsWithFixtures(UnitInputField, fixtureDefault);
46
- testComponentSnapshotsWithFixtures(UnitInputField, fixtureSingleUnit);
47
- testComponentSnapshotsWithFixtures(UnitInputField, fixtureDisabled);
24
+ it('renders the input with the initial value and unit dropdown', () => {
25
+ render(<UnitInputField {...getDefaultProps()} />);
26
+ expect(screen.getByRole('textbox')).toHaveValue('0');
27
+ expect(screen.getByRole('textbox')).toBeEnabled();
28
+ expect(screen.getByText('MiB')).toBeInTheDocument();
29
+ });
30
+
31
+ it('renders without dropdown for a single unit', () => {
32
+ render(
33
+ <UnitInputField
34
+ {...getDefaultProps()}
35
+ units={[{ symbol: 'cores', factor: 1 }]}
36
+ />
37
+ );
38
+ expect(screen.getByText('cores')).toBeInTheDocument();
39
+ expect(screen.queryByRole('button', { name: /cores/i })).toBeNull();
40
+ });
41
+
42
+ it('renders as disabled field', () => {
43
+ render(<UnitInputField {...getDefaultProps()} isDisabled />);
44
+ expect(screen.getByRole('textbox')).toBeDisabled();
45
+ });
48
46
 
49
47
  it('triggers handleInputValidation on unit change', async () => {
50
48
  const props = getDefaultProps();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_resource_quota
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATIX AG
@@ -16,9 +16,6 @@ dependencies:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '10.0'
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '14'
22
19
  type: :runtime
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,9 +23,6 @@ dependencies:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
25
  version: '10.0'
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '14'
32
26
  - !ruby/object:Gem::Dependency
33
27
  name: theforeman-rubocop
34
28
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +258,6 @@ files:
264
258
  - webpack/api_helper.test.js
265
259
  - webpack/components/CreateResourceQuotaModal.js
266
260
  - webpack/components/ResourceQuotaEmptyState/__test__/ResourceQuotaEmptyState.test.js
267
- - webpack/components/ResourceQuotaEmptyState/__test__/__snapshots__/ResourceQuotaEmptyState.test.js.snap
268
261
  - webpack/components/ResourceQuotaEmptyState/index.js
269
262
  - webpack/components/ResourceQuotaForm/ResourceQuotaForm.scss
270
263
  - webpack/components/ResourceQuotaForm/ResourceQuotaFormConstants.js
@@ -281,7 +274,6 @@ files:
281
274
  - webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.js
282
275
  - webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.scss
283
276
  - webpack/components/ResourceQuotaForm/components/Resource/__test__/UnitInputField.test.js
284
- - webpack/components/ResourceQuotaForm/components/Resource/__test__/__snapshots__/UnitInputField.test.js.snap
285
277
  - webpack/components/ResourceQuotaForm/components/Resource/index.js
286
278
  - webpack/components/ResourceQuotaForm/components/Resources.js
287
279
  - webpack/components/ResourceQuotaForm/components/Submit.js
@@ -301,7 +293,6 @@ files:
301
293
  - webpack/lib/EditableTextInput/index.js
302
294
  - webpack/lib/react-testing-lib-wrapper.js
303
295
  - webpack/test_helper.js
304
- - webpack/test_setup.js
305
296
  homepage: https://github.com/ATIX-AG/foreman_resource_quota
306
297
  licenses:
307
298
  - GPL-3.0
@@ -321,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
321
312
  - !ruby/object:Gem::Version
322
313
  version: '0'
323
314
  requirements: []
324
- rubygems_version: 4.0.16
315
+ rubygems_version: 4.0.20
325
316
  specification_version: 4
326
317
  summary: Foreman plugin for resource quota
327
318
  test_files: []
@@ -1,85 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ResourceQuotaEmptyState should render 1`] = `
4
- <div>
5
- <EmptyStatePattern
6
- action={
7
- <Button
8
- id="foreman-resource-quota-welcome-create-modal-button"
9
- onClick={[Function]}
10
- ouiaId="foreman-resource-quota-welcome-create-modal-button"
11
- variant="primary"
12
- >
13
- Create resource quota
14
- </Button>
15
- }
16
- description={
17
- <span>
18
- Resource Quotas help admins to manage resources including CPUs, memory, and disk space among users or user groups.
19
- <br />
20
- Define a Resource Quota here and apply it to users to guarantee a fair share of your resources.
21
- <br />
22
- </span>
23
- }
24
- documentation={
25
- Object {
26
- "url": "/links/docs/Administering_Project?chapter=limiting-host-resources",
27
- }
28
- }
29
- header="Resource Quotas"
30
- icon="pficon pficon-cluster"
31
- iconType="pf"
32
- secondaryActions={Array []}
33
- variant="xl"
34
- />
35
- <Modal
36
- actions={Array []}
37
- appendTo={<body />}
38
- aria-describedby=""
39
- aria-label=""
40
- aria-labelledby=""
41
- className=""
42
- hasNoBodyWrapper={false}
43
- isOpen={false}
44
- onClose={[Function]}
45
- ouiaId="foreman-resource-quota-create-modal"
46
- ouiaSafe={true}
47
- position="default"
48
- showClose={true}
49
- title="Create resource quota"
50
- titleIconVariant={null}
51
- titleLabel=""
52
- variant="small"
53
- >
54
- <ResourceQuotaForm
55
- initialProperties={
56
- Object {
57
- "cpu_cores": null,
58
- "description": "",
59
- "disk_gb": null,
60
- "memory_mb": null,
61
- "name": "",
62
- "unassigned": false,
63
- }
64
- }
65
- initialStatus={
66
- Object {
67
- "missing_hosts": null,
68
- "number_of_hosts": null,
69
- "number_of_usergroups": null,
70
- "number_of_users": null,
71
- "utilization": Object {
72
- "cpu_cores": null,
73
- "disk_gb": null,
74
- "memory_mb": null,
75
- },
76
- }
77
- }
78
- isNewQuota={true}
79
- onSubmit={[Function]}
80
- quotaChangesCallback={null}
81
- showAssignmentWarning={false}
82
- />
83
- </Modal>
84
- </div>
85
- `;
@@ -1,164 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`UnitInputField should render as disabled field 1`] = `
4
- <div
5
- className="container-unit-input-field"
6
- >
7
- <FormGroup
8
- fieldId="quota-limit-resource-quota-form-group"
9
- label="Quota Limit"
10
- labelIcon={
11
- <LabelIcon
12
- text="Descriptive title."
13
- />
14
- }
15
- validated="default"
16
- >
17
- <InputGroup>
18
- <InputGroupItem>
19
- <TextInput
20
- id="resource-quota-reg-token-life-time-input"
21
- isDisabled={true}
22
- max={5}
23
- min={0}
24
- onChange={[Function]}
25
- ouiaId="resource-quota-reg-token-life-time-input"
26
- validated="default"
27
- value={0}
28
- />
29
- </InputGroupItem>
30
- <InputGroupItem>
31
- <Dropdown
32
- dropdownItems={
33
- Array [
34
- <DropdownItem
35
- id="unit-dropdownitem-mib"
36
- ouiaId="unit-dropdownitem-mib"
37
- >
38
- MiB
39
- </DropdownItem>,
40
- <DropdownItem
41
- id="unit-dropdownitem-gib"
42
- ouiaId="unit-dropdownitem-gib"
43
- >
44
- GiB
45
- </DropdownItem>,
46
- ]
47
- }
48
- isOpen={false}
49
- onSelect={[Function]}
50
- ouiaId="resource-quota-unit-input-field-input-group-item-dropdown"
51
- toggle={
52
- <DropdownToggle
53
- isDisabled={true}
54
- onToggle={[Function]}
55
- ouiaId="resource-quota-unit-input-field-input-group-item-dropdowni-toggle"
56
- >
57
- MiB
58
- </DropdownToggle>
59
- }
60
- />
61
- </InputGroupItem>
62
- </InputGroup>
63
- </FormGroup>
64
- </div>
65
- `;
66
-
67
- exports[`UnitInputField should render default 1`] = `
68
- <div
69
- className="container-unit-input-field"
70
- >
71
- <FormGroup
72
- fieldId="quota-limit-resource-quota-form-group"
73
- label="Quota Limit"
74
- labelIcon={
75
- <LabelIcon
76
- text="Descriptive title."
77
- />
78
- }
79
- validated="default"
80
- >
81
- <InputGroup>
82
- <InputGroupItem>
83
- <TextInput
84
- id="resource-quota-reg-token-life-time-input"
85
- isDisabled={false}
86
- max={5}
87
- min={0}
88
- onChange={[Function]}
89
- ouiaId="resource-quota-reg-token-life-time-input"
90
- validated="default"
91
- value={0}
92
- />
93
- </InputGroupItem>
94
- <InputGroupItem>
95
- <Dropdown
96
- dropdownItems={
97
- Array [
98
- <DropdownItem
99
- id="unit-dropdownitem-mib"
100
- ouiaId="unit-dropdownitem-mib"
101
- >
102
- MiB
103
- </DropdownItem>,
104
- <DropdownItem
105
- id="unit-dropdownitem-gib"
106
- ouiaId="unit-dropdownitem-gib"
107
- >
108
- GiB
109
- </DropdownItem>,
110
- ]
111
- }
112
- isOpen={false}
113
- onSelect={[Function]}
114
- ouiaId="resource-quota-unit-input-field-input-group-item-dropdown"
115
- toggle={
116
- <DropdownToggle
117
- isDisabled={false}
118
- onToggle={[Function]}
119
- ouiaId="resource-quota-unit-input-field-input-group-item-dropdowni-toggle"
120
- >
121
- MiB
122
- </DropdownToggle>
123
- }
124
- />
125
- </InputGroupItem>
126
- </InputGroup>
127
- </FormGroup>
128
- </div>
129
- `;
130
-
131
- exports[`UnitInputField should render without dropdown (single unit) 1`] = `
132
- <div
133
- className="container-unit-input-field"
134
- >
135
- <FormGroup
136
- fieldId="quota-limit-resource-quota-form-group"
137
- label="Quota Limit"
138
- labelIcon={
139
- <LabelIcon
140
- text="Descriptive title."
141
- />
142
- }
143
- validated="default"
144
- >
145
- <InputGroup>
146
- <InputGroupItem>
147
- <TextInput
148
- id="resource-quota-reg-token-life-time-input"
149
- isDisabled={false}
150
- max={5}
151
- min={0}
152
- onChange={[Function]}
153
- ouiaId="resource-quota-reg-token-life-time-input"
154
- validated="default"
155
- value={0}
156
- />
157
- </InputGroupItem>
158
- <InputGroupText>
159
- cores
160
- </InputGroupText>
161
- </InputGroup>
162
- </FormGroup>
163
- </div>
164
- `;
@@ -1,17 +0,0 @@
1
- import 'core-js/shim';
2
- import 'regenerator-runtime/runtime';
3
- import MutationObserver from '@sheerun/mutationobserver-shim';
4
-
5
- import { configure } from 'enzyme';
6
- import Adapter from 'enzyme-adapter-react-16';
7
-
8
- configure({ adapter: new Adapter() });
9
-
10
- // Mocking translation function
11
- global.__ = text => text; // eslint-disable-line
12
-
13
- // Mocking locales to prevent unnecessary fallback messages
14
- window.locales = { en: { domain: 'app', locale_data: { app: { '': {} } } } };
15
-
16
- // see https://github.com/testing-library/dom-testing-library/releases/tag/v7.0.0
17
- window.MutationObserver = MutationObserver;