@truedat/dd 4.28.3 → 4.28.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.
- package/CHANGELOG.md +12 -0
- package/package.json +6 -6
- package/src/api.js +8 -0
- package/src/components/DictionaryRoutes.js +27 -0
- package/src/components/EditDomainForm.js +1 -0
- package/src/components/GrantDateFilter.js +30 -0
- package/src/components/GrantFilters.js +28 -0
- package/src/components/GrantFiltersLoader.js +29 -0
- package/src/components/GrantSelectedFilters.js +63 -0
- package/src/components/Grants.js +54 -0
- package/src/components/GrantsLabelResults.js +32 -0
- package/src/components/GrantsLoader.js +47 -0
- package/src/components/GrantsPagination.js +14 -0
- package/src/components/GrantsSearch.js +51 -0
- package/src/components/GrantsTable.js +112 -0
- package/src/components/StructureGrantCart.js +16 -14
- package/src/components/StructureGrantCartCheckout.js +9 -9
- package/src/components/StructureSummary.js +5 -5
- package/src/components/StructureTabPane.js +3 -3
- package/src/components/StructureView.js +14 -6
- package/src/components/__tests__/GrantDateFilter.spec.js +11 -0
- package/src/components/__tests__/GrantsLabelResults.js +17 -0
- package/src/components/__tests__/GrantsLoader.spec.js +41 -0
- package/src/components/__tests__/GrantsTable.spec.js +185 -0
- package/src/components/__tests__/StructureGrantRequestButton.spec.js +20 -9
- package/src/components/__tests__/StructureSummary.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +8 -0
- package/src/components/__tests__/__snapshots__/GrantDateFilter.spec.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/GrantsLabelResults.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/GrantsLoader.spec.js.snap +27 -0
- package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +231 -0
- package/src/components/index.js +4 -0
- package/src/messages/en.js +12 -2
- package/src/messages/es.js +12 -2
- package/src/reducers/__tests__/grantDateFilter.spec.js +54 -0
- package/src/reducers/__tests__/grantFilters.spec.js +37 -0
- package/src/reducers/__tests__/grantQuery.spec.js +113 -0
- package/src/reducers/__tests__/grants.spec.js +102 -0
- package/src/reducers/grantActiveFilters.js +48 -0
- package/src/reducers/grantCount.js +20 -0
- package/src/reducers/grantDateFilter.js +31 -0
- package/src/reducers/grantFilters.js +19 -0
- package/src/reducers/grantLoading.js +16 -0
- package/src/reducers/grantQuery.js +62 -0
- package/src/reducers/grantSelectedFilter.js +34 -0
- package/src/reducers/grants.js +24 -0
- package/src/reducers/grantsFilters.js +19 -0
- package/src/reducers/grantsPageSize.js +15 -0
- package/src/reducers/index.js +18 -0
- package/src/reducers/structureDateFilter.js +2 -2
- package/src/reducers/structureQuery.js +2 -2
- package/src/routines.js +20 -0
- package/src/sagas/__tests__/fetchGrantFilters.spec.js +97 -0
- package/src/sagas/__tests__/fetchGrants.spec.js +86 -0
- package/src/sagas/fetchGrantFilters.js +31 -0
- package/src/sagas/fetchGrants.js +26 -0
- package/src/sagas/index.js +6 -0
- package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +10 -0
- package/src/selectors/__tests__/getGrantAvailableFilters.spec.js +15 -0
- package/src/selectors/__tests__/getGrantSelectedFilterActiveValues.spec.js +16 -0
- package/src/selectors/__tests__/getGrantSelectedFilterValues.spec.js +15 -0
- package/src/selectors/__tests__/getGrantSelectedFilters.spec.js +15 -0
- package/src/selectors/__tests__/getGrantsColumns.spec.js +40 -0
- package/src/selectors/__tests__/getTabVisibility.spec.js +30 -30
- package/src/selectors/getGrantAvailableFilters.js +17 -0
- package/src/selectors/getGrantSelectedFilterActiveValues.js +8 -0
- package/src/selectors/getGrantSelectedFilterValues.js +13 -0
- package/src/selectors/getGrantSelectedFilters.js +7 -0
- package/src/selectors/getGrantsColumns.js +84 -8
- package/src/selectors/getStructureSelectedFilterValues.js +5 -3
- package/src/selectors/getTabVisibility.js +7 -7
- package/src/selectors/index.js +4 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
Divider,
|
|
15
15
|
Button,
|
|
16
16
|
Grid,
|
|
17
|
-
Form
|
|
17
|
+
Form,
|
|
18
18
|
} from "semantic-ui-react";
|
|
19
19
|
import { GRANTS_REQUESTS_CHECKOUT, STRUCTURES } from "@truedat/core/routes";
|
|
20
20
|
import { FiltersGrid } from "@truedat/dq/components/ruleImplementationForm/FiltersGrid";
|
|
@@ -22,13 +22,13 @@ import { getRuleImplementationOperators } from "@truedat/dq/selectors/getRuleImp
|
|
|
22
22
|
import {
|
|
23
23
|
addGrantRequestToCart,
|
|
24
24
|
removeGrantRequestFromCart,
|
|
25
|
-
updateGrantRequestFilter
|
|
25
|
+
updateGrantRequestFilter,
|
|
26
26
|
} from "../routines";
|
|
27
27
|
|
|
28
28
|
const getIcon = (formatMessage, type) =>
|
|
29
29
|
formatMessage({
|
|
30
30
|
id: `structure.type.${type}.icon`,
|
|
31
|
-
defaultMessage: "question circle outline"
|
|
31
|
+
defaultMessage: "question circle outline",
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export const StructureGrantCart = ({
|
|
@@ -36,7 +36,7 @@ export const StructureGrantCart = ({
|
|
|
36
36
|
grantRequestsCart,
|
|
37
37
|
removeGrantRequestFromCart,
|
|
38
38
|
updateGrantRequestFilter,
|
|
39
|
-
typeOperators
|
|
39
|
+
typeOperators,
|
|
40
40
|
}) => {
|
|
41
41
|
const { formatMessage } = useIntl();
|
|
42
42
|
const history = useHistory();
|
|
@@ -48,14 +48,16 @@ export const StructureGrantCart = ({
|
|
|
48
48
|
if (_.isEmpty(structures)) history.push(STRUCTURES);
|
|
49
49
|
}, [history, structures]);
|
|
50
50
|
|
|
51
|
-
const removeRequest = structure => () =>
|
|
51
|
+
const removeRequest = (structure) => () =>
|
|
52
52
|
removeGrantRequestFromCart(structure);
|
|
53
53
|
const canHasFilters = _.pathOr(false, "hasDataFields");
|
|
54
54
|
const hasFilters = _.flow(_.pathOr([], "filters"), _.negate(_.isEmpty));
|
|
55
55
|
|
|
56
|
-
const setRowValue =
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const setRowValue =
|
|
57
|
+
(structure_id) =>
|
|
58
|
+
({ index, value }) => {
|
|
59
|
+
updateGrantRequestFilter({ index, value, structure_id });
|
|
60
|
+
};
|
|
59
61
|
|
|
60
62
|
return (
|
|
61
63
|
<Segment>
|
|
@@ -64,7 +66,7 @@ export const StructureGrantCart = ({
|
|
|
64
66
|
</Header>
|
|
65
67
|
<Divider />
|
|
66
68
|
<List.List>
|
|
67
|
-
{structures.map(s => (
|
|
69
|
+
{structures.map((s) => (
|
|
68
70
|
<Popup
|
|
69
71
|
key={`${s.id}`}
|
|
70
72
|
content={s.external_id}
|
|
@@ -139,24 +141,24 @@ StructureGrantCart.propTypes = {
|
|
|
139
141
|
typeOperators: PropTypes.array,
|
|
140
142
|
addGrantRequestToCart: PropTypes.func,
|
|
141
143
|
removeGrantRequestFromCart: PropTypes.func,
|
|
142
|
-
updateGrantRequestFilter: PropTypes.func
|
|
144
|
+
updateGrantRequestFilter: PropTypes.func,
|
|
143
145
|
};
|
|
144
146
|
|
|
145
|
-
const mapStateToProps = state => {
|
|
147
|
+
const mapStateToProps = (state) => {
|
|
146
148
|
const { structure, grantRequestsCart, userPermissions } = state;
|
|
147
149
|
return {
|
|
148
150
|
structure,
|
|
149
151
|
grantRequestsCart,
|
|
150
152
|
authorized: _.pathOr(false, "request_grant")(userPermissions),
|
|
151
|
-
typeOperators: getRuleImplementationOperators(state)
|
|
153
|
+
typeOperators: getRuleImplementationOperators(state),
|
|
152
154
|
};
|
|
153
155
|
};
|
|
154
|
-
const mapDispatchToProps = dispatch =>
|
|
156
|
+
const mapDispatchToProps = (dispatch) =>
|
|
155
157
|
bindActionCreators(
|
|
156
158
|
{
|
|
157
159
|
addGrantRequestToCart,
|
|
158
160
|
removeGrantRequestFromCart,
|
|
159
|
-
updateGrantRequestFilter
|
|
161
|
+
updateGrantRequestFilter,
|
|
160
162
|
},
|
|
161
163
|
dispatch
|
|
162
164
|
);
|
|
@@ -13,7 +13,7 @@ import StructureGrantCartTemplate from "./StructureGrantCartTemplate";
|
|
|
13
13
|
|
|
14
14
|
export const StructureGrantCartCheckout = ({
|
|
15
15
|
grantRequestsCart,
|
|
16
|
-
checkoutGrantRequest
|
|
16
|
+
checkoutGrantRequest,
|
|
17
17
|
}) => {
|
|
18
18
|
const { formatMessage } = useIntl();
|
|
19
19
|
|
|
@@ -27,20 +27,20 @@ export const StructureGrantCartCheckout = ({
|
|
|
27
27
|
|
|
28
28
|
const checkout = () => {
|
|
29
29
|
const metadata = applyTemplate(template)(content);
|
|
30
|
-
const requests = _.map(structure => {
|
|
30
|
+
const requests = _.map((structure) => {
|
|
31
31
|
return {
|
|
32
32
|
data_structure_id: structure.id,
|
|
33
33
|
filters: {
|
|
34
|
-
rows: structure.filters
|
|
34
|
+
rows: structure.filters,
|
|
35
35
|
},
|
|
36
|
-
metadata: metadata
|
|
36
|
+
metadata: metadata,
|
|
37
37
|
};
|
|
38
38
|
})(grantRequestsCart.structures);
|
|
39
39
|
const payload = {
|
|
40
40
|
grant_request_group: {
|
|
41
41
|
requests,
|
|
42
|
-
type: template.name
|
|
43
|
-
}
|
|
42
|
+
type: template.name,
|
|
43
|
+
},
|
|
44
44
|
};
|
|
45
45
|
checkoutGrantRequest(payload);
|
|
46
46
|
};
|
|
@@ -76,12 +76,12 @@ export const StructureGrantCartCheckout = ({
|
|
|
76
76
|
|
|
77
77
|
StructureGrantCart.propTypes = {
|
|
78
78
|
grantRequestsCart: PropTypes.object,
|
|
79
|
-
checkoutGrantRequest: PropTypes.func
|
|
79
|
+
checkoutGrantRequest: PropTypes.func,
|
|
80
80
|
};
|
|
81
81
|
const mapStateToProps = ({ grantRequestsCart }) => ({
|
|
82
|
-
grantRequestsCart
|
|
82
|
+
grantRequestsCart,
|
|
83
83
|
});
|
|
84
|
-
const mapDispatchToProps = dispatch =>
|
|
84
|
+
const mapDispatchToProps = (dispatch) =>
|
|
85
85
|
bindActionCreators({ checkoutGrantRequest }, dispatch);
|
|
86
86
|
|
|
87
87
|
export default connect(
|
|
@@ -80,18 +80,18 @@ export const StructureSummary = ({
|
|
|
80
80
|
<Header as="h2">
|
|
81
81
|
<Header.Content>
|
|
82
82
|
{name}
|
|
83
|
-
{grant ?
|
|
84
|
-
|
|
83
|
+
{grant ? (
|
|
84
|
+
structureGrant ? (
|
|
85
85
|
structureGrant(grant)
|
|
86
86
|
) : (
|
|
87
87
|
<Label color="green">
|
|
88
88
|
<Icon name="shield" />
|
|
89
89
|
{formatMessage({ id: "structure.grant.has_grant" })}
|
|
90
90
|
</Label>
|
|
91
|
-
)
|
|
92
|
-
|
|
91
|
+
)
|
|
92
|
+
) : (
|
|
93
93
|
<StructureGrantRequestButton />
|
|
94
|
-
}
|
|
94
|
+
)}
|
|
95
95
|
{type && (
|
|
96
96
|
<Header.Subheader>
|
|
97
97
|
{formatMessage({
|
|
@@ -5,7 +5,7 @@ import { Route, Switch } from "react-router-dom";
|
|
|
5
5
|
import { ErrorBoundary } from "@truedat/core/components";
|
|
6
6
|
import {
|
|
7
7
|
STRUCTURE_LINKS_NEW,
|
|
8
|
-
STRUCTURE_NOTES_EDIT
|
|
8
|
+
STRUCTURE_NOTES_EDIT,
|
|
9
9
|
} from "@truedat/core/routes";
|
|
10
10
|
import { getActiveTab } from "../selectors/getActiveTab";
|
|
11
11
|
import { getTabVisibility } from "../selectors/getTabVisibility";
|
|
@@ -77,7 +77,7 @@ export const StructureTabPane = ({ activeTab, tabVisibility }) => (
|
|
|
77
77
|
|
|
78
78
|
StructureTabPane.propTypes = {
|
|
79
79
|
activeTab: PropTypes.string,
|
|
80
|
-
tabVisibility: PropTypes.object
|
|
80
|
+
tabVisibility: PropTypes.object,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const mapStateToProps = (state, { match: { path } }) => {
|
|
@@ -85,7 +85,7 @@ const mapStateToProps = (state, { match: { path } }) => {
|
|
|
85
85
|
const activeTab = getActiveTab(tabVisibility, path);
|
|
86
86
|
return {
|
|
87
87
|
tabVisibility,
|
|
88
|
-
activeTab
|
|
88
|
+
activeTab,
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
|
|
@@ -12,7 +12,11 @@ import StructureSummary from "./StructureSummary";
|
|
|
12
12
|
import StructureTabPaneRoutes from "./StructureTabPaneRoutes";
|
|
13
13
|
import StructureTabRoutes from "./StructureTabRoutes";
|
|
14
14
|
|
|
15
|
-
export const StructureView = ({
|
|
15
|
+
export const StructureView = ({
|
|
16
|
+
structureLoading,
|
|
17
|
+
structure,
|
|
18
|
+
hasItemsInCart,
|
|
19
|
+
}) => (
|
|
16
20
|
<Segment loading={structureLoading} className="structures">
|
|
17
21
|
{structure && structure.id && !structureLoading && (
|
|
18
22
|
<Grid>
|
|
@@ -34,11 +38,11 @@ export const StructureView = ({ structureLoading, structure, hasItemsInCart }) =
|
|
|
34
38
|
<StructureTabPaneRoutes />
|
|
35
39
|
</Segment>
|
|
36
40
|
</Grid.Column>
|
|
37
|
-
{hasItemsInCart &&
|
|
41
|
+
{hasItemsInCart && (
|
|
38
42
|
<Grid.Column width={4}>
|
|
39
|
-
<StructureGrantCart/>
|
|
43
|
+
<StructureGrantCart />
|
|
40
44
|
</Grid.Column>
|
|
41
|
-
}
|
|
45
|
+
)}
|
|
42
46
|
</Grid.Row>
|
|
43
47
|
</Grid>
|
|
44
48
|
)}
|
|
@@ -48,10 +52,14 @@ export const StructureView = ({ structureLoading, structure, hasItemsInCart }) =
|
|
|
48
52
|
StructureView.propTypes = {
|
|
49
53
|
structureLoading: PropTypes.bool,
|
|
50
54
|
structure: PropTypes.object,
|
|
51
|
-
hasItemsInCart: PropTypes.bool
|
|
55
|
+
hasItemsInCart: PropTypes.bool,
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
const mapStateToProps = ({
|
|
58
|
+
const mapStateToProps = ({
|
|
59
|
+
structureLoading,
|
|
60
|
+
structure,
|
|
61
|
+
grantRequestsCart,
|
|
62
|
+
}) => ({
|
|
55
63
|
structureLoading,
|
|
56
64
|
structure,
|
|
57
65
|
hasItemsInCart: _.flow(
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { shallow } from "enzyme";
|
|
3
|
+
import { GrantDateFilter } from "../GrantDateFilter";
|
|
4
|
+
|
|
5
|
+
describe("<GrantDateFilter/>", () => {
|
|
6
|
+
it("matches the latest snapshot", () => {
|
|
7
|
+
const props = { active: true };
|
|
8
|
+
const wrapper = shallow(<GrantDateFilter {...props} />);
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { shallow } from "enzyme";
|
|
3
|
+
import { intl } from "@truedat/test/intl-stub";
|
|
4
|
+
import { GrantsLabelResults } from "../GrantsLabelResults";
|
|
5
|
+
|
|
6
|
+
// workaround for enzyme issue with React.useContext
|
|
7
|
+
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
8
|
+
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
9
|
+
|
|
10
|
+
describe("<GrantsLabelResults />", () => {
|
|
11
|
+
const props = { grantCount: 22 };
|
|
12
|
+
|
|
13
|
+
it("matches the latest snapshot", () => {
|
|
14
|
+
const wrapper = shallow(<GrantsLabelResults {...props} />);
|
|
15
|
+
expect(wrapper).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { mount } from "enzyme";
|
|
3
|
+
import { GrantsLoader } from "../GrantsLoader";
|
|
4
|
+
|
|
5
|
+
const getProps = () => ({
|
|
6
|
+
clearGrants: jest.fn(),
|
|
7
|
+
payload: {},
|
|
8
|
+
grantsLoading: false,
|
|
9
|
+
fetchGrants: jest.fn(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("<GrantsLoader />", () => {
|
|
13
|
+
it("matches the latest snapshot", () => {
|
|
14
|
+
const props = getProps();
|
|
15
|
+
const wrapper = mount(<GrantsLoader {...props} />);
|
|
16
|
+
expect(wrapper).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("calls fetchGrants when component mounts but not when it unmounts", () => {
|
|
20
|
+
const props = getProps();
|
|
21
|
+
const wrapper = mount(<GrantsLoader {...props} />);
|
|
22
|
+
expect(props.fetchGrants).toHaveBeenCalledTimes(1);
|
|
23
|
+
wrapper.unmount();
|
|
24
|
+
expect(props.fetchGrants).toHaveBeenCalledTimes(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("calls clearGrants when component unmounts but not when it mounts", () => {
|
|
28
|
+
const props = getProps();
|
|
29
|
+
const wrapper = mount(<GrantsLoader {...props} />);
|
|
30
|
+
expect(props.clearGrants).toHaveBeenCalledTimes(0);
|
|
31
|
+
wrapper.unmount();
|
|
32
|
+
expect(props.clearGrants).toHaveBeenCalledTimes(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("calls fetchGrants when payload is updated", () => {
|
|
36
|
+
const props = getProps();
|
|
37
|
+
const wrapper = mount(<GrantsLoader {...props} />);
|
|
38
|
+
wrapper.setProps({ payload: { "data_structure_version.name.raw": "XXX" } });
|
|
39
|
+
expect(props.fetchGrants).toHaveBeenCalledTimes(2);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { shallow } from "enzyme";
|
|
4
|
+
import { intl } from "@truedat/test/intl-stub";
|
|
5
|
+
import { GrantsTable } from "../GrantsTable";
|
|
6
|
+
import {
|
|
7
|
+
userDecorator,
|
|
8
|
+
GrantTableStructureDecorator,
|
|
9
|
+
StartDateDecorator,
|
|
10
|
+
EndDateDecorator,
|
|
11
|
+
GenericObjectDecorator,
|
|
12
|
+
} from "../../selectors/getGrantsColumns";
|
|
13
|
+
|
|
14
|
+
// workaround for enzyme issue with React.useContext
|
|
15
|
+
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
16
|
+
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
17
|
+
|
|
18
|
+
describe("<GrantsTable />", () => {
|
|
19
|
+
const defaultGrantsTableColumns = [
|
|
20
|
+
{
|
|
21
|
+
name: "user",
|
|
22
|
+
sort: { name: "user.user_name.raw" },
|
|
23
|
+
fieldSelector: _.pick(["user"]),
|
|
24
|
+
fieldDecorator: userDecorator,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "data_structure_version",
|
|
28
|
+
sort: { name: "data_structure_version.name.raw" },
|
|
29
|
+
fieldSelector: _.pick(["data_structure", "data_structure_version"]),
|
|
30
|
+
fieldDecorator: GrantTableStructureDecorator,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "start_date",
|
|
34
|
+
sort: { name: "start_date" },
|
|
35
|
+
fieldSelector: _.pick(["start_date"]),
|
|
36
|
+
fieldDecorator: StartDateDecorator,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "end_date",
|
|
40
|
+
sort: { name: "end_date" },
|
|
41
|
+
fieldSelector: _.pick(["end_date"]),
|
|
42
|
+
fieldDecorator: EndDateDecorator,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "metadata",
|
|
46
|
+
fieldSelector: _.pick(["data_structure_version.metadata"]),
|
|
47
|
+
fieldDecorator: GenericObjectDecorator,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const grants = [
|
|
52
|
+
{
|
|
53
|
+
data_structure_version: {
|
|
54
|
+
data_structure_id: 22075,
|
|
55
|
+
description: "DEscripción",
|
|
56
|
+
domain: {
|
|
57
|
+
external_id: "Demo Truedat",
|
|
58
|
+
id: 3,
|
|
59
|
+
name: "Demo Truedat",
|
|
60
|
+
parent_ids: [],
|
|
61
|
+
updated_at: "2020-07-21 07:45:41.068703Z",
|
|
62
|
+
},
|
|
63
|
+
external_id: "sap:Clientes:KNA1",
|
|
64
|
+
metadata: {},
|
|
65
|
+
mutable_metadata: null,
|
|
66
|
+
name: "KNA1",
|
|
67
|
+
},
|
|
68
|
+
detail: {},
|
|
69
|
+
end_date: "2023-05-16",
|
|
70
|
+
id: 6,
|
|
71
|
+
start_date: "2020-05-17",
|
|
72
|
+
user: {
|
|
73
|
+
email: "user1@example.com",
|
|
74
|
+
full_name: "user_full_name_1",
|
|
75
|
+
user_name: "user1",
|
|
76
|
+
},
|
|
77
|
+
user_id: 23,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
data_structure_version: {
|
|
81
|
+
data_structure_id: 4570466,
|
|
82
|
+
description: null,
|
|
83
|
+
domain: {
|
|
84
|
+
external_id: "Truedat",
|
|
85
|
+
id: 2,
|
|
86
|
+
name: "Truedat",
|
|
87
|
+
parent_ids: [],
|
|
88
|
+
updated_at: "2020-07-28 13:21:21.938189Z",
|
|
89
|
+
},
|
|
90
|
+
external_id: "postgres://postgres/td_metrics/public/concepts",
|
|
91
|
+
metadata: {
|
|
92
|
+
alias: "Truedat-PostgreSQL",
|
|
93
|
+
database: "td_metrics",
|
|
94
|
+
host: "postgres",
|
|
95
|
+
schema: "public",
|
|
96
|
+
type: "BASE TABLE",
|
|
97
|
+
},
|
|
98
|
+
mutable_metadata: null,
|
|
99
|
+
name: "concepts",
|
|
100
|
+
},
|
|
101
|
+
detail: {
|
|
102
|
+
access_type: "admin",
|
|
103
|
+
},
|
|
104
|
+
end_date: "2023-05-18",
|
|
105
|
+
id: 8,
|
|
106
|
+
start_date: "2011-05-17",
|
|
107
|
+
user: {
|
|
108
|
+
email: "user2@example.com",
|
|
109
|
+
full_name: "user_full_name_2",
|
|
110
|
+
user_name: "user2",
|
|
111
|
+
},
|
|
112
|
+
user_id: 171,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const grantsSorting = [{ "data_structure_version.name.raw": "asc" }];
|
|
117
|
+
const sortGrants = jest.fn();
|
|
118
|
+
const grantsLoading = false;
|
|
119
|
+
const props = {
|
|
120
|
+
grants,
|
|
121
|
+
columns: defaultGrantsTableColumns,
|
|
122
|
+
grantsLoading,
|
|
123
|
+
sortGrants,
|
|
124
|
+
grantsSorting,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
it("matches the latest snapshot", () => {
|
|
128
|
+
const wrapper = shallow(<GrantsTable {...props} />);
|
|
129
|
+
expect(wrapper).toMatchSnapshot();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("sorts column in the direction specified", () => {
|
|
133
|
+
const wrapper = shallow(<GrantsTable {...props} />);
|
|
134
|
+
|
|
135
|
+
const tableHeaderCells = wrapper
|
|
136
|
+
.find("TableHeader")
|
|
137
|
+
.find("TableRow")
|
|
138
|
+
.dive()
|
|
139
|
+
.find("TableHeaderCell");
|
|
140
|
+
|
|
141
|
+
expect(tableHeaderCells.at(0).props().sorted).toEqual(null);
|
|
142
|
+
expect(tableHeaderCells.at(1).props().sorted).toEqual("ascending");
|
|
143
|
+
expect(tableHeaderCells.at(2).props().sorted).toEqual(null);
|
|
144
|
+
expect(tableHeaderCells.at(3).props().sorted).toEqual(null);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("handles sort when column header is clicked", () => {
|
|
148
|
+
const wrapper = shallow(<GrantsTable {...props} />);
|
|
149
|
+
|
|
150
|
+
wrapper
|
|
151
|
+
.find("TableHeader")
|
|
152
|
+
.find("TableRow")
|
|
153
|
+
.dive()
|
|
154
|
+
.find("TableHeaderCell")
|
|
155
|
+
.at(0)
|
|
156
|
+
.simulate("click");
|
|
157
|
+
|
|
158
|
+
expect(
|
|
159
|
+
wrapper
|
|
160
|
+
.find("TableHeader")
|
|
161
|
+
.find("TableRow")
|
|
162
|
+
.dive()
|
|
163
|
+
.find("TableHeaderCell")
|
|
164
|
+
.at(0)
|
|
165
|
+
.props().sorted
|
|
166
|
+
).toEqual("ascending");
|
|
167
|
+
|
|
168
|
+
wrapper
|
|
169
|
+
.find("TableHeader")
|
|
170
|
+
.find("TableRow")
|
|
171
|
+
.dive()
|
|
172
|
+
.find("TableHeaderCell")
|
|
173
|
+
.at(0)
|
|
174
|
+
.simulate("click");
|
|
175
|
+
expect(
|
|
176
|
+
wrapper
|
|
177
|
+
.find("TableHeader")
|
|
178
|
+
.find("TableRow")
|
|
179
|
+
.dive()
|
|
180
|
+
.find("TableHeaderCell")
|
|
181
|
+
.at(0)
|
|
182
|
+
.props().sorted
|
|
183
|
+
).toEqual("descending");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -8,17 +8,19 @@ import { StructureGrantRequestButton } from "../StructureGrantRequestButton";
|
|
|
8
8
|
import messages from "../../messages/en";
|
|
9
9
|
|
|
10
10
|
const renderOpts = {
|
|
11
|
-
messages: { en: messages }
|
|
11
|
+
messages: { en: messages },
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
describe("<StructureGrantRequestButton />", () => {
|
|
15
|
-
|
|
16
15
|
it("render a button", async () => {
|
|
17
16
|
const props = {
|
|
18
17
|
requested: false,
|
|
19
18
|
authorized: true,
|
|
20
19
|
};
|
|
21
|
-
const { getByText } = render(
|
|
20
|
+
const { getByText } = render(
|
|
21
|
+
<StructureGrantRequestButton {...props} />,
|
|
22
|
+
renderOpts
|
|
23
|
+
);
|
|
22
24
|
expect(getByText("Request grant")).toMatchSnapshot();
|
|
23
25
|
});
|
|
24
26
|
|
|
@@ -31,13 +33,16 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
31
33
|
removeGrantRequestFromCart: removeRequest,
|
|
32
34
|
authorized: true,
|
|
33
35
|
};
|
|
34
|
-
const { findByText } = render(
|
|
36
|
+
const { findByText } = render(
|
|
37
|
+
<StructureGrantRequestButton {...props} />,
|
|
38
|
+
renderOpts
|
|
39
|
+
);
|
|
35
40
|
userEvent.click(await findByText("Request grant"));
|
|
36
41
|
await waitFor(() => {
|
|
37
42
|
expect(addRequest.mock.calls.length).toBe(1);
|
|
38
43
|
expect(removeRequest.mock.calls.length).toBe(0);
|
|
39
44
|
});
|
|
40
|
-
})
|
|
45
|
+
});
|
|
41
46
|
|
|
42
47
|
it("can be clickable", async () => {
|
|
43
48
|
const addRequest = jest.fn();
|
|
@@ -48,13 +53,16 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
48
53
|
removeGrantRequestFromCart: removeRequest,
|
|
49
54
|
authorized: true,
|
|
50
55
|
};
|
|
51
|
-
const { findByText } = render(
|
|
56
|
+
const { findByText } = render(
|
|
57
|
+
<StructureGrantRequestButton {...props} />,
|
|
58
|
+
renderOpts
|
|
59
|
+
);
|
|
52
60
|
userEvent.click(await findByText("Pending request"));
|
|
53
61
|
await waitFor(() => {
|
|
54
62
|
expect(addRequest.mock.calls.length).toBe(0);
|
|
55
63
|
expect(removeRequest.mock.calls.length).toBe(1);
|
|
56
64
|
});
|
|
57
|
-
})
|
|
65
|
+
});
|
|
58
66
|
|
|
59
67
|
it("renders nothing if does not have permissions", async () => {
|
|
60
68
|
const addRequest = jest.fn();
|
|
@@ -65,10 +73,13 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
65
73
|
removeGrantRequestFromCart: removeRequest,
|
|
66
74
|
authorized: false,
|
|
67
75
|
};
|
|
68
|
-
const component = render(
|
|
76
|
+
const component = render(
|
|
77
|
+
<StructureGrantRequestButton {...props} />,
|
|
78
|
+
renderOpts
|
|
79
|
+
);
|
|
69
80
|
const { queryAllByText } = component;
|
|
70
81
|
expect(queryAllByText("Request grant")).toHaveLength(0);
|
|
71
82
|
expect(queryAllByText("Pending request")).toHaveLength(0);
|
|
72
83
|
expect(component).toMatchSnapshot();
|
|
73
|
-
})
|
|
84
|
+
});
|
|
74
85
|
});
|
|
@@ -17,6 +17,14 @@ exports[`<DictionaryRoutes /> matches the latest snapshot 1`] = `
|
|
|
17
17
|
path="/grants_requests/checkout"
|
|
18
18
|
render={[Function]}
|
|
19
19
|
/>
|
|
20
|
+
<Route
|
|
21
|
+
path="/grants"
|
|
22
|
+
render={[Function]}
|
|
23
|
+
/>
|
|
24
|
+
<Route
|
|
25
|
+
path="/my_grants"
|
|
26
|
+
render={[Function]}
|
|
27
|
+
/>
|
|
20
28
|
<Route
|
|
21
29
|
path="/structure_tags"
|
|
22
30
|
render={[Function]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<GrantDateFilter/> matches the latest snapshot 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<DateRangeFilter
|
|
6
|
+
defaultValues={Object {}}
|
|
7
|
+
label={
|
|
8
|
+
<FormattedMessage
|
|
9
|
+
id="grant.start_date"
|
|
10
|
+
values={Object {}}
|
|
11
|
+
/>
|
|
12
|
+
}
|
|
13
|
+
name="start_date,end_date"
|
|
14
|
+
/>
|
|
15
|
+
</Fragment>
|
|
16
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<GrantsLabelResults /> matches the latest snapshot 1`] = `
|
|
4
|
+
<Label
|
|
5
|
+
className="grants-label-results"
|
|
6
|
+
>
|
|
7
|
+
<FormattedMessage
|
|
8
|
+
id="grants.retrieved.results"
|
|
9
|
+
values={
|
|
10
|
+
Object {
|
|
11
|
+
"count": 22,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/>
|
|
15
|
+
</Label>
|
|
16
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<GrantsLoader /> matches the latest snapshot 1`] = `
|
|
4
|
+
<GrantsLoader
|
|
5
|
+
clearGrants={[MockFunction]}
|
|
6
|
+
fetchGrants={
|
|
7
|
+
[MockFunction] {
|
|
8
|
+
"calls": Array [
|
|
9
|
+
Array [
|
|
10
|
+
Object {
|
|
11
|
+
"onlyMyGrants": false,
|
|
12
|
+
"payload": Object {},
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
],
|
|
16
|
+
"results": Array [
|
|
17
|
+
Object {
|
|
18
|
+
"type": "return",
|
|
19
|
+
"value": undefined,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
grantsLoading={false}
|
|
25
|
+
payload={Object {}}
|
|
26
|
+
/>
|
|
27
|
+
`;
|