foreman-tasks 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/foreman_tasks/tasks.css.scss +3 -3
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +50 -30
- data/app/controllers/foreman_tasks/tasks_controller.rb +8 -17
- data/app/models/foreman_tasks/task.rb +6 -4
- data/app/models/foreman_tasks/task/search.rb +0 -25
- data/app/models/setting/foreman_tasks.rb +19 -23
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -0
- data/app/views/foreman_tasks/layouts/react.html.erb +4 -1
- data/config/routes.rb +17 -3
- data/db/migrate/20180927120509_add_user_id.foreman_tasks.rb +4 -2
- data/lib/foreman_tasks/dynflow.rb +1 -1
- data/lib/foreman_tasks/dynflow/console_authorizer.rb +13 -2
- data/lib/foreman_tasks/engine.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/package.json +1 -0
- data/test/controllers/tasks_controller_test.rb +35 -4
- data/test/unit/dynflow_console_authorizer_test.rb +1 -1
- data/test/unit/otp_manager_test.rb +24 -17
- data/test/unit/task_test.rb +48 -2
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +29 -16
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskHelper.js +3 -17
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +18 -5
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskHelper.test.js +1 -56
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +24 -44
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +22 -10
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +6 -0
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.js +6 -3
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +2 -3
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +10 -41
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardReducer.js +0 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardReducer.test.js.snap +1 -6
- data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +30 -0
- data/webpack/ForemanTasks/Components/TasksTable/TaskTableFormmatters.js +53 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksIndexPage.js +10 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +119 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +67 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +5 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +64 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +63 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +29 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +35 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +67 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +39 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +20 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +12 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +42 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +9 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +48 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +28 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +26 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +37 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +49 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +42 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTable.test.js.snap +72 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +115 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +194 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +32 -0
- data/webpack/ForemanTasks/Components/TasksTable/index.js +32 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +39 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +45 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +23 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +27 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +23 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +27 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +28 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +15 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +15 -0
- data/webpack/ForemanTasks/ForemanTasks.js +1 -17
- data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
- data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +5 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.js +9 -3
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +5 -1
- data/webpack/ForemanTasks/Routes/__snapshots__/ForemanTasksRoutes.test.js.snap +18 -2
- data/webpack/ForemanTasks/__snapshots__/ForemanTasks.test.js.snap +1 -54
- data/webpack/__mocks__/foremanReact/common/helpers.js +1 -0
- data/webpack/__mocks__/foremanReact/common/urlHelpers.js +1 -0
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/MessageBox.js +4 -0
- data/webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js +5 -0
- data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +3 -0
- data/webpack/__mocks__/foremanReact/components/common/table.js +4 -0
- data/webpack/__mocks__/foremanReact/components/common/table/actionsHelpers/actionTypeCreator.js +7 -0
- data/webpack/__mocks__/foremanReact/constants.js +24 -0
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js +5 -0
- data/webpack/index.js +5 -0
- metadata +49 -9
- data/app/views/foreman_tasks/tasks/index.html.erb +0 -46
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskHelper.test.js.snap +0 -37
- data/webpack/ForemanTasks/Routes/IndexTasks/IndexTasks.js +0 -10
- data/webpack/ForemanTasks/Routes/IndexTasks/__tests__/IndexTasks.test.js +0 -10
- data/webpack/ForemanTasks/Routes/IndexTasks/__tests__/__snapshots__/IndexTasks.test.js.snap +0 -12
- data/webpack/ForemanTasks/Routes/IndexTasks/index.js +0 -1
- data/webpack/ForemanTasks/Routes/IndexTasks/indexTasks.scss +0 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import TasksTable from '../TasksTable';
|
3
|
+
import fixtures from './TasksTable.fixtures';
|
4
|
+
|
5
|
+
jest.mock('../TasksTableSchema');
|
6
|
+
describe('TasksTable', () => {
|
7
|
+
describe('rendering', () =>
|
8
|
+
testComponentSnapshotsWithFixtures(TasksTable, fixtures));
|
9
|
+
});
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import API from 'foremanReact/API';
|
3
|
+
import { TASKS_TABLE_ID } from '../TasksTableConstants';
|
4
|
+
import {
|
5
|
+
getTableItems,
|
6
|
+
cancelTask,
|
7
|
+
cancelTaskRequest,
|
8
|
+
resumeTask,
|
9
|
+
resumeTaskRequest,
|
10
|
+
} from '../TasksTableActions';
|
11
|
+
|
12
|
+
jest.mock('foremanReact/components/common/table', () => ({
|
13
|
+
getTableItemsAction: jest.fn(controller => controller),
|
14
|
+
}));
|
15
|
+
|
16
|
+
jest.mock('foremanReact/API');
|
17
|
+
|
18
|
+
API.post.mockImplementation(() => ({ data: 'some-data' }));
|
19
|
+
|
20
|
+
const fixtures = {
|
21
|
+
'should cancelTask': () => cancelTask('some-id', 'some-name', 'some-url'),
|
22
|
+
'should cancelTaskRequest and succeed': () =>
|
23
|
+
cancelTaskRequest('some-id', 'some-name', 'some-url'),
|
24
|
+
'should cancelTaskRequest and fail': () => {
|
25
|
+
API.post.mockImplementation(() =>
|
26
|
+
Promise.reject(new Error('Network Error'))
|
27
|
+
);
|
28
|
+
return cancelTaskRequest('some-id', 'some-name');
|
29
|
+
},
|
30
|
+
|
31
|
+
'should resumeTask': () => resumeTask('some-id', 'some-name', 'some-url'),
|
32
|
+
'should resumeTaskRequest and succeed': () => {
|
33
|
+
API.post.mockImplementation(() => ({ data: 'some-data' }));
|
34
|
+
return resumeTaskRequest('some-id', 'some-name', 'some-url');
|
35
|
+
},
|
36
|
+
'should resumeTaskRequest and fail': () => {
|
37
|
+
API.post.mockImplementation(() =>
|
38
|
+
Promise.reject(new Error('Network Error'))
|
39
|
+
);
|
40
|
+
return resumeTaskRequest('some-id', 'some-name', 'some-url');
|
41
|
+
},
|
42
|
+
};
|
43
|
+
describe('TasksTable actions', () => {
|
44
|
+
it('getTableItems should reuse common/table/getTableItemsAction', () => {
|
45
|
+
expect(getTableItems('')).toEqual(TASKS_TABLE_ID);
|
46
|
+
});
|
47
|
+
testActionSnapshotWithFixtures(fixtures);
|
48
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { updateURlQuery, getDuration } from '../TasksTableHelpers';
|
2
|
+
|
3
|
+
describe('updateURlQuery', () => {
|
4
|
+
it('should use url with new query', () => {
|
5
|
+
const history = {
|
6
|
+
push: jest.fn(),
|
7
|
+
location: {
|
8
|
+
pathname:
|
9
|
+
'/foreman_tasks/tasks/?state=stopped&result=error&page=1&per_page=20',
|
10
|
+
},
|
11
|
+
};
|
12
|
+
const query = { time_mode: 'recent', per_page: 35 };
|
13
|
+
updateURlQuery(query, history);
|
14
|
+
const newURL =
|
15
|
+
'?state=stopped&result=error&page=1&per_page=35&time_mode=recent';
|
16
|
+
expect(history.push).toBeCalledWith(newURL);
|
17
|
+
});
|
18
|
+
it('getDuration should work', () => {
|
19
|
+
const duration = getDuration('1/1/2000 11:00', '1/1/2000 11:25');
|
20
|
+
expect(duration.text).toEqual('25 minutes');
|
21
|
+
expect(duration.tooltip).toEqual(undefined);
|
22
|
+
});
|
23
|
+
it('getDuration should work without start date', () => {
|
24
|
+
const duration = getDuration('', '1/1/2000 11:25');
|
25
|
+
expect(duration.text).toEqual('N/A');
|
26
|
+
expect(duration.tooltip).toEqual('Task was canceled');
|
27
|
+
});
|
28
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import TasksTablePage from '../TasksTablePage';
|
3
|
+
import { minProps } from './TasksTable.fixtures';
|
4
|
+
|
5
|
+
const fixtures = {
|
6
|
+
'render with minimal props': minProps,
|
7
|
+
|
8
|
+
'render with Breadcrubs': {
|
9
|
+
...minProps,
|
10
|
+
getBreadcrumbs: () => ({
|
11
|
+
breadcrumbItems: [
|
12
|
+
{ caption: 'Tasks', url: `/foreman_tasks/tasks` },
|
13
|
+
{
|
14
|
+
caption: 'action Name',
|
15
|
+
url: `/foreman_tasks/tasks/someid`,
|
16
|
+
},
|
17
|
+
{ caption: 'Sub tasks' },
|
18
|
+
],
|
19
|
+
}),
|
20
|
+
},
|
21
|
+
};
|
22
|
+
|
23
|
+
describe('TasksTablePage', () => {
|
24
|
+
describe('rendering', () =>
|
25
|
+
testComponentSnapshotsWithFixtures(TasksTablePage, fixtures));
|
26
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import {
|
3
|
+
TASKS_TABLE_ID,
|
4
|
+
TASKS_TABLE_SET_SORT,
|
5
|
+
TASKS_TABLE_SET_PAGINATION,
|
6
|
+
} from '../TasksTableConstants';
|
7
|
+
import reducer from '../TasksTableReducer';
|
8
|
+
|
9
|
+
const fixtures = {
|
10
|
+
'should return the initial state': {},
|
11
|
+
'should handle TASKS_TABLE_SUCCESS': {
|
12
|
+
action: {
|
13
|
+
type: `${TASKS_TABLE_ID}_SUCCESS`,
|
14
|
+
payload: {
|
15
|
+
subtotal: 120,
|
16
|
+
page: 3,
|
17
|
+
per_page: 12,
|
18
|
+
},
|
19
|
+
},
|
20
|
+
},
|
21
|
+
'should handle TASKS_TABLE_SET_SORT': {
|
22
|
+
action: {
|
23
|
+
type: TASKS_TABLE_SET_SORT,
|
24
|
+
payload: { by: 'a', order: 'b' },
|
25
|
+
},
|
26
|
+
},
|
27
|
+
|
28
|
+
'should handle TASKS_TABLE_SET_PAGINATION': {
|
29
|
+
action: {
|
30
|
+
type: TASKS_TABLE_SET_PAGINATION,
|
31
|
+
payload: { page: 4, perPage: 7 },
|
32
|
+
},
|
33
|
+
},
|
34
|
+
};
|
35
|
+
|
36
|
+
describe('TasksTablePaginationReducer reducer', () =>
|
37
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SubTasksPage rendering render with minimal props 1`] = `
|
4
|
+
<Connect(TasksTablePage)
|
5
|
+
cancelTask={[MockFunction]}
|
6
|
+
getBreadcrumbs={[MockFunction]}
|
7
|
+
getTableItems={[MockFunction]}
|
8
|
+
history={
|
9
|
+
Object {
|
10
|
+
"location": Object {
|
11
|
+
"search": "",
|
12
|
+
},
|
13
|
+
}
|
14
|
+
}
|
15
|
+
itemCount={2}
|
16
|
+
location={
|
17
|
+
Object {
|
18
|
+
"pathname": "",
|
19
|
+
}
|
20
|
+
}
|
21
|
+
match={
|
22
|
+
Object {
|
23
|
+
"params": Object {
|
24
|
+
"id": "some-id",
|
25
|
+
},
|
26
|
+
}
|
27
|
+
}
|
28
|
+
pagination={
|
29
|
+
Object {
|
30
|
+
"page": 1,
|
31
|
+
"perPage": 10,
|
32
|
+
}
|
33
|
+
}
|
34
|
+
results={
|
35
|
+
Array [
|
36
|
+
"a",
|
37
|
+
"b",
|
38
|
+
]
|
39
|
+
}
|
40
|
+
resumeTask={[MockFunction]}
|
41
|
+
sort={
|
42
|
+
Object {
|
43
|
+
"by": "q",
|
44
|
+
"order": "w",
|
45
|
+
}
|
46
|
+
}
|
47
|
+
status="RESOLVED"
|
48
|
+
/>
|
49
|
+
`;
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksIndexPage rendering render with minimal props 1`] = `
|
4
|
+
<Connect(TasksTablePage)
|
5
|
+
cancelTask={[MockFunction]}
|
6
|
+
getBreadcrumbs={[MockFunction]}
|
7
|
+
getTableItems={[MockFunction]}
|
8
|
+
history={
|
9
|
+
Object {
|
10
|
+
"location": Object {
|
11
|
+
"search": "",
|
12
|
+
},
|
13
|
+
}
|
14
|
+
}
|
15
|
+
itemCount={2}
|
16
|
+
location={
|
17
|
+
Object {
|
18
|
+
"pathname": "",
|
19
|
+
}
|
20
|
+
}
|
21
|
+
pagination={
|
22
|
+
Object {
|
23
|
+
"page": 1,
|
24
|
+
"perPage": 10,
|
25
|
+
}
|
26
|
+
}
|
27
|
+
results={
|
28
|
+
Array [
|
29
|
+
"a",
|
30
|
+
"b",
|
31
|
+
]
|
32
|
+
}
|
33
|
+
resumeTask={[MockFunction]}
|
34
|
+
sort={
|
35
|
+
Object {
|
36
|
+
"by": "q",
|
37
|
+
"order": "w",
|
38
|
+
}
|
39
|
+
}
|
40
|
+
status="RESOLVED"
|
41
|
+
/>
|
42
|
+
`;
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTable.test.js.snap
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksTable rendering render with error Props 1`] = `
|
4
|
+
<MessageBox
|
5
|
+
icontype="error-circle-o"
|
6
|
+
key="tasks-table-error"
|
7
|
+
msg="Could not receive data: null"
|
8
|
+
/>
|
9
|
+
`;
|
10
|
+
|
11
|
+
exports[`TasksTable rendering render with loading Props 1`] = `
|
12
|
+
<div
|
13
|
+
className="tasks-table"
|
14
|
+
>
|
15
|
+
<Table
|
16
|
+
key="tasks-table"
|
17
|
+
rows={
|
18
|
+
Array [
|
19
|
+
"a",
|
20
|
+
]
|
21
|
+
}
|
22
|
+
/>
|
23
|
+
<PaginationWrapper
|
24
|
+
className="tasks-pagination"
|
25
|
+
dropdownButtonId="tasks-table-dropdown"
|
26
|
+
itemCount={2}
|
27
|
+
onChange={[Function]}
|
28
|
+
pagination={
|
29
|
+
Object {
|
30
|
+
"page": 1,
|
31
|
+
"perPage": 10,
|
32
|
+
}
|
33
|
+
}
|
34
|
+
viewType="table"
|
35
|
+
/>
|
36
|
+
</div>
|
37
|
+
`;
|
38
|
+
|
39
|
+
exports[`TasksTable rendering render with minimal Props 1`] = `
|
40
|
+
<div
|
41
|
+
className="tasks-table"
|
42
|
+
>
|
43
|
+
<Table
|
44
|
+
key="tasks-table"
|
45
|
+
rows={
|
46
|
+
Array [
|
47
|
+
"a",
|
48
|
+
"b",
|
49
|
+
]
|
50
|
+
}
|
51
|
+
/>
|
52
|
+
<PaginationWrapper
|
53
|
+
className="tasks-pagination"
|
54
|
+
dropdownButtonId="tasks-table-dropdown"
|
55
|
+
itemCount={2}
|
56
|
+
onChange={[Function]}
|
57
|
+
pagination={
|
58
|
+
Object {
|
59
|
+
"page": 1,
|
60
|
+
"perPage": 10,
|
61
|
+
}
|
62
|
+
}
|
63
|
+
viewType="table"
|
64
|
+
/>
|
65
|
+
</div>
|
66
|
+
`;
|
67
|
+
|
68
|
+
exports[`TasksTable rendering render with no results 1`] = `
|
69
|
+
<span>
|
70
|
+
No Tasks
|
71
|
+
</span>
|
72
|
+
`;
|
@@ -0,0 +1,115 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksTable actions should cancelTaskRequest and fail 1`] = `
|
4
|
+
Array [
|
5
|
+
Array [
|
6
|
+
Object {
|
7
|
+
"payload": Object {
|
8
|
+
"message": Object {
|
9
|
+
"message": "Trying to cancel \\"some-name\\" task",
|
10
|
+
"type": "info",
|
11
|
+
},
|
12
|
+
},
|
13
|
+
"type": "TOASTS_ADD",
|
14
|
+
},
|
15
|
+
],
|
16
|
+
Array [
|
17
|
+
Object {
|
18
|
+
"payload": Object {
|
19
|
+
"message": Object {
|
20
|
+
"message": "\\"some-name\\" task cannot be cancelled at the moment.",
|
21
|
+
"type": "error",
|
22
|
+
},
|
23
|
+
},
|
24
|
+
"type": "TOASTS_ADD",
|
25
|
+
},
|
26
|
+
],
|
27
|
+
]
|
28
|
+
`;
|
29
|
+
|
30
|
+
exports[`TasksTable actions should cancelTaskRequest and succeed 1`] = `
|
31
|
+
Array [
|
32
|
+
Array [
|
33
|
+
Object {
|
34
|
+
"payload": Object {
|
35
|
+
"message": Object {
|
36
|
+
"message": "Trying to cancel \\"some-name\\" task",
|
37
|
+
"type": "info",
|
38
|
+
},
|
39
|
+
},
|
40
|
+
"type": "TOASTS_ADD",
|
41
|
+
},
|
42
|
+
],
|
43
|
+
Array [
|
44
|
+
Object {
|
45
|
+
"payload": Object {
|
46
|
+
"message": Object {
|
47
|
+
"message": "\\"some-name\\" task cancelled",
|
48
|
+
"type": "success",
|
49
|
+
},
|
50
|
+
},
|
51
|
+
"type": "TOASTS_ADD",
|
52
|
+
},
|
53
|
+
],
|
54
|
+
]
|
55
|
+
`;
|
56
|
+
|
57
|
+
exports[`TasksTable actions should cancelTask 1`] = `
|
58
|
+
Array [
|
59
|
+
Array [
|
60
|
+
[Function],
|
61
|
+
],
|
62
|
+
Array [
|
63
|
+
"TASKS_TABLE",
|
64
|
+
],
|
65
|
+
Array [
|
66
|
+
[Function],
|
67
|
+
],
|
68
|
+
]
|
69
|
+
`;
|
70
|
+
|
71
|
+
exports[`TasksTable actions should resumeTaskRequest and fail 1`] = `
|
72
|
+
Array [
|
73
|
+
Array [
|
74
|
+
Object {
|
75
|
+
"payload": Object {
|
76
|
+
"message": Object {
|
77
|
+
"message": "Task \\"some-name\\" has to be resumable.",
|
78
|
+
"type": "error",
|
79
|
+
},
|
80
|
+
},
|
81
|
+
"type": "TOASTS_ADD",
|
82
|
+
},
|
83
|
+
],
|
84
|
+
]
|
85
|
+
`;
|
86
|
+
|
87
|
+
exports[`TasksTable actions should resumeTaskRequest and succeed 1`] = `
|
88
|
+
Array [
|
89
|
+
Array [
|
90
|
+
Object {
|
91
|
+
"payload": Object {
|
92
|
+
"message": Object {
|
93
|
+
"message": "\\"some-name\\" Task execution was resumed",
|
94
|
+
"type": "success",
|
95
|
+
},
|
96
|
+
},
|
97
|
+
"type": "TOASTS_ADD",
|
98
|
+
},
|
99
|
+
],
|
100
|
+
]
|
101
|
+
`;
|
102
|
+
|
103
|
+
exports[`TasksTable actions should resumeTask 1`] = `
|
104
|
+
Array [
|
105
|
+
Array [
|
106
|
+
[Function],
|
107
|
+
],
|
108
|
+
Array [
|
109
|
+
"TASKS_TABLE",
|
110
|
+
],
|
111
|
+
Array [
|
112
|
+
[Function],
|
113
|
+
],
|
114
|
+
]
|
115
|
+
`;
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksTablePage rendering render with Breadcrubs 1`] = `
|
4
|
+
<div
|
5
|
+
className="tasks-table-wrapper"
|
6
|
+
>
|
7
|
+
<PageLayout
|
8
|
+
beforeToolbarComponent={
|
9
|
+
<Connect(TasksDashboard)
|
10
|
+
history={
|
11
|
+
Object {
|
12
|
+
"location": Object {
|
13
|
+
"search": "",
|
14
|
+
},
|
15
|
+
}
|
16
|
+
}
|
17
|
+
/>
|
18
|
+
}
|
19
|
+
breadcrumbOptions={
|
20
|
+
Object {
|
21
|
+
"breadcrumbItems": Array [
|
22
|
+
Object {
|
23
|
+
"caption": "Tasks",
|
24
|
+
"url": "/foreman_tasks/tasks",
|
25
|
+
},
|
26
|
+
Object {
|
27
|
+
"caption": "action Name",
|
28
|
+
"url": "/foreman_tasks/tasks/someid",
|
29
|
+
},
|
30
|
+
Object {
|
31
|
+
"caption": "Sub tasks",
|
32
|
+
},
|
33
|
+
],
|
34
|
+
}
|
35
|
+
}
|
36
|
+
onSearch={[Function]}
|
37
|
+
searchProps={
|
38
|
+
Object {
|
39
|
+
"autocomplete": Object {
|
40
|
+
"id": "searchBar",
|
41
|
+
"searchQuery": "",
|
42
|
+
"url": "tasks/auto_complete_search",
|
43
|
+
"useKeyShortcuts": true,
|
44
|
+
},
|
45
|
+
"bookmarks": Object {
|
46
|
+
"canCreateBookmarks": true,
|
47
|
+
"documentationUrl": "4.1.5Searching",
|
48
|
+
"url": "/api/bookmarks",
|
49
|
+
},
|
50
|
+
"controller": "tasks",
|
51
|
+
}
|
52
|
+
}
|
53
|
+
searchQuery="a=b"
|
54
|
+
searchable={true}
|
55
|
+
toastNotifications="foreman-tasks-cancel"
|
56
|
+
toolbarButtons={
|
57
|
+
<React.Fragment>
|
58
|
+
<ExportButton
|
59
|
+
url="/foreman_tasks/tasks.csv?include_permissions=true"
|
60
|
+
/>
|
61
|
+
</React.Fragment>
|
62
|
+
}
|
63
|
+
>
|
64
|
+
<TasksTable
|
65
|
+
actionName=""
|
66
|
+
cancelTask={[MockFunction]}
|
67
|
+
error={null}
|
68
|
+
getTableItems={[MockFunction]}
|
69
|
+
history={
|
70
|
+
Object {
|
71
|
+
"location": Object {
|
72
|
+
"search": "",
|
73
|
+
},
|
74
|
+
}
|
75
|
+
}
|
76
|
+
isSubTask={false}
|
77
|
+
itemCount={2}
|
78
|
+
location={
|
79
|
+
Object {
|
80
|
+
"pathname": "",
|
81
|
+
}
|
82
|
+
}
|
83
|
+
pagination={
|
84
|
+
Object {
|
85
|
+
"page": 1,
|
86
|
+
"perPage": 10,
|
87
|
+
}
|
88
|
+
}
|
89
|
+
results={
|
90
|
+
Array [
|
91
|
+
"a",
|
92
|
+
"b",
|
93
|
+
]
|
94
|
+
}
|
95
|
+
resumeTask={[MockFunction]}
|
96
|
+
sort={
|
97
|
+
Object {
|
98
|
+
"by": "q",
|
99
|
+
"order": "w",
|
100
|
+
}
|
101
|
+
}
|
102
|
+
status="RESOLVED"
|
103
|
+
/>
|
104
|
+
</PageLayout>
|
105
|
+
</div>
|
106
|
+
`;
|
107
|
+
|
108
|
+
exports[`TasksTablePage rendering render with minimal props 1`] = `
|
109
|
+
<div
|
110
|
+
className="tasks-table-wrapper"
|
111
|
+
>
|
112
|
+
<PageLayout
|
113
|
+
beforeToolbarComponent={
|
114
|
+
<Connect(TasksDashboard)
|
115
|
+
history={
|
116
|
+
Object {
|
117
|
+
"location": Object {
|
118
|
+
"search": "",
|
119
|
+
},
|
120
|
+
}
|
121
|
+
}
|
122
|
+
/>
|
123
|
+
}
|
124
|
+
onSearch={[Function]}
|
125
|
+
searchProps={
|
126
|
+
Object {
|
127
|
+
"autocomplete": Object {
|
128
|
+
"id": "searchBar",
|
129
|
+
"searchQuery": "",
|
130
|
+
"url": "tasks/auto_complete_search",
|
131
|
+
"useKeyShortcuts": true,
|
132
|
+
},
|
133
|
+
"bookmarks": Object {
|
134
|
+
"canCreateBookmarks": true,
|
135
|
+
"documentationUrl": "4.1.5Searching",
|
136
|
+
"url": "/api/bookmarks",
|
137
|
+
},
|
138
|
+
"controller": "tasks",
|
139
|
+
}
|
140
|
+
}
|
141
|
+
searchQuery="a=b"
|
142
|
+
searchable={true}
|
143
|
+
toastNotifications="foreman-tasks-cancel"
|
144
|
+
toolbarButtons={
|
145
|
+
<React.Fragment>
|
146
|
+
<ExportButton
|
147
|
+
url="/foreman_tasks/tasks.csv?include_permissions=true"
|
148
|
+
/>
|
149
|
+
</React.Fragment>
|
150
|
+
}
|
151
|
+
>
|
152
|
+
<TasksTable
|
153
|
+
actionName=""
|
154
|
+
cancelTask={[MockFunction]}
|
155
|
+
error={null}
|
156
|
+
getTableItems={[MockFunction]}
|
157
|
+
history={
|
158
|
+
Object {
|
159
|
+
"location": Object {
|
160
|
+
"search": "",
|
161
|
+
},
|
162
|
+
}
|
163
|
+
}
|
164
|
+
isSubTask={false}
|
165
|
+
itemCount={2}
|
166
|
+
location={
|
167
|
+
Object {
|
168
|
+
"pathname": "",
|
169
|
+
}
|
170
|
+
}
|
171
|
+
pagination={
|
172
|
+
Object {
|
173
|
+
"page": 1,
|
174
|
+
"perPage": 10,
|
175
|
+
}
|
176
|
+
}
|
177
|
+
results={
|
178
|
+
Array [
|
179
|
+
"a",
|
180
|
+
"b",
|
181
|
+
]
|
182
|
+
}
|
183
|
+
resumeTask={[MockFunction]}
|
184
|
+
sort={
|
185
|
+
Object {
|
186
|
+
"by": "q",
|
187
|
+
"order": "w",
|
188
|
+
}
|
189
|
+
}
|
190
|
+
status="RESOLVED"
|
191
|
+
/>
|
192
|
+
</PageLayout>
|
193
|
+
</div>
|
194
|
+
`;
|