@truedat/dd 4.44.1 → 4.44.4
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 +10 -0
- package/package.json +6 -6
- package/src/api/mutations.js +27 -0
- package/src/api/queries.js +24 -0
- package/src/api.js +2 -0
- package/src/components/DictionaryRoutes.js +7 -5
- package/src/components/FilteredNav.js +9 -9
- package/src/components/GrantRequestApprovalPopup.js +0 -1
- package/src/components/ImplementationStructuresLoader.js +14 -11
- package/src/components/PendingStructureNotes.js +10 -4
- package/src/components/ReferenceDataset.js +23 -0
- package/src/components/ReferenceDatasetActions.js +88 -0
- package/src/components/ReferenceDatasetBreadcrumbs.js +22 -0
- package/src/components/ReferenceDatasetCreate.js +36 -0
- package/src/components/ReferenceDatasetDetail.js +42 -0
- package/src/components/ReferenceDatasetForm.js +109 -0
- package/src/components/ReferenceDatasetHeader.js +32 -0
- package/src/components/ReferenceDatasetRoutes.js +56 -0
- package/src/components/ReferenceDatasetTable.js +42 -0
- package/src/components/ReferenceDatasets.js +61 -0
- package/src/components/ReferenceDatasetsTable.js +105 -0
- package/src/components/StructureTagsRoutes.js +0 -1
- package/src/components/StructureTypesCrumbs.js +0 -1
- package/src/components/StructureView.js +1 -3
- package/src/components/SystemForm.js +1 -1
- package/src/components/__tests__/ImplementationStructuresLoader.spec.js +12 -54
- package/src/components/__tests__/LineageEventsTable.spec.js +2 -7
- package/src/components/__tests__/PendingStructureNoteRow.spec.js +1 -17
- package/src/components/__tests__/PendingStructureNotes.spec.js +5 -33
- package/src/components/__tests__/ReferenceDataset.spec.js +64 -0
- package/src/components/__tests__/ReferenceDatasetActions.spec.js +17 -0
- package/src/components/__tests__/ReferenceDatasetBreadcrumbs.spec.js +12 -0
- package/src/components/__tests__/ReferenceDatasetCreate.spec.js +12 -0
- package/src/components/__tests__/ReferenceDatasetDetail.spec.js +37 -0
- package/src/components/__tests__/ReferenceDatasetForm.spec.js +51 -0
- package/src/components/__tests__/ReferenceDatasetHeader.spec.js +17 -0
- package/src/components/__tests__/ReferenceDatasetRoutes.spec.js +74 -0
- package/src/components/__tests__/ReferenceDatasetTable.spec.js +18 -0
- package/src/components/__tests__/ReferenceDatasets.spec.js +32 -0
- package/src/components/__tests__/ReferenceDatasetsTable.spec.js +22 -0
- package/src/components/__tests__/StructureGrantRequestButton.spec.js +4 -23
- package/src/components/__tests__/StructureNoteActions.spec.js +2 -19
- package/src/components/__tests__/StructureNotes.spec.js +3 -15
- package/src/components/__tests__/StructureNotesEdit.spec.js +3 -16
- package/src/components/__tests__/StructureTagForm.spec.js +1 -3
- package/src/components/__tests__/StructuresOptions.spec.js +1 -7
- package/src/components/__tests__/StructuresUploadEventsTable.spec.js +3 -4
- package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +4 -0
- package/src/components/__tests__/__snapshots__/PendingStructureNotes.spec.js.snap +3 -3
- package/src/components/__tests__/__snapshots__/ReferenceDataset.spec.js.snap +365 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetActions.spec.js.snap +65 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetBreadcrumbs.spec.js.snap +25 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetCreate.spec.js.snap +98 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetDetail.spec.js.snap +135 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetForm.spec.js.snap +61 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetHeader.spec.js.snap +95 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetRoutes.spec.js.snap +414 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetTable.spec.js.snap +75 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasets.spec.js.snap +128 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetsTable.spec.js.snap +86 -0
- package/src/components/__tests__/__snapshots__/StructureNavClassified.spec.js.snap +2 -2
- package/src/components/__tests__/__snapshots__/StructureNotes.spec.js.snap +9 -9
- package/src/components/__tests__/__snapshots__/StructureNotesEdit.spec.js.snap +2 -2
- package/src/messages/en.js +18 -0
- package/src/messages/es.js +20 -0
- package/src/reducers/__tests__/ddMessage.spec.js +26 -5
- package/src/reducers/__tests__/graph.spec.js +1 -6
- package/src/reducers/__tests__/referenceDatasetSaving.spec.js +44 -0
- package/src/reducers/__tests__/structureRedirect.spec.js +37 -13
- package/src/reducers/ddMessage.js +26 -1
- package/src/reducers/index.js +2 -0
- package/src/reducers/referenceDatasetSaving.js +16 -0
- package/src/reducers/structureRedirect.js +36 -15
- package/src/reducers/structuresUploadEvents.js +0 -1
- package/src/routines.js +35 -74
- package/src/sagas/__tests__/createReferenceDataset.spec.js +90 -0
- package/src/sagas/__tests__/deleteReferenceDataset.spec.js +81 -0
- package/src/sagas/__tests__/updateReferenceDataset.spec.js +116 -0
- package/src/sagas/createReferenceDataset.js +34 -0
- package/src/sagas/deleteReferenceDataset.js +29 -0
- package/src/sagas/downloadReferenceDataset.js +44 -0
- package/src/sagas/index.js +31 -22
- package/src/sagas/updateReferenceDataset.js +35 -0
- package/src/selectors/getRelationSortingCriteria.js +3 -5
- package/src/components/__tests__/__snapshots__/ImplementationStructuresLoader.spec.js.snap +0 -30
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Route, Switch, useParams } from "react-router-dom";
|
|
4
|
+
import { useQuery } from "@apollo/client";
|
|
5
|
+
import { Unauthorized, Loading } from "@truedat/core/components";
|
|
6
|
+
import { useAuthorized } from "@truedat/core/hooks";
|
|
7
|
+
import {
|
|
8
|
+
REFERENCE_DATASETS,
|
|
9
|
+
REFERENCE_DATASET_NEW,
|
|
10
|
+
REFERENCE_DATASET,
|
|
11
|
+
} from "@truedat/core/routes";
|
|
12
|
+
import { REFERENCE_DATASET_QUERY } from "../api/queries";
|
|
13
|
+
import ReferenceDataset from "./ReferenceDataset";
|
|
14
|
+
import ReferenceDatasets from "./ReferenceDatasets";
|
|
15
|
+
import ReferenceDatasetCreate from "./ReferenceDatasetCreate";
|
|
16
|
+
|
|
17
|
+
export const DatasetLoader = () => {
|
|
18
|
+
const { id } = useParams();
|
|
19
|
+
const { loading, error, data } = useQuery(REFERENCE_DATASET_QUERY, {
|
|
20
|
+
variables: { id },
|
|
21
|
+
});
|
|
22
|
+
if (error) return null;
|
|
23
|
+
if (loading) return <Loading />;
|
|
24
|
+
const dataset = data?.referenceDataset;
|
|
25
|
+
return _.isEmpty(dataset) ? null : <ReferenceDataset dataset={dataset} />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const AuthorizedReferenceDatasetRoutes = () => (
|
|
29
|
+
<Switch>
|
|
30
|
+
<Route
|
|
31
|
+
path={REFERENCE_DATASET_NEW}
|
|
32
|
+
exact
|
|
33
|
+
render={() => <ReferenceDatasetCreate />}
|
|
34
|
+
/>
|
|
35
|
+
<Route
|
|
36
|
+
path={REFERENCE_DATASETS}
|
|
37
|
+
exact
|
|
38
|
+
render={() => <ReferenceDatasets />}
|
|
39
|
+
/>
|
|
40
|
+
<Route path={REFERENCE_DATASET} render={() => <DatasetLoader />} />
|
|
41
|
+
</Switch>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const ReferenceDatasetRoutes = () => {
|
|
45
|
+
const authorized = useAuthorized();
|
|
46
|
+
return (
|
|
47
|
+
<Route
|
|
48
|
+
path={REFERENCE_DATASETS}
|
|
49
|
+
render={() =>
|
|
50
|
+
authorized ? <AuthorizedReferenceDatasetRoutes /> : <Unauthorized />
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default ReferenceDatasetRoutes;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Table } from "semantic-ui-react";
|
|
5
|
+
|
|
6
|
+
const truncateOpts = { length: 100 };
|
|
7
|
+
|
|
8
|
+
export const DataRow = ({ values }) => (
|
|
9
|
+
<Table.Row>
|
|
10
|
+
{values.map((value, key) => (
|
|
11
|
+
<Table.Cell key={key}>{_.truncate(truncateOpts)(value)}</Table.Cell>
|
|
12
|
+
))}
|
|
13
|
+
</Table.Row>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
DataRow.propTypes = {
|
|
17
|
+
values: PropTypes.arrayOf(PropTypes.string),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ReferenceDatasetTable = ({ headers = [], rows = [] }) => (
|
|
21
|
+
<Table compact basic="very">
|
|
22
|
+
<Table.Header>
|
|
23
|
+
<Table.Row>
|
|
24
|
+
{headers.map((text, key) => (
|
|
25
|
+
<Table.HeaderCell key={key} content={text} />
|
|
26
|
+
))}
|
|
27
|
+
</Table.Row>
|
|
28
|
+
</Table.Header>
|
|
29
|
+
<Table.Body>
|
|
30
|
+
{rows.map((values, key) => (
|
|
31
|
+
<DataRow key={key} values={values} />
|
|
32
|
+
))}
|
|
33
|
+
</Table.Body>
|
|
34
|
+
</Table>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
ReferenceDatasetTable.propTypes = {
|
|
38
|
+
headers: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
39
|
+
rows: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)).isRequired,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ReferenceDatasetTable;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { matchSorter } from "match-sorter";
|
|
4
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import { Button, Header, Icon, Input, Segment } from "semantic-ui-react";
|
|
7
|
+
import { useQuery } from "@apollo/client";
|
|
8
|
+
import { Loading } from "@truedat/core/components";
|
|
9
|
+
import { REFERENCE_DATASET_NEW } from "@truedat/core/routes";
|
|
10
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
11
|
+
import { REFERENCE_DATASETS_QUERY } from "../api/queries";
|
|
12
|
+
import ReferenceDatasetsTable from "./ReferenceDatasetsTable";
|
|
13
|
+
|
|
14
|
+
const sortByName = _.sortBy([({ name }) => lowerDeburrTrim(name), "name"]);
|
|
15
|
+
|
|
16
|
+
export const ReferenceDatasets = () => {
|
|
17
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
18
|
+
const { formatMessage } = useIntl();
|
|
19
|
+
const { loading, error, data } = useQuery(REFERENCE_DATASETS_QUERY);
|
|
20
|
+
if (error) return null;
|
|
21
|
+
if (loading) return <Loading />;
|
|
22
|
+
const items = data?.referenceDatasets;
|
|
23
|
+
const datasets =
|
|
24
|
+
searchTerm === ""
|
|
25
|
+
? sortByName(items)
|
|
26
|
+
: matchSorter(items, searchTerm, {
|
|
27
|
+
keys: ["name", "headers", "rowCount", "updatedAt"],
|
|
28
|
+
threshold: matchSorter.rankings.CONTAINS,
|
|
29
|
+
});
|
|
30
|
+
return (
|
|
31
|
+
<Segment>
|
|
32
|
+
<Header as="h2">
|
|
33
|
+
<Button
|
|
34
|
+
floated="right"
|
|
35
|
+
primary
|
|
36
|
+
as={Link}
|
|
37
|
+
to={REFERENCE_DATASET_NEW}
|
|
38
|
+
content={formatMessage({ id: "referenceDatasets.actions.create" })}
|
|
39
|
+
/>
|
|
40
|
+
<Icon name="list ol" circular />
|
|
41
|
+
<Header.Content>
|
|
42
|
+
<FormattedMessage id="referenceDatasets.header" />
|
|
43
|
+
<Header.Subheader>
|
|
44
|
+
<FormattedMessage id="referenceDatasets.subheader" />
|
|
45
|
+
</Header.Subheader>
|
|
46
|
+
</Header.Content>
|
|
47
|
+
</Header>
|
|
48
|
+
<Input
|
|
49
|
+
onChange={(_e, { value }) => setSearchTerm(value)}
|
|
50
|
+
value={searchTerm}
|
|
51
|
+
icon={{ name: "search", link: true }}
|
|
52
|
+
placeholder={formatMessage({
|
|
53
|
+
id: "referenceDatasets.search.placeholder",
|
|
54
|
+
})}
|
|
55
|
+
/>
|
|
56
|
+
<ReferenceDatasetsTable datasets={datasets} />
|
|
57
|
+
</Segment>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default ReferenceDatasets;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Icon, Table } from "semantic-ui-react";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import Moment from "react-moment";
|
|
8
|
+
import { DateTime } from "@truedat/core/components";
|
|
9
|
+
import { linkTo } from "@truedat/core/routes";
|
|
10
|
+
|
|
11
|
+
export const HeaderRow = ({ onDateClick, relative }) => {
|
|
12
|
+
const { formatMessage } = useIntl();
|
|
13
|
+
return (
|
|
14
|
+
<Table.Row>
|
|
15
|
+
<Table.HeaderCell
|
|
16
|
+
content={formatMessage({ id: "referenceDataset.name" })}
|
|
17
|
+
/>
|
|
18
|
+
<Table.HeaderCell
|
|
19
|
+
content={formatMessage({ id: "referenceDataset.headers" })}
|
|
20
|
+
/>
|
|
21
|
+
<Table.HeaderCell
|
|
22
|
+
content={formatMessage({ id: "referenceDataset.rowCount" })}
|
|
23
|
+
textAlign="right"
|
|
24
|
+
/>
|
|
25
|
+
<Table.HeaderCell textAlign="right">
|
|
26
|
+
{formatMessage({ id: "referenceDataset.updatedAt" })}{" "}
|
|
27
|
+
<a onClick={onDateClick}>
|
|
28
|
+
<Icon name={relative ? "calendar outline" : "clock outline"} />
|
|
29
|
+
</a>
|
|
30
|
+
</Table.HeaderCell>
|
|
31
|
+
</Table.Row>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
HeaderRow.propTypes = {
|
|
36
|
+
relative: PropTypes.bool,
|
|
37
|
+
onDateClick: PropTypes.func,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const DatasetRow = ({
|
|
41
|
+
name,
|
|
42
|
+
id,
|
|
43
|
+
relative,
|
|
44
|
+
rowCount,
|
|
45
|
+
headers,
|
|
46
|
+
updatedAt,
|
|
47
|
+
}) => {
|
|
48
|
+
const { locale } = useIntl();
|
|
49
|
+
return (
|
|
50
|
+
<Table.Row>
|
|
51
|
+
<Table.Cell>
|
|
52
|
+
<Link to={linkTo.REFERENCE_DATASET({ id })}>{name}</Link>
|
|
53
|
+
</Table.Cell>
|
|
54
|
+
<Table.Cell content={_.truncate({ length: 90 })(_.join(", ")(headers))} />
|
|
55
|
+
<Table.Cell textAlign="right" width={1} content={rowCount} />
|
|
56
|
+
<Table.Cell textAlign="right" width={3}>
|
|
57
|
+
{relative ? (
|
|
58
|
+
<Moment locale={locale} fromNow date={updatedAt} />
|
|
59
|
+
) : (
|
|
60
|
+
<DateTime value={updatedAt} locale={locale} />
|
|
61
|
+
)}
|
|
62
|
+
</Table.Cell>
|
|
63
|
+
</Table.Row>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
DatasetRow.propTypes = {
|
|
68
|
+
headers: PropTypes.arrayOf(PropTypes.string),
|
|
69
|
+
id: PropTypes.string,
|
|
70
|
+
name: PropTypes.string,
|
|
71
|
+
relative: PropTypes.bool,
|
|
72
|
+
rowCount: PropTypes.number,
|
|
73
|
+
updatedAt: PropTypes.string,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const ReferenceDatasetsTable = ({ datasets }) => {
|
|
77
|
+
const { formatMessage } = useIntl();
|
|
78
|
+
const [relative, setRelative] = useState(true);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Table>
|
|
82
|
+
<caption className="text-right">
|
|
83
|
+
{formatMessage(
|
|
84
|
+
{ id: "referenceDatasets.count" },
|
|
85
|
+
{ count: _.size(datasets) }
|
|
86
|
+
)}
|
|
87
|
+
</caption>
|
|
88
|
+
<Table.Header>
|
|
89
|
+
<HeaderRow
|
|
90
|
+
relative={relative}
|
|
91
|
+
onDateClick={() => setRelative((value) => !value)}
|
|
92
|
+
/>
|
|
93
|
+
</Table.Header>
|
|
94
|
+
<Table.Body>
|
|
95
|
+
{datasets.map((props, key) => (
|
|
96
|
+
<DatasetRow key={key} relative={relative} {...props} />
|
|
97
|
+
))}
|
|
98
|
+
</Table.Body>
|
|
99
|
+
</Table>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
ReferenceDatasetsTable.propTypes = { datasets: PropTypes.array };
|
|
104
|
+
|
|
105
|
+
export default ReferenceDatasetsTable;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { linkTo } from "@truedat/core/routes";
|
|
3
|
-
import { Link } from "react-router-dom";
|
|
4
2
|
import React from "react";
|
|
5
3
|
import PropTypes from "prop-types";
|
|
6
4
|
import { connect } from "react-redux";
|
|
7
|
-
import { Grid, Segment
|
|
5
|
+
import { Grid, Segment } from "semantic-ui-react";
|
|
8
6
|
import FilteredNav from "./FilteredNav";
|
|
9
7
|
import StructureCrumbs from "./StructureCrumbs";
|
|
10
8
|
import StructureGrantCart from "./StructureGrantCart";
|
|
@@ -1,63 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import { ImplementationStructuresLoader } from "../ImplementationStructuresLoader";
|
|
4
4
|
|
|
5
|
-
jest.mock("@fluentui/react-component-event-listener", () => ({
|
|
6
|
-
documentRef: null,
|
|
7
|
-
windowRef: null,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock("react-redux", () => ({
|
|
11
|
-
...jest.requireActual("react-redux"),
|
|
12
|
-
useSelector: jest.fn(() => [1]),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const getProps = () => ({
|
|
16
|
-
fetchStructure: jest.fn(),
|
|
17
|
-
structureIds: [1, 2],
|
|
18
|
-
clearStructure: jest.fn(),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
5
|
describe("<ImplementationStructuresLoader/>", () => {
|
|
22
|
-
it("
|
|
23
|
-
const props =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const wrapper = mount(<ImplementationStructuresLoader {...props} />);
|
|
31
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
32
|
-
expect(props.fetchStructure).toHaveBeenCalledWith({ id: 2 });
|
|
33
|
-
|
|
34
|
-
wrapper.unmount();
|
|
35
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("call fetchStructure when next id of structures when field id is already in structures fields", () => {
|
|
39
|
-
const props = { ...getProps(), structureIds: [1, 2] };
|
|
40
|
-
const wrapper = mount(<ImplementationStructuresLoader {...props} />);
|
|
41
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
42
|
-
expect(props.fetchStructure).toHaveBeenCalledWith({ id: 2 });
|
|
43
|
-
|
|
44
|
-
wrapper.unmount();
|
|
6
|
+
it("calls fetchStructure on mount and clearStructure on unmount", () => {
|
|
7
|
+
const props = {
|
|
8
|
+
clearStructure: jest.fn(),
|
|
9
|
+
fetchStructure: jest.fn(),
|
|
10
|
+
structureIds: [42],
|
|
11
|
+
};
|
|
12
|
+
const { unmount } = render(<ImplementationStructuresLoader {...props} />);
|
|
13
|
+
expect(props.clearStructure).toHaveBeenCalledTimes(0);
|
|
45
14
|
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
46
|
-
|
|
15
|
+
expect(props.fetchStructure).toHaveBeenCalledWith({ id: 42 });
|
|
47
16
|
|
|
48
|
-
|
|
49
|
-
const props = getProps();
|
|
50
|
-
const wrapper = mount(<ImplementationStructuresLoader {...props} />);
|
|
51
|
-
expect(props.clearStructure).toHaveBeenCalledTimes(0);
|
|
52
|
-
wrapper.unmount();
|
|
17
|
+
unmount();
|
|
53
18
|
expect(props.clearStructure).toHaveBeenCalledTimes(1);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
it("calls fetchStructures when structureIds is updated", () => {
|
|
57
|
-
const props = getProps();
|
|
58
|
-
const wrapper = mount(<ImplementationStructuresLoader {...props} />);
|
|
59
|
-
wrapper.setProps({ structureIds: [6, 5] });
|
|
60
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(2);
|
|
61
|
-
expect(props.fetchStructure).toHaveBeenCalledWith({ id: 5 });
|
|
19
|
+
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
62
20
|
});
|
|
63
21
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
3
|
import { LineageEventsTable } from "../LineageEventsTable";
|
|
4
|
-
import en from "../../messages/en";
|
|
5
4
|
|
|
6
5
|
describe("<LineageEventsTable />", () => {
|
|
7
6
|
const lineageEvents = [
|
|
@@ -19,9 +18,7 @@ describe("<LineageEventsTable />", () => {
|
|
|
19
18
|
|
|
20
19
|
it("matches the latest snapshot", () => {
|
|
21
20
|
const props = { fetchLineageEvents, lineageEvents, lineageEventsLoading };
|
|
22
|
-
const { container } = render(<LineageEventsTable {...props}
|
|
23
|
-
messages: { en },
|
|
24
|
-
});
|
|
21
|
+
const { container } = render(<LineageEventsTable {...props} />);
|
|
25
22
|
expect(container).toMatchSnapshot();
|
|
26
23
|
});
|
|
27
24
|
|
|
@@ -31,9 +28,7 @@ describe("<LineageEventsTable />", () => {
|
|
|
31
28
|
lineageEvents: [],
|
|
32
29
|
lineageEventsLoading,
|
|
33
30
|
};
|
|
34
|
-
const { container } = render(<LineageEventsTable {...props}
|
|
35
|
-
messages: { en },
|
|
36
|
-
});
|
|
31
|
+
const { container } = render(<LineageEventsTable {...props} />);
|
|
37
32
|
expect(container).toMatchSnapshot();
|
|
38
33
|
});
|
|
39
34
|
});
|
|
@@ -3,21 +3,6 @@ import { waitFor } from "@testing-library/react";
|
|
|
3
3
|
import { render } from "@truedat/test/render";
|
|
4
4
|
import PendingStructureNoteRow from "../PendingStructureNoteRow";
|
|
5
5
|
|
|
6
|
-
const renderOpts = {
|
|
7
|
-
messages: {
|
|
8
|
-
en: {
|
|
9
|
-
"pendingStructureNotes.search.results.empty": "Empty",
|
|
10
|
-
"pendingStructureNotes.props.structure": "Structure",
|
|
11
|
-
"pendingStructureNotes.props.status": "Status",
|
|
12
|
-
"pendingStructureNotes.props.system": "System",
|
|
13
|
-
"pendingStructureNotes.props.domains": "Domains",
|
|
14
|
-
"structure.notes.status.deprecated": "Deprecated",
|
|
15
|
-
"structure.notes.status.draft": "Draft",
|
|
16
|
-
"structure.notes.status.rejected": "Rejected",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
6
|
const props = {
|
|
22
7
|
structureNote: {
|
|
23
8
|
id: "7207",
|
|
@@ -40,8 +25,7 @@ describe("<PendingStructureNoteRow />", () => {
|
|
|
40
25
|
<tbody>
|
|
41
26
|
<PendingStructureNoteRow {...props} />
|
|
42
27
|
</tbody>
|
|
43
|
-
</table
|
|
44
|
-
renderOpts
|
|
28
|
+
</table>
|
|
45
29
|
);
|
|
46
30
|
expect(container).toMatchSnapshot();
|
|
47
31
|
|
|
@@ -1,44 +1,17 @@
|
|
|
1
1
|
import React, { Suspense } from "react";
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
3
|
import { render } from "@truedat/test/render";
|
|
4
|
-
import {
|
|
5
|
-
PendingStructureNotes,
|
|
4
|
+
import PendingStructureNotes, {
|
|
6
5
|
STRUCTURE_NOTES,
|
|
7
6
|
} from "../PendingStructureNotes";
|
|
8
7
|
|
|
9
|
-
jest.mock("react-redux", () => ({
|
|
10
|
-
...jest.requireActual("react-redux"),
|
|
11
|
-
useSelector: jest.fn((selector) =>
|
|
12
|
-
selector({
|
|
13
|
-
systems: [
|
|
14
|
-
{ external_id: "some_external_id", id: 10, name: "some system" },
|
|
15
|
-
],
|
|
16
|
-
})
|
|
17
|
-
),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
8
|
const domains = [
|
|
21
9
|
{ id: 1, name: "Domain 1", level: 0 },
|
|
22
10
|
{ id: 2, name: "Domain 2", level: 0 },
|
|
23
11
|
];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"structure.notes.status.pending_approval": "Empty",
|
|
28
|
-
"pendingStructureNotes.filters": "Filters",
|
|
29
|
-
"pendingStructureNotes.props.status": "Status",
|
|
30
|
-
"pendingStructureNotes.props.system": "System",
|
|
31
|
-
"pendingStructureNotes.props.domains": "Domains",
|
|
32
|
-
"structure.notes.status.draft": "Draft",
|
|
33
|
-
"structure.notes.status.rejected": "Rejected",
|
|
34
|
-
"pendingStructureNotes.header": "Header",
|
|
35
|
-
"pendingStructureNotes.subheader": "Sub header",
|
|
36
|
-
"pendingStructureNotes.search.results.empty": "Serch Empty",
|
|
37
|
-
"domain.selector.placeholder": "Place Holder",
|
|
38
|
-
"domain.selector.label": "label",
|
|
39
|
-
"template.form.validation.empty_required": "empty required",
|
|
40
|
-
},
|
|
41
|
-
};
|
|
12
|
+
const systems = [
|
|
13
|
+
{ external_id: "some_external_id", id: 10, name: "some system" },
|
|
14
|
+
];
|
|
42
15
|
|
|
43
16
|
const structureNotes = {
|
|
44
17
|
loading: false,
|
|
@@ -77,8 +50,7 @@ const structureNotesMock = {
|
|
|
77
50
|
|
|
78
51
|
const renderOpts = {
|
|
79
52
|
mocks: [structureNotesMock],
|
|
80
|
-
|
|
81
|
-
state: { domains },
|
|
53
|
+
state: { domains, systems },
|
|
82
54
|
};
|
|
83
55
|
|
|
84
56
|
describe("<PendingStructureNotes />", () => {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
import ReferenceDataset from "../ReferenceDataset";
|
|
6
|
+
|
|
7
|
+
const dataset = {
|
|
8
|
+
id: "123",
|
|
9
|
+
name: "foo",
|
|
10
|
+
headers: ["foo", "bar", "baz"],
|
|
11
|
+
rows: [
|
|
12
|
+
["foo1", "bar1", "baz1"],
|
|
13
|
+
["foo2", "bar2", "baz2"],
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<ReferenceDataset /> show dataset view", () => {
|
|
18
|
+
const renderOpts = { routes: ["/referenceDatasets/123"] };
|
|
19
|
+
const props = { dataset };
|
|
20
|
+
|
|
21
|
+
it("matches the latest snapshot", () => {
|
|
22
|
+
const { container } = render(<ReferenceDataset {...props} />, renderOpts);
|
|
23
|
+
expect(container).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("contains the right number of rows", () => {
|
|
27
|
+
const { queryAllByRole } = render(
|
|
28
|
+
<ReferenceDataset {...props} />,
|
|
29
|
+
renderOpts
|
|
30
|
+
);
|
|
31
|
+
expect(queryAllByRole("row")).toHaveLength(3);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("<ReferenceDataset /> edit dataset view", () => {
|
|
36
|
+
const renderOpts = { routes: ["/referenceDatasets/123/edit"] };
|
|
37
|
+
const props = { dataset };
|
|
38
|
+
|
|
39
|
+
it("matches the latest snapshot", async () => {
|
|
40
|
+
const { container, findByText } = render(
|
|
41
|
+
<ReferenceDataset {...props} />,
|
|
42
|
+
renderOpts
|
|
43
|
+
);
|
|
44
|
+
await findByText("Save");
|
|
45
|
+
expect(container).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("form is disabled until modified", async () => {
|
|
49
|
+
const { findByText, findByRole, getByRole, queryByRole } = render(
|
|
50
|
+
<ReferenceDataset {...props} />,
|
|
51
|
+
renderOpts
|
|
52
|
+
);
|
|
53
|
+
await findByText("Save");
|
|
54
|
+
|
|
55
|
+
// Form is disabled until modified
|
|
56
|
+
expect(queryByRole("button", { name: /Save/ })).toBeDisabled();
|
|
57
|
+
userEvent.type(await findByRole("textbox"), "bar");
|
|
58
|
+
|
|
59
|
+
// Form is now enabled
|
|
60
|
+
await waitFor(() =>
|
|
61
|
+
expect(getByRole("button", { name: /Save/ })).not.toBeDisabled()
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetActions from "../ReferenceDatasetActions";
|
|
4
|
+
|
|
5
|
+
const dataset = {
|
|
6
|
+
id: "123",
|
|
7
|
+
name: "foo",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
describe("<ReferenceDatasetActions />", () => {
|
|
11
|
+
const props = { dataset };
|
|
12
|
+
|
|
13
|
+
it("matches the latest snapshot", () => {
|
|
14
|
+
const { container } = render(<ReferenceDatasetActions {...props} />);
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetBreadcrumbs from "../ReferenceDatasetBreadcrumbs";
|
|
4
|
+
|
|
5
|
+
describe("<ReferenceDatasetBreadcrumbs />", () => {
|
|
6
|
+
const props = { text: "foo" };
|
|
7
|
+
|
|
8
|
+
it("matches the latest snapshot", () => {
|
|
9
|
+
const { container } = render(<ReferenceDatasetBreadcrumbs {...props} />);
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetCreate from "../ReferenceDatasetCreate";
|
|
4
|
+
|
|
5
|
+
describe("<ReferenceDatasetCreate />", () => {
|
|
6
|
+
const props = { createReferenceDataset: jest.fn() };
|
|
7
|
+
|
|
8
|
+
it("matches the latest snapshot", () => {
|
|
9
|
+
const { container } = render(<ReferenceDatasetCreate {...props} />);
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetDetail from "../ReferenceDatasetDetail";
|
|
4
|
+
|
|
5
|
+
const dataset = {
|
|
6
|
+
id: "123",
|
|
7
|
+
name: "foo",
|
|
8
|
+
headers: ["foo", "bar", "baz"],
|
|
9
|
+
rows: [
|
|
10
|
+
["foo1", "bar1", "baz1"],
|
|
11
|
+
["foo2", "bar2", "baz2"],
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("<ReferenceDatasetDetail />", () => {
|
|
16
|
+
const props = { dataset };
|
|
17
|
+
|
|
18
|
+
it("matches the latest snapshot (edit route)", async () => {
|
|
19
|
+
const renderOpts = { routes: ["/referenceDatasets/123/edit"] };
|
|
20
|
+
const { container, findByRole } = render(
|
|
21
|
+
<ReferenceDatasetDetail {...props} />,
|
|
22
|
+
renderOpts
|
|
23
|
+
);
|
|
24
|
+
await findByRole("button", { name: "Save" });
|
|
25
|
+
expect(container).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("matches the latest snapshot (view route)", async () => {
|
|
29
|
+
const renderOpts = { routes: ["/referenceDatasets/123"] };
|
|
30
|
+
const { container, findByText } = render(
|
|
31
|
+
<ReferenceDatasetDetail {...props} />,
|
|
32
|
+
renderOpts
|
|
33
|
+
);
|
|
34
|
+
await findByText("foo");
|
|
35
|
+
expect(container).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
});
|