foreman_webhooks 6.0.0 → 6.0.1
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/db/seeds.d/62_shellhooks_proxy_feature.rb +1 -1
- data/lib/foreman_webhooks/version.rb +1 -1
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js +2 -1
- data/webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageSelectors.test.js +121 -16
- metadata +2 -3
- data/webpack/ForemanWebhooks/Routes/Webhooks/__tests__/__snapshots__/WebhooksPageSelectors.test.js.snap +0 -50
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2504e406a10a1be7d18fe058224497d23d5888a67c73c3a37a79a3c60d14b91d
|
|
4
|
+
data.tar.gz: f558a5e1d7f670ba489dea28d371c7ddd71a604131ffe0b50206286899794e5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c31f081144dad2899b5b54f9eb6dd7fc04a8314ba684b82925856771d80449872c859e399015c5daaa542d0a743cbe44741d11251b8d1318f1fbed034140453
|
|
7
|
+
data.tar.gz: a18a91b96ddf51b0989c85fe74a9285c0e4a341253bcdc88ea152bbef3e8cce500dfc5c00f62d8b3fe9765f3e4e4464d59339b939df183d78d7ca418f355485f
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
proxy_feature = Feature.where(name: 'Shellhooks').first_or_create
|
|
4
4
|
return unless proxy_feature.nil? || proxy_feature.errors.any?
|
|
5
5
|
|
|
6
|
-
raise "Unable to create proxy feature: #{format_errors
|
|
6
|
+
raise "Unable to create proxy feature: #{SeedHelper.format_errors(proxy_feature)}"
|
|
@@ -38,9 +38,10 @@ export const queryParams = {
|
|
|
38
38
|
...querySort,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const stateFactory = state => ({
|
|
41
|
+
export const stateFactory = (state = {}, { status } = {}) => ({
|
|
42
42
|
API: {
|
|
43
43
|
[WEBHOOKS_API_REQUEST_KEY]: {
|
|
44
|
+
...(status !== undefined && { status }),
|
|
44
45
|
response: {
|
|
45
46
|
...stateParams,
|
|
46
47
|
...state,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { STATUS } from 'foremanReact/constants';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
selectWebhooks,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
selectIsLoading,
|
|
12
12
|
selectSubtotal,
|
|
13
13
|
selectMessage,
|
|
14
|
+
selectCanCreate,
|
|
14
15
|
} from '../WebhooksPageSelectors';
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -18,28 +19,132 @@ import {
|
|
|
18
19
|
webhooks,
|
|
19
20
|
} from '../WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures';
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
+
const populatedState = stateFactory({
|
|
22
23
|
results: webhooks,
|
|
23
24
|
sort: { by: 'name', order: 'DESC' },
|
|
24
25
|
page: 1,
|
|
25
26
|
perPage: 1,
|
|
26
27
|
search: 'name ~ foo',
|
|
27
28
|
subtotal: 42,
|
|
28
|
-
|
|
29
|
+
canCreate: true,
|
|
30
|
+
message: { type: 'info', text: 'Saved successfully' },
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const resolvedState = stateFactory(
|
|
34
|
+
{ results: webhooks, subtotal: webhooks.length },
|
|
35
|
+
{ status: STATUS.RESOLVED }
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const pendingState = stateFactory({ results: [] }, { status: STATUS.PENDING });
|
|
39
|
+
|
|
40
|
+
const errorState = {
|
|
41
|
+
API: {
|
|
42
|
+
webhooks: {
|
|
43
|
+
status: STATUS.ERROR,
|
|
44
|
+
response: {
|
|
45
|
+
message: 'Request failed with status code 500',
|
|
46
|
+
response: {
|
|
47
|
+
data: { error: { message: 'Unable to load webhooks' } },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
42
52
|
};
|
|
43
53
|
|
|
44
|
-
describe('WebhooksPage selectors', () =>
|
|
45
|
-
|
|
54
|
+
describe('WebhooksPage selectors', () => {
|
|
55
|
+
it('returns webhooks from the API response', () => {
|
|
56
|
+
expect(selectWebhooks(populatedState)).toEqual(webhooks);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('returns page from the API response', () => {
|
|
60
|
+
expect(selectPage(populatedState)).toBe(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('returns perPage from the API response', () => {
|
|
64
|
+
expect(selectPerPage(populatedState)).toBe(1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns search from the API response', () => {
|
|
68
|
+
expect(selectSearch(populatedState)).toBe('name ~ foo');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('returns sort with camelCased column name', () => {
|
|
72
|
+
expect(selectSort(populatedState)).toEqual({ by: 'name', order: 'DESC' });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('camelCases snake_case sort column names', () => {
|
|
76
|
+
const state = stateFactory({
|
|
77
|
+
sort: { by: 'target_url', order: 'ASC' },
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(selectSort(state)).toEqual({ by: 'targetUrl', order: 'ASC' });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('returns hasData as false when the API request is not resolved', () => {
|
|
84
|
+
expect(selectHasData(populatedState)).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('returns hasData as true when the API request is resolved with results', () => {
|
|
88
|
+
expect(selectHasData(resolvedState)).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns hasError as false for a successful API response', () => {
|
|
92
|
+
expect(selectHasError(populatedState)).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('returns hasError as true when the API request failed', () => {
|
|
96
|
+
expect(selectHasError(errorState)).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('returns isLoading as true when the API status is missing or pending', () => {
|
|
100
|
+
expect(selectIsLoading(populatedState)).toBe(true);
|
|
101
|
+
expect(selectIsLoading(pendingState)).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('returns isLoading as false when the API request is resolved', () => {
|
|
105
|
+
expect(selectIsLoading(resolvedState)).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('returns subtotal from the API response', () => {
|
|
109
|
+
expect(selectSubtotal(populatedState)).toBe(42);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('returns message from the API response when there is no error', () => {
|
|
113
|
+
expect(selectMessage(populatedState)).toEqual({
|
|
114
|
+
type: 'info',
|
|
115
|
+
text: 'Saved successfully',
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('returns an error message from the API when the request failed', () => {
|
|
120
|
+
expect(selectMessage(errorState)).toEqual({
|
|
121
|
+
type: 'error',
|
|
122
|
+
text: 'Unable to load webhooks',
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('returns an empty webhook list when the API request failed', () => {
|
|
127
|
+
expect(selectWebhooks(errorState)).toEqual([]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('returns canCreate from the API response', () => {
|
|
131
|
+
expect(selectCanCreate(populatedState)).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('returns default pagination values when the API response is empty', () => {
|
|
135
|
+
const emptyState = {
|
|
136
|
+
API: {
|
|
137
|
+
webhooks: {
|
|
138
|
+
status: STATUS.RESOLVED,
|
|
139
|
+
response: {},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
expect(selectPage(emptyState)).toBe(1);
|
|
145
|
+
expect(selectPerPage(emptyState)).toBe(20);
|
|
146
|
+
expect(selectWebhooks(emptyState)).toEqual([]);
|
|
147
|
+
expect(selectSubtotal(emptyState)).toBe(0);
|
|
148
|
+
expect(selectCanCreate(emptyState)).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
});
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_webhooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Timo Goebel
|
|
@@ -168,7 +168,6 @@ files:
|
|
|
168
168
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageSelectors.js
|
|
169
169
|
- webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageHelpers.test.js
|
|
170
170
|
- webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageSelectors.test.js
|
|
171
|
-
- webpack/ForemanWebhooks/Routes/Webhooks/__tests__/__snapshots__/WebhooksPageSelectors.test.js.snap
|
|
172
171
|
- webpack/ForemanWebhooks/Routes/Webhooks/constants.js
|
|
173
172
|
- webpack/index.js
|
|
174
173
|
- webpack/routes_index.js
|
|
@@ -195,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
195
194
|
- !ruby/object:Gem::Version
|
|
196
195
|
version: '0'
|
|
197
196
|
requirements: []
|
|
198
|
-
rubygems_version: 4.0.
|
|
197
|
+
rubygems_version: 4.0.20
|
|
199
198
|
specification_version: 4
|
|
200
199
|
summary: Configure webhooks for Foreman.
|
|
201
200
|
test_files:
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`WebhooksPage selectors should return hasData 1`] = `false`;
|
|
4
|
-
|
|
5
|
-
exports[`WebhooksPage selectors should return hasError 1`] = `false`;
|
|
6
|
-
|
|
7
|
-
exports[`WebhooksPage selectors should return isLoading 1`] = `true`;
|
|
8
|
-
|
|
9
|
-
exports[`WebhooksPage selectors should return message 1`] = `
|
|
10
|
-
Object {
|
|
11
|
-
"text": "This is error",
|
|
12
|
-
"type": "error",
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
exports[`WebhooksPage selectors should return page 1`] = `1`;
|
|
17
|
-
|
|
18
|
-
exports[`WebhooksPage selectors should return perPage 1`] = `1`;
|
|
19
|
-
|
|
20
|
-
exports[`WebhooksPage selectors should return search 1`] = `"name ~ foo"`;
|
|
21
|
-
|
|
22
|
-
exports[`WebhooksPage selectors should return sort 1`] = `
|
|
23
|
-
Object {
|
|
24
|
-
"by": "name",
|
|
25
|
-
"order": "DESC",
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
exports[`WebhooksPage selectors should return subtotal 1`] = `42`;
|
|
30
|
-
|
|
31
|
-
exports[`WebhooksPage selectors should return webhooks 1`] = `
|
|
32
|
-
Array [
|
|
33
|
-
Object {
|
|
34
|
-
"canDelete": true,
|
|
35
|
-
"canEdit": true,
|
|
36
|
-
"enabled": true,
|
|
37
|
-
"id": 1,
|
|
38
|
-
"name": "my-webhook",
|
|
39
|
-
"targetUrl": "https://my-machine.example.com",
|
|
40
|
-
},
|
|
41
|
-
Object {
|
|
42
|
-
"canDelete": false,
|
|
43
|
-
"canEdit": false,
|
|
44
|
-
"enabled": false,
|
|
45
|
-
"id": 2,
|
|
46
|
-
"name": "your-webhook",
|
|
47
|
-
"targetUrl": "https://your-machine.example.com",
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
`;
|