@truedat/bg 6.3.0 → 6.3.2
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.
- package/package.json +6 -6
- package/src/concepts/components/ConceptCreate.js +1 -1
- package/src/taxonomy/api.js +1 -15
- package/src/taxonomy/components/AddDomainMember.js +24 -0
- package/src/taxonomy/components/DomainMembers.js +4 -105
- package/src/taxonomy/components/DomainRoutes.js +4 -4
- package/src/taxonomy/components/__tests__/AddDomainMember.spec.js +12 -0
- package/src/taxonomy/components/__tests__/DomainMembers.spec.js +10 -93
- package/src/taxonomy/components/__tests__/__snapshots__/AddDomainMember.spec.js.snap +170 -0
- package/src/taxonomy/components/__tests__/__snapshots__/DomainMembers.spec.js.snap +37 -111
- package/src/taxonomy/reducers/__tests__/domainRedirect.spec.js +1 -20
- package/src/taxonomy/reducers/domainRedirect.js +1 -15
- package/src/taxonomy/reducers/index.js +0 -10
- package/src/taxonomy/routines.js +0 -9
- package/src/taxonomy/sagas/index.js +0 -15
- package/src/taxonomy/components/AddMember.js +0 -23
- package/src/taxonomy/components/AddMemberForm.js +0 -187
- package/src/taxonomy/components/DomainMember.js +0 -230
- package/src/taxonomy/components/DomainMembersActions.js +0 -32
- package/src/taxonomy/components/ModalOnRoleDeletion.js +0 -77
- package/src/taxonomy/components/__tests__/AddMember.spec.js +0 -10
- package/src/taxonomy/components/__tests__/AddMemberForm.spec.js +0 -78
- package/src/taxonomy/components/__tests__/DomainMember.spec.js +0 -61
- package/src/taxonomy/components/__tests__/__snapshots__/AddMember.spec.js.snap +0 -26
- package/src/taxonomy/components/__tests__/__snapshots__/AddMemberForm.spec.js.snap +0 -187
- package/src/taxonomy/components/__tests__/__snapshots__/DomainMember.spec.js.snap +0 -47
- package/src/taxonomy/reducers/__tests__/domainConceptChildren.spec.js +0 -45
- package/src/taxonomy/reducers/__tests__/domainConceptChildrenLoading.spec.js +0 -38
- package/src/taxonomy/reducers/__tests__/domainMembers.spec.js +0 -33
- package/src/taxonomy/reducers/domainConceptChildren.js +0 -24
- package/src/taxonomy/reducers/domainConceptChildrenLoading.js +0 -16
- package/src/taxonomy/reducers/domainMemberDeleting.js +0 -14
- package/src/taxonomy/reducers/domainMemberSaving.js +0 -12
- package/src/taxonomy/reducers/domainMembers.js +0 -22
- package/src/taxonomy/sagas/__tests__/addDomainMember.spec.js +0 -49
- package/src/taxonomy/sagas/__tests__/fetchDomainConceptChildren.spec.js +0 -105
- package/src/taxonomy/sagas/__tests__/fetchDomainMembers.spec.js +0 -73
- package/src/taxonomy/sagas/__tests__/updateDomainMember.spec.js +0 -81
- package/src/taxonomy/sagas/addDomainMember.js +0 -32
- package/src/taxonomy/sagas/deleteDomainMember.js +0 -29
- package/src/taxonomy/sagas/fetchDomainConceptChildren.js +0 -47
- package/src/taxonomy/sagas/fetchDomainMembers.js +0 -28
- package/src/taxonomy/sagas/updateDomainMember.js +0 -28
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { shallow } from "enzyme";
|
|
3
|
-
import { AddMember } from "../AddMember";
|
|
4
|
-
|
|
5
|
-
describe("<AddMember />", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
7
|
-
const wrapper = shallow(<AddMember />);
|
|
8
|
-
expect(wrapper).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { MemoryRouter } from "react-router-dom";
|
|
3
|
-
import { intl } from "@truedat/test/intl-stub";
|
|
4
|
-
import { render, waitFor } from "@testing-library/react";
|
|
5
|
-
import userEvent from "@testing-library/user-event";
|
|
6
|
-
import { AddMemberForm } from "../AddMemberForm";
|
|
7
|
-
|
|
8
|
-
// workaround for enzyme issue with React.useContext
|
|
9
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
10
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
11
|
-
|
|
12
|
-
describe("<AddMemberForm />", () => {
|
|
13
|
-
const addDomainMember = jest.fn();
|
|
14
|
-
const domain = { id: 1 };
|
|
15
|
-
const options = [
|
|
16
|
-
{ key: 1, text: "john", value: "user_1", id: 1 },
|
|
17
|
-
{ key: 2, text: "mambo", value: "group_2", id: 2 }
|
|
18
|
-
];
|
|
19
|
-
const roles = [
|
|
20
|
-
{ key: 1, text: "role1", value: "role1" },
|
|
21
|
-
{ key: 2, text: "role2", value: "role2" }
|
|
22
|
-
];
|
|
23
|
-
const props = { addDomainMember, domain, options, roles };
|
|
24
|
-
|
|
25
|
-
it("matches the latest snapshot", async () => {
|
|
26
|
-
const { container, findByRole } = render(
|
|
27
|
-
<MemoryRouter>
|
|
28
|
-
<AddMemberForm {...props} />
|
|
29
|
-
</MemoryRouter>
|
|
30
|
-
);
|
|
31
|
-
await findByRole("button", { name: /add_member/ });
|
|
32
|
-
expect(container).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("calls addDomainMember with acl data on submit", async () => {
|
|
36
|
-
const { findByRole, getByRole, findByText } = render(
|
|
37
|
-
<MemoryRouter>
|
|
38
|
-
<AddMemberForm {...props} />
|
|
39
|
-
</MemoryRouter>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Submit button should initially be disabled
|
|
43
|
-
await waitFor(() =>
|
|
44
|
-
expect(getByRole("button", { name: /add_member/ })).toBeDisabled()
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Select principal
|
|
48
|
-
userEvent.click(await findByText(/john/));
|
|
49
|
-
|
|
50
|
-
// Select role
|
|
51
|
-
userEvent.click(await findByRole("textbox", { name: "domain.role" }));
|
|
52
|
-
userEvent.click(await findByRole("option", { name: "role2" }));
|
|
53
|
-
|
|
54
|
-
// Submit button should now be enabled
|
|
55
|
-
await waitFor(() =>
|
|
56
|
-
expect(getByRole("button", { name: /add_member/ })).not.toBeDisabled()
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// Description
|
|
60
|
-
userEvent.type(await findByRole("textbox", { name: /description/ }), "foo");
|
|
61
|
-
|
|
62
|
-
// Submit
|
|
63
|
-
userEvent.click(await findByRole("button", { name: /add_member/ }));
|
|
64
|
-
|
|
65
|
-
await waitFor(() =>
|
|
66
|
-
expect(addDomainMember).toHaveBeenCalledWith({
|
|
67
|
-
resource_id: 1,
|
|
68
|
-
acl_entry: {
|
|
69
|
-
role_name: "role2",
|
|
70
|
-
resource_type: "domain",
|
|
71
|
-
principal_type: "user",
|
|
72
|
-
principal_id: 1,
|
|
73
|
-
description: "foo"
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { waitFor } from "@testing-library/react";
|
|
3
|
-
import { render } from "@truedat/test/render";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
import { DomainMember } from "../DomainMember";
|
|
6
|
-
|
|
7
|
-
describe("<DomainMember />", () => {
|
|
8
|
-
const deleteDomainMember = jest.fn();
|
|
9
|
-
const updateDomainMember = jest.fn();
|
|
10
|
-
const domainMemberDeleting = [];
|
|
11
|
-
const domainConceptChildrenLoading = [];
|
|
12
|
-
const _links = { self: { methods: ["DELETE", "UPDATE"] } };
|
|
13
|
-
const member = {
|
|
14
|
-
user_id: 1,
|
|
15
|
-
role_name: "admin",
|
|
16
|
-
user_name: "user1",
|
|
17
|
-
acl_entry_id: 1,
|
|
18
|
-
domainConceptChildrenLoading,
|
|
19
|
-
updateDomainMember,
|
|
20
|
-
};
|
|
21
|
-
const props = { deleteDomainMember, domainMemberDeleting, _links, ...member };
|
|
22
|
-
|
|
23
|
-
const messages = {
|
|
24
|
-
en: {
|
|
25
|
-
"domain.member.update_description.tooltip": "Update",
|
|
26
|
-
"domain.members.delete": "Delete",
|
|
27
|
-
"domain.members.delete.question": "Delete Question",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
it("matches the latest snapshot", () => {
|
|
32
|
-
const { container } = render(<DomainMember {...props} />, {
|
|
33
|
-
messages,
|
|
34
|
-
});
|
|
35
|
-
expect(container).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("can update acl description", async () => {
|
|
39
|
-
const { container } = render(<DomainMember {...props} />, {
|
|
40
|
-
messages,
|
|
41
|
-
});
|
|
42
|
-
userEvent.click(
|
|
43
|
-
container.querySelector('[class="pencil alternate link icon"]')
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
await waitFor(() => {
|
|
47
|
-
expect(container.querySelector('[name="description"]')).toBeTruthy();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const input = container.querySelector('[name="description"]');
|
|
51
|
-
userEvent.type(input, "foo");
|
|
52
|
-
userEvent.click(container.querySelector('[type="submit"]'));
|
|
53
|
-
|
|
54
|
-
await waitFor(() => {
|
|
55
|
-
expect(updateDomainMember).toBeCalledWith({
|
|
56
|
-
id: 1,
|
|
57
|
-
acl_entry: { description: "foo" },
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<AddMember /> matches the latest snapshot 1`] = `
|
|
4
|
-
<Fragment>
|
|
5
|
-
<Connect(DomainCrumbs) />
|
|
6
|
-
<Container
|
|
7
|
-
as={[Function]}
|
|
8
|
-
text={true}
|
|
9
|
-
>
|
|
10
|
-
<Header
|
|
11
|
-
as="h2"
|
|
12
|
-
>
|
|
13
|
-
<Icon
|
|
14
|
-
as="i"
|
|
15
|
-
name="id card outline"
|
|
16
|
-
/>
|
|
17
|
-
<HeaderContent>
|
|
18
|
-
<MemoizedFormattedMessage
|
|
19
|
-
id="domain.actions.add_member"
|
|
20
|
-
/>
|
|
21
|
-
</HeaderContent>
|
|
22
|
-
</Header>
|
|
23
|
-
<Connect(AddMemberForm) />
|
|
24
|
-
</Container>
|
|
25
|
-
</Fragment>
|
|
26
|
-
`;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<AddMemberForm /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<form
|
|
6
|
-
class="ui form"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
class="required field"
|
|
10
|
-
>
|
|
11
|
-
<label
|
|
12
|
-
for="principal"
|
|
13
|
-
>
|
|
14
|
-
domain.member
|
|
15
|
-
</label>
|
|
16
|
-
<div
|
|
17
|
-
aria-expanded="false"
|
|
18
|
-
class="ui search selection dropdown"
|
|
19
|
-
required=""
|
|
20
|
-
role="combobox"
|
|
21
|
-
>
|
|
22
|
-
<input
|
|
23
|
-
aria-autocomplete="list"
|
|
24
|
-
autocomplete="off"
|
|
25
|
-
class="search"
|
|
26
|
-
tabindex="0"
|
|
27
|
-
type="text"
|
|
28
|
-
value=""
|
|
29
|
-
/>
|
|
30
|
-
<div
|
|
31
|
-
aria-atomic="true"
|
|
32
|
-
aria-live="polite"
|
|
33
|
-
class="divider default text"
|
|
34
|
-
role="alert"
|
|
35
|
-
>
|
|
36
|
-
domain.member
|
|
37
|
-
</div>
|
|
38
|
-
<i
|
|
39
|
-
aria-hidden="true"
|
|
40
|
-
class="dropdown icon"
|
|
41
|
-
/>
|
|
42
|
-
<div
|
|
43
|
-
class="menu transition"
|
|
44
|
-
role="listbox"
|
|
45
|
-
>
|
|
46
|
-
<div
|
|
47
|
-
aria-checked="false"
|
|
48
|
-
aria-selected="true"
|
|
49
|
-
class="selected item"
|
|
50
|
-
id="1"
|
|
51
|
-
role="option"
|
|
52
|
-
style="pointer-events: all;"
|
|
53
|
-
>
|
|
54
|
-
<span
|
|
55
|
-
class="text"
|
|
56
|
-
>
|
|
57
|
-
john
|
|
58
|
-
</span>
|
|
59
|
-
</div>
|
|
60
|
-
<div
|
|
61
|
-
aria-checked="false"
|
|
62
|
-
aria-selected="false"
|
|
63
|
-
class="item"
|
|
64
|
-
id="2"
|
|
65
|
-
role="option"
|
|
66
|
-
style="pointer-events: all;"
|
|
67
|
-
>
|
|
68
|
-
<span
|
|
69
|
-
class="text"
|
|
70
|
-
>
|
|
71
|
-
mambo
|
|
72
|
-
</span>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
<div
|
|
78
|
-
class="required field"
|
|
79
|
-
>
|
|
80
|
-
<label
|
|
81
|
-
for="role"
|
|
82
|
-
>
|
|
83
|
-
domain.role
|
|
84
|
-
</label>
|
|
85
|
-
<div
|
|
86
|
-
aria-expanded="false"
|
|
87
|
-
class="ui basic search selection dropdown"
|
|
88
|
-
required=""
|
|
89
|
-
role="combobox"
|
|
90
|
-
>
|
|
91
|
-
<input
|
|
92
|
-
aria-autocomplete="list"
|
|
93
|
-
autocomplete="off"
|
|
94
|
-
class="search"
|
|
95
|
-
id="role"
|
|
96
|
-
tabindex="0"
|
|
97
|
-
type="text"
|
|
98
|
-
value=""
|
|
99
|
-
/>
|
|
100
|
-
<div
|
|
101
|
-
aria-atomic="true"
|
|
102
|
-
aria-live="polite"
|
|
103
|
-
class="divider default text"
|
|
104
|
-
role="alert"
|
|
105
|
-
>
|
|
106
|
-
domain.role
|
|
107
|
-
</div>
|
|
108
|
-
<i
|
|
109
|
-
aria-hidden="true"
|
|
110
|
-
class="dropdown icon"
|
|
111
|
-
/>
|
|
112
|
-
<div
|
|
113
|
-
class="menu transition"
|
|
114
|
-
role="listbox"
|
|
115
|
-
>
|
|
116
|
-
<div
|
|
117
|
-
aria-checked="false"
|
|
118
|
-
aria-selected="true"
|
|
119
|
-
class="selected item"
|
|
120
|
-
role="option"
|
|
121
|
-
style="pointer-events: all;"
|
|
122
|
-
>
|
|
123
|
-
<span
|
|
124
|
-
class="text"
|
|
125
|
-
>
|
|
126
|
-
role1
|
|
127
|
-
</span>
|
|
128
|
-
</div>
|
|
129
|
-
<div
|
|
130
|
-
aria-checked="false"
|
|
131
|
-
aria-selected="false"
|
|
132
|
-
class="item"
|
|
133
|
-
role="option"
|
|
134
|
-
style="pointer-events: all;"
|
|
135
|
-
>
|
|
136
|
-
<span
|
|
137
|
-
class="text"
|
|
138
|
-
>
|
|
139
|
-
role2
|
|
140
|
-
</span>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
<div
|
|
146
|
-
class="field"
|
|
147
|
-
>
|
|
148
|
-
<label
|
|
149
|
-
for="description"
|
|
150
|
-
>
|
|
151
|
-
domain.role.member.description
|
|
152
|
-
</label>
|
|
153
|
-
<div
|
|
154
|
-
class="ui input"
|
|
155
|
-
>
|
|
156
|
-
<input
|
|
157
|
-
autocomplete="off"
|
|
158
|
-
id="description"
|
|
159
|
-
maxlength="120"
|
|
160
|
-
placeholder="domain.role.member.description"
|
|
161
|
-
type="text"
|
|
162
|
-
value=""
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
<div
|
|
167
|
-
class="actions"
|
|
168
|
-
>
|
|
169
|
-
<button
|
|
170
|
-
class="ui primary disabled right floated button"
|
|
171
|
-
disabled=""
|
|
172
|
-
tabindex="-1"
|
|
173
|
-
type="submit"
|
|
174
|
-
>
|
|
175
|
-
domain.actions.add_member
|
|
176
|
-
</button>
|
|
177
|
-
<a
|
|
178
|
-
class="ui secondary button"
|
|
179
|
-
href="/"
|
|
180
|
-
role="button"
|
|
181
|
-
>
|
|
182
|
-
actions.cancel
|
|
183
|
-
</a>
|
|
184
|
-
</div>
|
|
185
|
-
</form>
|
|
186
|
-
</div>
|
|
187
|
-
`;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<DomainMember /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="ui card domain-member"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
class="content domain-member__content"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
class="header"
|
|
13
|
-
>
|
|
14
|
-
<i
|
|
15
|
-
aria-hidden="true"
|
|
16
|
-
class="icon"
|
|
17
|
-
/>
|
|
18
|
-
</div>
|
|
19
|
-
<div
|
|
20
|
-
class="description"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
|
-
<div
|
|
24
|
-
class="extra content domain-member__content-without-description"
|
|
25
|
-
>
|
|
26
|
-
<div
|
|
27
|
-
class="description domain-member__description"
|
|
28
|
-
>
|
|
29
|
-
<span />
|
|
30
|
-
|
|
31
|
-
<i
|
|
32
|
-
aria-hidden="true"
|
|
33
|
-
class="pencil alternate link icon"
|
|
34
|
-
/>
|
|
35
|
-
</div>
|
|
36
|
-
<button
|
|
37
|
-
class="ui basic icon negative right floated button button-domain_delete_without_description"
|
|
38
|
-
>
|
|
39
|
-
<i
|
|
40
|
-
aria-hidden="true"
|
|
41
|
-
class="trash icon"
|
|
42
|
-
/>
|
|
43
|
-
</button>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchDomainConceptChildren,
|
|
3
|
-
clearDomainConceptChildren
|
|
4
|
-
} from "../../routines";
|
|
5
|
-
import { domainConceptChildren } from "..";
|
|
6
|
-
|
|
7
|
-
const fooState = { foo: "bar" };
|
|
8
|
-
|
|
9
|
-
describe("reducers: domainConceptChildren", () => {
|
|
10
|
-
const initialState = {};
|
|
11
|
-
|
|
12
|
-
it("should provide the initial state", () => {
|
|
13
|
-
expect(domainConceptChildren(undefined, {})).toEqual(initialState);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should handle the clearDomainConceptChildren.TRIGGER action", () => {
|
|
17
|
-
expect(
|
|
18
|
-
domainConceptChildren(fooState, {
|
|
19
|
-
type: clearDomainConceptChildren.TRIGGER
|
|
20
|
-
})
|
|
21
|
-
).toEqual(initialState);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("should handle the fetchDomainConceptChildren.TRIGGER action", () => {
|
|
25
|
-
expect(
|
|
26
|
-
domainConceptChildren(fooState, {
|
|
27
|
-
type: fetchDomainConceptChildren.TRIGGER
|
|
28
|
-
})
|
|
29
|
-
).toEqual(initialState);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should handle the fetchDomainConceptChildren.SUCCESS action", () => {
|
|
33
|
-
const data = { counter: 0, acl_entry_id: 1 };
|
|
34
|
-
expect(
|
|
35
|
-
domainConceptChildren(fooState, {
|
|
36
|
-
type: fetchDomainConceptChildren.SUCCESS,
|
|
37
|
-
payload: { data }
|
|
38
|
-
})
|
|
39
|
-
).toEqual(data);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should ignore unknown actions", () => {
|
|
43
|
-
expect(domainConceptChildren(fooState, { type: "FOO" })).toBe(fooState);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { fetchDomainConceptChildren } from "../../routines";
|
|
2
|
-
import { domainConceptChildrenLoading } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: domainConceptChildrenLoading", () => {
|
|
7
|
-
const initialState = [];
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(domainConceptChildrenLoading(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the fetchDomainConceptChildren.TRIGGER action", () => {
|
|
14
|
-
const acl_entry_id = 0;
|
|
15
|
-
const payload = { acl_entry_id };
|
|
16
|
-
|
|
17
|
-
expect(
|
|
18
|
-
domainConceptChildrenLoading(fooState, {
|
|
19
|
-
type: fetchDomainConceptChildren.TRIGGER,
|
|
20
|
-
payload
|
|
21
|
-
})
|
|
22
|
-
).toEqual([acl_entry_id]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle the fetchDomainConceptChildren.SUCCESS action", () => {
|
|
26
|
-
expect(
|
|
27
|
-
domainConceptChildrenLoading(fooState, {
|
|
28
|
-
type: fetchDomainConceptChildren.FULFILL
|
|
29
|
-
})
|
|
30
|
-
).toEqual(initialState);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should ignore unknown actions", () => {
|
|
34
|
-
expect(domainConceptChildrenLoading(fooState, { type: "FOO" })).toBe(
|
|
35
|
-
fooState
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { fetchDomainMembers } from "../../routines";
|
|
2
|
-
import { domainMembers } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: domainMembers", () => {
|
|
7
|
-
const initialState = [];
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(domainMembers(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the fetchDomainMembers.SUCCESS action", () => {
|
|
14
|
-
const acl_entries = [
|
|
15
|
-
{ id: 1, name: "Name 1", user_name: "user1" },
|
|
16
|
-
{ id: 2, name: "Name 2", user_name: "user2" }
|
|
17
|
-
];
|
|
18
|
-
const _embedded = {
|
|
19
|
-
acl_entries: acl_entries
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
expect(
|
|
23
|
-
domainMembers(fooState, {
|
|
24
|
-
type: fetchDomainMembers.SUCCESS,
|
|
25
|
-
payload: { _embedded }
|
|
26
|
-
})
|
|
27
|
-
).toMatchObject(acl_entries);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should ignore unknown actions", () => {
|
|
31
|
-
expect(domainMembers(fooState, { type: "FOO" })).toBe(fooState);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
3
|
-
fetchDomainConceptChildren,
|
|
4
|
-
clearDomainConceptChildren
|
|
5
|
-
} from "../routines";
|
|
6
|
-
|
|
7
|
-
const initialState = {};
|
|
8
|
-
|
|
9
|
-
const pickFields = _.pick(["counter", "acl_entry_id"]);
|
|
10
|
-
|
|
11
|
-
const domainConceptChildren = (state = initialState, { type, payload }) => {
|
|
12
|
-
switch (type) {
|
|
13
|
-
case clearDomainConceptChildren.TRIGGER:
|
|
14
|
-
return initialState;
|
|
15
|
-
case fetchDomainConceptChildren.TRIGGER:
|
|
16
|
-
return initialState;
|
|
17
|
-
case fetchDomainConceptChildren.SUCCESS:
|
|
18
|
-
return pickFields(payload.data);
|
|
19
|
-
default:
|
|
20
|
-
return state;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { domainConceptChildren };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { fetchDomainConceptChildren } from "../routines";
|
|
2
|
-
|
|
3
|
-
const domainConceptChildrenLoading = (state = [], { type, payload }) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case fetchDomainConceptChildren.TRIGGER: {
|
|
6
|
-
const { acl_entry_id } = payload;
|
|
7
|
-
return [acl_entry_id];
|
|
8
|
-
}
|
|
9
|
-
case fetchDomainConceptChildren.FULFILL:
|
|
10
|
-
return [];
|
|
11
|
-
default:
|
|
12
|
-
return state;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { domainConceptChildrenLoading };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { deleteDomainMember } from "../routines";
|
|
2
|
-
|
|
3
|
-
export const domainMemberDeleting = (state = [], { type, payload }) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case deleteDomainMember.TRIGGER: {
|
|
6
|
-
const { id } = payload;
|
|
7
|
-
return [id];
|
|
8
|
-
}
|
|
9
|
-
case deleteDomainMember.FULFILL:
|
|
10
|
-
return [];
|
|
11
|
-
default:
|
|
12
|
-
return state;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { addDomainMember } from "../routines";
|
|
2
|
-
|
|
3
|
-
export const domainMemberSaving = (state = false, { type }) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case addDomainMember.TRIGGER:
|
|
6
|
-
return true;
|
|
7
|
-
case addDomainMember.FULFILL:
|
|
8
|
-
return false;
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
3
|
-
import { fetchDomainMembers, deleteDomainMember } from "../routines";
|
|
4
|
-
|
|
5
|
-
const initialState = [];
|
|
6
|
-
|
|
7
|
-
export const domainMembers = (state = initialState, { type, payload }) => {
|
|
8
|
-
switch (type) {
|
|
9
|
-
case fetchDomainMembers.SUCCESS: {
|
|
10
|
-
return _.flow(
|
|
11
|
-
_.pathOr(initialState, "_embedded.acl_entries"),
|
|
12
|
-
_.sortBy(accentInsensitivePathOrder("user_name"))
|
|
13
|
-
)(payload);
|
|
14
|
-
}
|
|
15
|
-
case deleteDomainMember.SUCCESS: {
|
|
16
|
-
const { id } = payload;
|
|
17
|
-
return _.filter(x => x.acl_entry_id !== id)(state);
|
|
18
|
-
}
|
|
19
|
-
default:
|
|
20
|
-
return state;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
-
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
3
|
-
import { addDomainMemberSaga } from "../addDomainMember";
|
|
4
|
-
import { addDomainMember } from "../../routines";
|
|
5
|
-
|
|
6
|
-
describe("sagas: addDomainMemberSaga", () => {
|
|
7
|
-
const resource_id = 123;
|
|
8
|
-
const acl_entry = { id: 1, name: "foo" };
|
|
9
|
-
const payload = { acl_entry, resource_id };
|
|
10
|
-
const meta = { resource_id };
|
|
11
|
-
const url = "/api/acl_entries/domains/123"; // Note resource_type is "domains"
|
|
12
|
-
|
|
13
|
-
it("should put a success action when a response is returned", () => {
|
|
14
|
-
const data = [];
|
|
15
|
-
|
|
16
|
-
expect(() => {
|
|
17
|
-
testSaga(addDomainMemberSaga, { payload })
|
|
18
|
-
.next()
|
|
19
|
-
.put({ meta, ...addDomainMember.request() })
|
|
20
|
-
.next()
|
|
21
|
-
.call(apiJsonPost, url, { acl_entry }, JSON_OPTS)
|
|
22
|
-
.next({ data })
|
|
23
|
-
.put({ meta, ...addDomainMember.success(data) })
|
|
24
|
-
.next()
|
|
25
|
-
.put(addDomainMember.fulfill())
|
|
26
|
-
.next()
|
|
27
|
-
.isDone();
|
|
28
|
-
}).not.toThrow();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should put a failure action when the call returns an error", () => {
|
|
32
|
-
const message = "Request failed";
|
|
33
|
-
const error = { message };
|
|
34
|
-
|
|
35
|
-
expect(() => {
|
|
36
|
-
testSaga(addDomainMemberSaga, { payload })
|
|
37
|
-
.next()
|
|
38
|
-
.put({ meta, ...addDomainMember.request() })
|
|
39
|
-
.next()
|
|
40
|
-
.call(apiJsonPost, url, { acl_entry }, JSON_OPTS)
|
|
41
|
-
.throw(error)
|
|
42
|
-
.put(addDomainMember.failure(message))
|
|
43
|
-
.next()
|
|
44
|
-
.put(addDomainMember.fulfill())
|
|
45
|
-
.next()
|
|
46
|
-
.isDone();
|
|
47
|
-
}).not.toThrow();
|
|
48
|
-
});
|
|
49
|
-
});
|