foreman-tasks 11.0.6 → 11.0.7
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_tasks/version.rb +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +37 -9
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +19 -16
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +197 -71
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +24 -40
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +2 -16
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +0 -16
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/GenericConfirmModal.js +70 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +25 -14
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +8 -7
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/index.test.js +409 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createBulkTaskModal.js +67 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createTaskModal.js +51 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +73 -23
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +5 -2
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +67 -11
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +86 -6
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +225 -39
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +136 -37
- metadata +6 -19
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +0 -60
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +0 -14
- data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +0 -25
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +0 -212
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +0 -83
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +0 -106
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +0 -38
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +0 -36
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +0 -205
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +0 -27
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +0 -41
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +0 -19
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +0 -9
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +0 -52
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +0 -2
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +0 -10
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c64888d93b687e1d29a9b7baaeefc47dd42a8cc82383b6b42cce34e69731cbe3
|
|
4
|
+
data.tar.gz: 2166a6056f5d8553b7b61345908860d745e8dd465508bc4011251e2d2938ece2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfce2a4d918298cec79b2954f3411fa7d6947a020f95f4b62137a12e0b81d5019dff5c317706bae0572d64728bfed5707e49a75793aa43221d2beb95f901a992
|
|
7
|
+
data.tar.gz: fc7f80734a1e145bfee7530252288a9037266c8b1da0577394a776cd3c503459b2420b35c3c4725c27ee16858978237f990b714650c32301ff7ea0a8f456716e
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { Grid, Row } from 'patternfly-react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
3
4
|
import TaskInfo from './TaskInfo';
|
|
4
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ForceUnlockConfirmationModal,
|
|
7
|
+
UnlockConfirmationModal,
|
|
8
|
+
} from '../../common/ClickConfirmation';
|
|
5
9
|
import { TaskButtons } from './TaskButtons';
|
|
6
10
|
|
|
7
11
|
const Task = props => {
|
|
@@ -25,13 +29,29 @@ const Task = props => {
|
|
|
25
29
|
}
|
|
26
30
|
unlockTaskRequest(id, action);
|
|
27
31
|
};
|
|
32
|
+
const [unlockModalOpen, setUnlockModalOpen] = useState(false);
|
|
33
|
+
const [forceUnlockModalOpen, setForceUnlockModalOpen] = useState(false);
|
|
34
|
+
|
|
28
35
|
return (
|
|
29
36
|
<React.Fragment>
|
|
30
|
-
<
|
|
31
|
-
|
|
37
|
+
<UnlockConfirmationModal
|
|
38
|
+
onClick={unlock}
|
|
39
|
+
isOpen={unlockModalOpen}
|
|
40
|
+
setModalClosed={() => setUnlockModalOpen(false)}
|
|
41
|
+
/>
|
|
42
|
+
<ForceUnlockConfirmationModal
|
|
43
|
+
onClick={forceUnlock}
|
|
44
|
+
isOpen={forceUnlockModalOpen}
|
|
45
|
+
setModalClosed={() => setForceUnlockModalOpen(false)}
|
|
46
|
+
/>
|
|
32
47
|
<Grid>
|
|
33
48
|
<Row>
|
|
34
|
-
<TaskButtons
|
|
49
|
+
<TaskButtons
|
|
50
|
+
taskReloadStart={taskReloadStart}
|
|
51
|
+
setUnlockModalOpen={setUnlockModalOpen}
|
|
52
|
+
setForceUnlockModalOpen={setForceUnlockModalOpen}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
35
55
|
</Row>
|
|
36
56
|
<TaskInfo {...props} />
|
|
37
57
|
</Grid>
|
|
@@ -40,13 +60,21 @@ const Task = props => {
|
|
|
40
60
|
};
|
|
41
61
|
|
|
42
62
|
Task.propTypes = {
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
taskReload: PropTypes.bool,
|
|
64
|
+
id: PropTypes.string,
|
|
65
|
+
forceCancelTaskRequest: PropTypes.func,
|
|
66
|
+
unlockTaskRequest: PropTypes.func,
|
|
67
|
+
action: PropTypes.string,
|
|
68
|
+
taskReloadStart: PropTypes.func,
|
|
45
69
|
};
|
|
46
70
|
|
|
47
71
|
Task.defaultProps = {
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
taskReload: false,
|
|
73
|
+
id: '',
|
|
74
|
+
forceCancelTaskRequest: () => null,
|
|
75
|
+
unlockTaskRequest: () => null,
|
|
76
|
+
action: '',
|
|
77
|
+
taskReloadStart: () => null,
|
|
50
78
|
};
|
|
51
79
|
|
|
52
80
|
export default Task;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Col, Button } from 'patternfly-react';
|
|
4
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
5
4
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
6
|
-
import {
|
|
7
|
-
UNLOCK_MODAL,
|
|
8
|
-
FORCE_UNLOCK_MODAL,
|
|
9
|
-
} from '../../TaskActions/TaskActionsConstants';
|
|
10
5
|
|
|
11
6
|
export const TaskButtons = ({
|
|
12
7
|
canEdit,
|
|
@@ -24,13 +19,9 @@ export const TaskButtons = ({
|
|
|
24
19
|
parentTask,
|
|
25
20
|
cancelTaskRequest,
|
|
26
21
|
resumeTaskRequest,
|
|
22
|
+
setUnlockModalOpen,
|
|
23
|
+
setForceUnlockModalOpen,
|
|
27
24
|
}) => {
|
|
28
|
-
const unlockModalActions = useForemanModal({
|
|
29
|
-
id: UNLOCK_MODAL,
|
|
30
|
-
});
|
|
31
|
-
const forceUnlockModalActions = useForemanModal({
|
|
32
|
-
id: FORCE_UNLOCK_MODAL,
|
|
33
|
-
});
|
|
34
25
|
const editActionsTitle = canEdit
|
|
35
26
|
? undefined
|
|
36
27
|
: __('You do not have permission');
|
|
@@ -114,7 +105,9 @@ export const TaskButtons = ({
|
|
|
114
105
|
className="unlock-button"
|
|
115
106
|
bsSize="small"
|
|
116
107
|
disabled={!canEdit || state !== 'paused'}
|
|
117
|
-
onClick={
|
|
108
|
+
onClick={() => {
|
|
109
|
+
setUnlockModalOpen(true);
|
|
110
|
+
}}
|
|
118
111
|
title={editActionsTitle}
|
|
119
112
|
data-original-title={editActionsTitle}
|
|
120
113
|
>
|
|
@@ -124,7 +117,7 @@ export const TaskButtons = ({
|
|
|
124
117
|
className="force-unlock-button"
|
|
125
118
|
bsSize="small"
|
|
126
119
|
disabled={!canEdit || state === 'stopped'}
|
|
127
|
-
onClick={
|
|
120
|
+
onClick={() => setForceUnlockModalOpen(true)}
|
|
128
121
|
title={editActionsTitle}
|
|
129
122
|
data-original-title={editActionsTitle}
|
|
130
123
|
>
|
|
@@ -134,7 +127,7 @@ export const TaskButtons = ({
|
|
|
134
127
|
);
|
|
135
128
|
};
|
|
136
129
|
|
|
137
|
-
|
|
130
|
+
export const TaskButtonspropTypes = {
|
|
138
131
|
canEdit: PropTypes.bool,
|
|
139
132
|
dynflowEnableConsole: PropTypes.bool,
|
|
140
133
|
taskReloadStart: PropTypes.func.isRequired,
|
|
@@ -151,8 +144,7 @@ TaskButtons.propTypes = {
|
|
|
151
144
|
cancelTaskRequest: PropTypes.func,
|
|
152
145
|
resumeTaskRequest: PropTypes.func,
|
|
153
146
|
};
|
|
154
|
-
|
|
155
|
-
TaskButtons.defaultProps = {
|
|
147
|
+
export const TaskButtonsdefaultProps = {
|
|
156
148
|
canEdit: false,
|
|
157
149
|
dynflowEnableConsole: false,
|
|
158
150
|
taskReload: false,
|
|
@@ -166,3 +158,14 @@ TaskButtons.defaultProps = {
|
|
|
166
158
|
cancelTaskRequest: () => null,
|
|
167
159
|
resumeTaskRequest: () => null,
|
|
168
160
|
};
|
|
161
|
+
|
|
162
|
+
TaskButtons.propTypes = {
|
|
163
|
+
...TaskButtonspropTypes,
|
|
164
|
+
setUnlockModalOpen: PropTypes.func,
|
|
165
|
+
setForceUnlockModalOpen: PropTypes.func,
|
|
166
|
+
};
|
|
167
|
+
TaskButtons.defaultProps = {
|
|
168
|
+
setUnlockModalOpen: () => null,
|
|
169
|
+
setForceUnlockModalOpen: () => null,
|
|
170
|
+
...TaskButtonsdefaultProps,
|
|
171
|
+
};
|
|
@@ -1,45 +1,160 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
mount,
|
|
5
|
-
shallow,
|
|
6
|
-
} from '@theforeman/test';
|
|
7
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
8
4
|
import { STATUS } from 'foremanReact/constants';
|
|
9
5
|
import { TaskButtons } from '../TaskButtons';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
id: 'test',
|
|
23
|
-
state: 'paused',
|
|
24
|
-
hasSubTasks: true,
|
|
25
|
-
dynflowEnableConsole: true,
|
|
26
|
-
parentTask: 'parent-id',
|
|
27
|
-
taskReload: true,
|
|
28
|
-
canEdit: true,
|
|
29
|
-
status: STATUS.RESOLVED,
|
|
30
|
-
taskReloadStart: jest.fn(),
|
|
31
|
-
taskProgressToggle: jest.fn(),
|
|
32
|
-
},
|
|
6
|
+
|
|
7
|
+
const setUnlockModalOpen = jest.fn();
|
|
8
|
+
const setForceUnlockModalOpen = jest.fn();
|
|
9
|
+
|
|
10
|
+
const defaultProps = {
|
|
11
|
+
id: 'test',
|
|
12
|
+
taskReloadStart: jest.fn(),
|
|
13
|
+
taskProgressToggle: jest.fn(),
|
|
14
|
+
cancelTaskRequest: jest.fn(),
|
|
15
|
+
resumeTaskRequest: jest.fn(),
|
|
16
|
+
setUnlockModalOpen,
|
|
17
|
+
setForceUnlockModalOpen,
|
|
33
18
|
};
|
|
34
19
|
|
|
35
|
-
describe('
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
describe('TaskButtons', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('rendering', () => {
|
|
26
|
+
it('renders reload button with correct text when taskReload is false', () => {
|
|
27
|
+
render(<TaskButtons {...defaultProps} taskReload={false} />);
|
|
28
|
+
expect(
|
|
29
|
+
screen.getByRole('button', { name: /start auto-reloading/i })
|
|
30
|
+
).toBeInTheDocument();
|
|
31
|
+
expect(
|
|
32
|
+
screen.queryByRole('button', { name: /stop auto-reloading/i })
|
|
33
|
+
).not.toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('renders reload button with correct text when taskReload is true', () => {
|
|
37
|
+
render(<TaskButtons {...defaultProps} taskReload />);
|
|
38
|
+
expect(
|
|
39
|
+
screen.getByRole('button', { name: /stop auto-reloading/i })
|
|
40
|
+
).toBeInTheDocument();
|
|
41
|
+
expect(
|
|
42
|
+
screen.queryByRole('button', { name: /start auto-reloading/i })
|
|
43
|
+
).not.toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('renders dynflow console link with correct href when externalId is provided', () => {
|
|
47
|
+
render(<TaskButtons {...defaultProps} externalId="external-123" />);
|
|
48
|
+
const dynflowLink = screen.getByRole('link', {
|
|
49
|
+
name: /dynflow console/i,
|
|
50
|
+
});
|
|
51
|
+
expect(dynflowLink).toHaveAttribute(
|
|
52
|
+
'href',
|
|
53
|
+
'/foreman_tasks/dynflow/external-123'
|
|
54
|
+
);
|
|
55
|
+
expect(dynflowLink).toHaveAttribute('target', '_blank');
|
|
56
|
+
expect(dynflowLink).toHaveAttribute('rel', 'noopener noreferrer');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('disables dynflow console link when dynflowEnableConsole is false', () => {
|
|
60
|
+
render(<TaskButtons {...defaultProps} dynflowEnableConsole={false} />);
|
|
61
|
+
const dynflowLink = screen.getByRole('link', {
|
|
62
|
+
name: /dynflow console/i,
|
|
63
|
+
});
|
|
64
|
+
expect(dynflowLink).toHaveClass('disabled');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('enables dynflow console link when dynflowEnableConsole is true', () => {
|
|
68
|
+
render(
|
|
69
|
+
<TaskButtons
|
|
70
|
+
{...defaultProps}
|
|
71
|
+
dynflowEnableConsole
|
|
72
|
+
externalId="external-123"
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
const dynflowLink = screen.getByRole('link', {
|
|
76
|
+
name: /dynflow console/i,
|
|
77
|
+
});
|
|
78
|
+
expect(dynflowLink).not.toHaveClass('disabled');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('disables resume and cancel buttons when canEdit is false', () => {
|
|
82
|
+
render(<TaskButtons {...defaultProps} canEdit={false} />);
|
|
83
|
+
expect(screen.getByRole('button', { name: /resume/i })).toBeDisabled();
|
|
84
|
+
expect(screen.getByRole('button', { name: /cancel/i })).toBeDisabled();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('disables resume button when resumable is false', () => {
|
|
88
|
+
render(<TaskButtons {...defaultProps} canEdit resumable={false} />);
|
|
89
|
+
expect(screen.getByRole('button', { name: /resume/i })).toBeDisabled();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('disables cancel button when cancellable is false', () => {
|
|
93
|
+
render(<TaskButtons {...defaultProps} canEdit cancellable={false} />);
|
|
94
|
+
expect(screen.getByRole('button', { name: /cancel/i })).toBeDisabled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('disables unlock button when state is not paused', () => {
|
|
98
|
+
render(<TaskButtons {...defaultProps} canEdit state="running" />);
|
|
99
|
+
expect(screen.getByRole('button', { name: /^unlock$/i })).toBeDisabled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('enables unlock button when state is paused and canEdit is true', () => {
|
|
103
|
+
render(<TaskButtons {...defaultProps} canEdit state="paused" />);
|
|
104
|
+
expect(
|
|
105
|
+
screen.getByRole('button', { name: /^unlock$/i })
|
|
106
|
+
).not.toBeDisabled();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('disables force unlock button when state is stopped', () => {
|
|
110
|
+
render(<TaskButtons {...defaultProps} canEdit state="stopped" />);
|
|
111
|
+
expect(
|
|
112
|
+
screen.getByRole('button', { name: /force unlock/i })
|
|
113
|
+
).toBeDisabled();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('enables force unlock button when state is not stopped and canEdit is true', () => {
|
|
117
|
+
render(<TaskButtons {...defaultProps} canEdit state="running" />);
|
|
118
|
+
expect(
|
|
119
|
+
screen.getByRole('button', { name: /force unlock/i })
|
|
120
|
+
).not.toBeDisabled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('renders parent task button when parentTask is provided', () => {
|
|
124
|
+
render(<TaskButtons {...defaultProps} parentTask="parent-123" />);
|
|
125
|
+
const parentButton = screen.getByRole('link', { name: /parent task/i });
|
|
126
|
+
expect(parentButton).toBeInTheDocument();
|
|
127
|
+
expect(parentButton).toHaveAttribute(
|
|
128
|
+
'href',
|
|
129
|
+
'/foreman_tasks/tasks/parent-123'
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('does not render parent task button when parentTask is not provided', () => {
|
|
134
|
+
render(<TaskButtons {...defaultProps} />);
|
|
135
|
+
expect(
|
|
136
|
+
screen.queryByRole('link', { name: /parent task/i })
|
|
137
|
+
).not.toBeInTheDocument();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('renders sub tasks button when hasSubTasks is true', () => {
|
|
141
|
+
render(<TaskButtons {...defaultProps} hasSubTasks id="task-123" />);
|
|
142
|
+
const subTasksButton = screen.getByRole('link', { name: /sub tasks/i });
|
|
143
|
+
expect(subTasksButton).toBeInTheDocument();
|
|
144
|
+
expect(subTasksButton).toHaveAttribute(
|
|
145
|
+
'href',
|
|
146
|
+
'/foreman_tasks/tasks/task-123/sub_tasks'
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('does not render sub tasks button when hasSubTasks is false', () => {
|
|
151
|
+
render(<TaskButtons {...defaultProps} hasSubTasks={false} />);
|
|
152
|
+
expect(
|
|
153
|
+
screen.queryByRole('link', { name: /sub tasks/i })
|
|
154
|
+
).not.toBeInTheDocument();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
describe('user interactions', () => {
|
|
43
158
|
const cancelTaskRequest = jest.fn();
|
|
44
159
|
const resumeTaskRequest = jest.fn();
|
|
45
160
|
const taskProgressToggle = jest.fn();
|
|
@@ -47,6 +162,7 @@ describe('Task', () => {
|
|
|
47
162
|
const id = 'some-id';
|
|
48
163
|
const action = 'some-action';
|
|
49
164
|
const props = {
|
|
165
|
+
...defaultProps,
|
|
50
166
|
taskReload: false,
|
|
51
167
|
id,
|
|
52
168
|
action,
|
|
@@ -55,41 +171,51 @@ describe('Task', () => {
|
|
|
55
171
|
taskProgressToggle,
|
|
56
172
|
taskReloadStart,
|
|
57
173
|
status: STATUS.RESOLVED,
|
|
174
|
+
canEdit: true,
|
|
175
|
+
resumable: true,
|
|
176
|
+
cancellable: true,
|
|
177
|
+
state: 'paused',
|
|
58
178
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(taskProgressToggle).
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
resumeButton.
|
|
72
|
-
|
|
73
|
-
expect(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
179
|
+
|
|
180
|
+
it('calls taskProgressToggle when reload button is clicked', () => {
|
|
181
|
+
render(<TaskButtons {...props} />);
|
|
182
|
+
const reloadButton = screen.getByRole('button', {
|
|
183
|
+
name: /start auto-reloading/i,
|
|
184
|
+
});
|
|
185
|
+
fireEvent.click(reloadButton);
|
|
186
|
+
expect(taskProgressToggle).toHaveBeenCalled();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('calls taskReloadStart and resumeTaskRequest when resume button is clicked', () => {
|
|
190
|
+
render(<TaskButtons {...props} />);
|
|
191
|
+
const resumeButton = screen.getByRole('button', { name: /resume/i });
|
|
192
|
+
fireEvent.click(resumeButton);
|
|
193
|
+
expect(taskReloadStart).toHaveBeenCalledWith(id);
|
|
194
|
+
expect(resumeTaskRequest).toHaveBeenCalledWith(id, action);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('calls taskReloadStart and cancelTaskRequest when cancel button is clicked', () => {
|
|
198
|
+
render(<TaskButtons {...props} />);
|
|
199
|
+
const cancelButton = screen.getByRole('button', { name: /cancel/i });
|
|
200
|
+
fireEvent.click(cancelButton);
|
|
201
|
+
expect(taskReloadStart).toHaveBeenCalledWith(id);
|
|
202
|
+
expect(cancelTaskRequest).toHaveBeenCalledWith(id, action);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('calls setUnlockModalOpen when unlock button is clicked', () => {
|
|
206
|
+
render(<TaskButtons {...props} />);
|
|
207
|
+
const unlockButton = screen.getByRole('button', { name: /^unlock$/i });
|
|
208
|
+
fireEvent.click(unlockButton);
|
|
209
|
+
expect(setUnlockModalOpen).toHaveBeenCalledWith(true);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('calls setForceUnlockModalOpen when force unlock button is clicked', () => {
|
|
213
|
+
render(<TaskButtons {...props} />);
|
|
214
|
+
const forceUnlockButton = screen.getByRole('button', {
|
|
215
|
+
name: /force unlock/i,
|
|
216
|
+
});
|
|
217
|
+
fireEvent.click(forceUnlockButton);
|
|
218
|
+
expect(setForceUnlockModalOpen).toHaveBeenCalledWith(true);
|
|
93
219
|
});
|
|
94
220
|
});
|
|
95
221
|
});
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Task rendering render with minimal Props 1`] = `
|
|
4
4
|
<Fragment>
|
|
5
|
-
<
|
|
5
|
+
<UnlockConfirmationModal
|
|
6
6
|
id="unlockModal"
|
|
7
|
+
isOpen={false}
|
|
7
8
|
onClick={[Function]}
|
|
9
|
+
setModalClosed={[Function]}
|
|
8
10
|
/>
|
|
9
|
-
<
|
|
11
|
+
<ForceUnlockConfirmationModal
|
|
10
12
|
id="forceUnlockModal"
|
|
13
|
+
isOpen={false}
|
|
11
14
|
onClick={[Function]}
|
|
12
15
|
selectedRowsLen={1}
|
|
16
|
+
setModalClosed={[Function]}
|
|
13
17
|
/>
|
|
14
18
|
<Grid
|
|
15
19
|
bsClass="container"
|
|
@@ -26,47 +30,32 @@ exports[`Task rendering render with minimal Props 1`] = `
|
|
|
26
30
|
cancelTaskRequest={[Function]}
|
|
27
31
|
cancellable={false}
|
|
28
32
|
dynflowEnableConsole={false}
|
|
29
|
-
endedAt=""
|
|
30
|
-
errors={Array []}
|
|
31
33
|
externalId=""
|
|
34
|
+
forceCancelTaskRequest={[Function]}
|
|
32
35
|
hasSubTasks={false}
|
|
33
|
-
help=""
|
|
34
36
|
id="test"
|
|
35
|
-
output=""
|
|
36
37
|
parentTask=""
|
|
37
|
-
progress={0}
|
|
38
|
-
result="error"
|
|
39
38
|
resumable={false}
|
|
40
39
|
resumeTaskRequest={[Function]}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
startedAt=""
|
|
40
|
+
setForceUnlockModalOpen={[Function]}
|
|
41
|
+
setUnlockModalOpen={[Function]}
|
|
44
42
|
state=""
|
|
45
43
|
taskProgressToggle={[MockFunction]}
|
|
46
44
|
taskReload={false}
|
|
47
45
|
taskReloadStart={[MockFunction]}
|
|
48
|
-
|
|
49
|
-
usernamePath=""
|
|
46
|
+
unlockTaskRequest={[Function]}
|
|
50
47
|
/>
|
|
51
48
|
</Row>
|
|
52
49
|
<TaskInfo
|
|
53
50
|
action=""
|
|
54
|
-
canEdit={false}
|
|
55
|
-
cancelTaskRequest={[Function]}
|
|
56
|
-
cancellable={false}
|
|
57
|
-
dynflowEnableConsole={false}
|
|
58
51
|
endedAt=""
|
|
59
52
|
errors={Array []}
|
|
60
|
-
|
|
61
|
-
hasSubTasks={false}
|
|
53
|
+
forceCancelTaskRequest={[Function]}
|
|
62
54
|
help=""
|
|
63
55
|
id="test"
|
|
64
56
|
output=""
|
|
65
|
-
parentTask=""
|
|
66
57
|
progress={0}
|
|
67
58
|
result="error"
|
|
68
|
-
resumable={false}
|
|
69
|
-
resumeTaskRequest={[Function]}
|
|
70
59
|
startAt=""
|
|
71
60
|
startBefore=""
|
|
72
61
|
startedAt=""
|
|
@@ -74,6 +63,7 @@ exports[`Task rendering render with minimal Props 1`] = `
|
|
|
74
63
|
taskProgressToggle={[MockFunction]}
|
|
75
64
|
taskReload={false}
|
|
76
65
|
taskReloadStart={[MockFunction]}
|
|
66
|
+
unlockTaskRequest={[Function]}
|
|
77
67
|
username=""
|
|
78
68
|
usernamePath=""
|
|
79
69
|
/>
|
|
@@ -83,14 +73,18 @@ exports[`Task rendering render with minimal Props 1`] = `
|
|
|
83
73
|
|
|
84
74
|
exports[`Task rendering render with some Props 1`] = `
|
|
85
75
|
<Fragment>
|
|
86
|
-
<
|
|
76
|
+
<UnlockConfirmationModal
|
|
87
77
|
id="unlockModal"
|
|
78
|
+
isOpen={false}
|
|
88
79
|
onClick={[Function]}
|
|
80
|
+
setModalClosed={[Function]}
|
|
89
81
|
/>
|
|
90
|
-
<
|
|
82
|
+
<ForceUnlockConfirmationModal
|
|
91
83
|
id="forceUnlockModal"
|
|
84
|
+
isOpen={false}
|
|
92
85
|
onClick={[Function]}
|
|
93
86
|
selectedRowsLen={1}
|
|
87
|
+
setModalClosed={[Function]}
|
|
94
88
|
/>
|
|
95
89
|
<Grid
|
|
96
90
|
bsClass="container"
|
|
@@ -107,39 +101,30 @@ exports[`Task rendering render with some Props 1`] = `
|
|
|
107
101
|
cancelTaskRequest={[Function]}
|
|
108
102
|
cancellable={false}
|
|
109
103
|
dynflowEnableConsole={true}
|
|
110
|
-
endedAt=""
|
|
111
|
-
errors={Array []}
|
|
112
104
|
externalId=""
|
|
105
|
+
forceCancelTaskRequest={[Function]}
|
|
113
106
|
hasSubTasks={true}
|
|
114
|
-
help=""
|
|
115
107
|
id="test"
|
|
116
|
-
output=""
|
|
117
108
|
parentTask="parent-id"
|
|
118
|
-
progress={0}
|
|
119
|
-
result="error"
|
|
120
109
|
resumable={false}
|
|
121
110
|
resumeTaskRequest={[Function]}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
startedAt=""
|
|
111
|
+
setForceUnlockModalOpen={[Function]}
|
|
112
|
+
setUnlockModalOpen={[Function]}
|
|
125
113
|
state="paused"
|
|
126
114
|
status="RESOLVED"
|
|
127
115
|
taskProgressToggle={[MockFunction]}
|
|
128
116
|
taskReload={true}
|
|
129
117
|
taskReloadStart={[MockFunction]}
|
|
130
|
-
|
|
131
|
-
usernamePath=""
|
|
118
|
+
unlockTaskRequest={[Function]}
|
|
132
119
|
/>
|
|
133
120
|
</Row>
|
|
134
121
|
<TaskInfo
|
|
135
122
|
action=""
|
|
136
123
|
canEdit={true}
|
|
137
|
-
cancelTaskRequest={[Function]}
|
|
138
|
-
cancellable={false}
|
|
139
124
|
dynflowEnableConsole={true}
|
|
140
125
|
endedAt=""
|
|
141
126
|
errors={Array []}
|
|
142
|
-
|
|
127
|
+
forceCancelTaskRequest={[Function]}
|
|
143
128
|
hasSubTasks={true}
|
|
144
129
|
help=""
|
|
145
130
|
id="test"
|
|
@@ -147,8 +132,6 @@ exports[`Task rendering render with some Props 1`] = `
|
|
|
147
132
|
parentTask="parent-id"
|
|
148
133
|
progress={0}
|
|
149
134
|
result="error"
|
|
150
|
-
resumable={false}
|
|
151
|
-
resumeTaskRequest={[Function]}
|
|
152
135
|
startAt=""
|
|
153
136
|
startBefore=""
|
|
154
137
|
startedAt=""
|
|
@@ -157,6 +140,7 @@ exports[`Task rendering render with some Props 1`] = `
|
|
|
157
140
|
taskProgressToggle={[MockFunction]}
|
|
158
141
|
taskReload={true}
|
|
159
142
|
taskReloadStart={[MockFunction]}
|
|
143
|
+
unlockTaskRequest={[Function]}
|
|
160
144
|
username=""
|
|
161
145
|
usernamePath=""
|
|
162
146
|
/>
|
data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap
CHANGED
|
@@ -89,34 +89,20 @@ exports[`TaskDetails rendering render with min Props 1`] = `
|
|
|
89
89
|
>
|
|
90
90
|
<Task
|
|
91
91
|
action=""
|
|
92
|
-
canEdit={false}
|
|
93
|
-
cancelTaskRequest={[Function]}
|
|
94
|
-
cancellable={false}
|
|
95
|
-
dynflowEnableConsole={false}
|
|
96
92
|
endedAt=""
|
|
97
|
-
errors={Array []}
|
|
98
93
|
externalId=""
|
|
99
|
-
|
|
100
|
-
help=""
|
|
94
|
+
forceCancelTaskRequest={[Function]}
|
|
101
95
|
id="a15dd820-32f1-4ced-9ab7-c0fab8234c47"
|
|
102
96
|
input={Array []}
|
|
103
97
|
label=""
|
|
104
98
|
output={Object {}}
|
|
105
|
-
parentTask=""
|
|
106
|
-
progress={0}
|
|
107
|
-
result="error"
|
|
108
99
|
resumable={false}
|
|
109
|
-
resumeTaskRequest={[Function]}
|
|
110
|
-
startAt=""
|
|
111
|
-
startBefore=""
|
|
112
100
|
startedAt=""
|
|
113
|
-
state=""
|
|
114
101
|
status="RESOLVED"
|
|
115
102
|
taskProgressToggle={[Function]}
|
|
116
103
|
taskReload={false}
|
|
117
104
|
taskReloadStart={[MockFunction]}
|
|
118
|
-
|
|
119
|
-
usernamePath=""
|
|
105
|
+
unlockTaskRequest={[Function]}
|
|
120
106
|
/>
|
|
121
107
|
</Tab>
|
|
122
108
|
<Tab
|