@truedat/dd 4.44.2 → 4.44.5
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 +23 -19
- 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/EditDomainPopup.js +1 -1
- package/src/components/FilteredNav.js +9 -9
- package/src/components/GrantFilters.js +1 -5
- package/src/components/GrantRequestApprovalPopup.js +0 -1
- package/src/components/ImplementationStructuresLoader.js +14 -11
- package/src/components/PendingStructureNotes.js +11 -5
- 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/StructureConfidentialButton.js +1 -1
- package/src/components/StructureFilters.js +1 -5
- package/src/components/StructureNotesEdit.js +6 -6
- package/src/components/StructureProperties.js +4 -1
- package/src/components/StructureTagsRoutes.js +0 -1
- package/src/components/StructureTypesCrumbs.js +0 -1
- package/src/components/StructureVersionListItem.js +2 -2
- 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__/LineageRoutes.spec.js +4 -4
- 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__/StructureConfidentialButton.spec.js +26 -30
- 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 +5 -25
- package/src/components/__tests__/StructureProperties.spec.js +6 -8
- package/src/components/__tests__/StructureTagForm.spec.js +1 -3
- package/src/components/__tests__/StructureVersionListItem.spec.js +4 -4
- 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__/LineageRoutes.spec.js.snap +1 -20
- package/src/components/__tests__/__snapshots__/PendingStructureNotes.spec.js.snap +3 -3
- package/src/components/__tests__/__snapshots__/ProfileExecution.spec.js.snap +2 -1
- 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__/StructureConfidentialButton.spec.js.snap +13 -33
- 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/components/__tests__/__snapshots__/StructureProperties.spec.js.snap +76 -71
- package/src/components/__tests__/__snapshots__/StructureVersionListItem.spec.js.snap +31 -64
- 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/selectors/getTabVisibility.js +1 -4
- package/src/components/__tests__/__snapshots__/ImplementationStructuresLoader.spec.js.snap +0 -30
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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 ReferenceDatasetForm from "../ReferenceDatasetForm";
|
|
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("<ReferenceDatasetForm />", () => {
|
|
18
|
+
const onSubmit = jest.fn();
|
|
19
|
+
const props = { dataset, onSubmit };
|
|
20
|
+
|
|
21
|
+
it("matches the latest snapshot", async () => {
|
|
22
|
+
const { container, findByText } = render(
|
|
23
|
+
<ReferenceDatasetForm {...props} />
|
|
24
|
+
);
|
|
25
|
+
await findByText("Save");
|
|
26
|
+
expect(container).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("form is disabled until modified", async () => {
|
|
30
|
+
const { findByText, findByRole, getByRole, queryByRole } = render(
|
|
31
|
+
<ReferenceDatasetForm {...props} />
|
|
32
|
+
);
|
|
33
|
+
await findByText("Save");
|
|
34
|
+
|
|
35
|
+
// Form is disabled until modified
|
|
36
|
+
expect(queryByRole("button", { name: /Save/ })).toBeDisabled();
|
|
37
|
+
userEvent.type(await findByRole("textbox"), "bar");
|
|
38
|
+
|
|
39
|
+
// Form is now enabled
|
|
40
|
+
await waitFor(() =>
|
|
41
|
+
expect(getByRole("button", { name: /Save/ })).not.toBeDisabled()
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Submit
|
|
45
|
+
await waitFor(() => {
|
|
46
|
+
userEvent.click(getByRole("button", { name: /Save/ }));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(onSubmit).toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetHeader from "../ReferenceDatasetHeader";
|
|
4
|
+
|
|
5
|
+
const dataset = {
|
|
6
|
+
id: "123",
|
|
7
|
+
name: "foo",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
describe("<ReferenceDatasetHeader />", () => {
|
|
11
|
+
const props = { dataset };
|
|
12
|
+
|
|
13
|
+
it("matches the latest snapshot", () => {
|
|
14
|
+
const { container } = render(<ReferenceDatasetHeader {...props} />);
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetRoutes from "../ReferenceDatasetRoutes";
|
|
4
|
+
import {
|
|
5
|
+
REFERENCE_DATASET_QUERY,
|
|
6
|
+
REFERENCE_DATASETS_QUERY,
|
|
7
|
+
} from "../../api/queries";
|
|
8
|
+
|
|
9
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
10
|
+
useAuthorized: jest.fn(() => true),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const dataset = {
|
|
14
|
+
__typename: "ReferenceDataset",
|
|
15
|
+
id: "123",
|
|
16
|
+
name: "foo",
|
|
17
|
+
headers: ["foo", "bar", "baz"],
|
|
18
|
+
rowCount: 2,
|
|
19
|
+
rows: [
|
|
20
|
+
["foo1", "bar1", "baz1"],
|
|
21
|
+
["foo2", "bar2", "baz2"],
|
|
22
|
+
],
|
|
23
|
+
updatedAt: "2020-01-01T00:00:00.000Z",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const datasetsMock = {
|
|
27
|
+
request: { query: REFERENCE_DATASETS_QUERY },
|
|
28
|
+
result: { data: { referenceDatasets: [dataset] } },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const datasetMock = {
|
|
32
|
+
request: { query: REFERENCE_DATASET_QUERY, variables: { id: "123" } },
|
|
33
|
+
result: { data: { referenceDataset: dataset } },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe("<ReferenceDatasetRoutes />", () => {
|
|
37
|
+
const props = { dataset };
|
|
38
|
+
|
|
39
|
+
it("matches the latest snapshot (list route)", async () => {
|
|
40
|
+
const renderOpts = {
|
|
41
|
+
routes: ["/referenceDatasets"],
|
|
42
|
+
mocks: [datasetsMock],
|
|
43
|
+
};
|
|
44
|
+
const { container, findByText } = render(
|
|
45
|
+
<ReferenceDatasetRoutes {...props} />,
|
|
46
|
+
renderOpts
|
|
47
|
+
);
|
|
48
|
+
await findByText("foo");
|
|
49
|
+
expect(container).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("matches the latest snapshot (create route)", async () => {
|
|
53
|
+
const renderOpts = { routes: ["/referenceDatasets/new"] };
|
|
54
|
+
const { container, findByRole } = render(
|
|
55
|
+
<ReferenceDatasetRoutes {...props} />,
|
|
56
|
+
renderOpts
|
|
57
|
+
);
|
|
58
|
+
await findByRole("button", { name: "Save" });
|
|
59
|
+
expect(container).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("matches the latest snapshot (view route)", async () => {
|
|
63
|
+
const renderOpts = {
|
|
64
|
+
routes: ["/referenceDatasets/123"],
|
|
65
|
+
mocks: [datasetMock],
|
|
66
|
+
};
|
|
67
|
+
const { container, findByText } = render(
|
|
68
|
+
<ReferenceDatasetRoutes {...props} />,
|
|
69
|
+
renderOpts
|
|
70
|
+
);
|
|
71
|
+
await findByText("baz2");
|
|
72
|
+
expect(container).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetTable from "../ReferenceDatasetTable";
|
|
4
|
+
|
|
5
|
+
const props = {
|
|
6
|
+
headers: ["foo", "bar", "baz"],
|
|
7
|
+
rows: [
|
|
8
|
+
["foo1", "bar1", "baz1"],
|
|
9
|
+
["foo2", "bar2", "baz2"],
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("<ReferenceDatasetTable />", () => {
|
|
14
|
+
it("matches the latest snapshot", () => {
|
|
15
|
+
const { container } = render(<ReferenceDatasetTable {...props} />);
|
|
16
|
+
expect(container).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasets from "../ReferenceDatasets";
|
|
4
|
+
import { REFERENCE_DATASETS_QUERY } from "../../api/queries";
|
|
5
|
+
|
|
6
|
+
const dataset = {
|
|
7
|
+
__typename: "ReferenceDataset",
|
|
8
|
+
id: "123",
|
|
9
|
+
name: "foo",
|
|
10
|
+
headers: ["foo", "bar", "baz"],
|
|
11
|
+
rowCount: 2,
|
|
12
|
+
rows: [
|
|
13
|
+
["foo1", "bar1", "baz1"],
|
|
14
|
+
["foo2", "bar2", "baz2"],
|
|
15
|
+
],
|
|
16
|
+
updatedAt: "2020-01-01T00:00:00.000Z",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const datasetsMock = {
|
|
20
|
+
request: { query: REFERENCE_DATASETS_QUERY },
|
|
21
|
+
result: { data: { referenceDatasets: [dataset] } },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const renderOpts = { mocks: [datasetsMock] };
|
|
25
|
+
|
|
26
|
+
describe("<ReferenceDatasets />", () => {
|
|
27
|
+
it("matches the latest snapshot", async () => {
|
|
28
|
+
const { container, findByText } = render(<ReferenceDatasets />, renderOpts);
|
|
29
|
+
await findByText("One dataset found");
|
|
30
|
+
expect(container).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ReferenceDatasetsTable from "../ReferenceDatasetsTable";
|
|
4
|
+
|
|
5
|
+
const props = {
|
|
6
|
+
datasets: [
|
|
7
|
+
{
|
|
8
|
+
id: "123",
|
|
9
|
+
name: "foo",
|
|
10
|
+
headers: ["foo", "bar", "baz"],
|
|
11
|
+
rowCount: 2,
|
|
12
|
+
updatedAt: "2020-01-01T00:00:00.000Z",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<ReferenceDatasetsTable />", () => {
|
|
18
|
+
it("matches the latest snapshot", () => {
|
|
19
|
+
const { container } = render(<ReferenceDatasetsTable {...props} />);
|
|
20
|
+
expect(container).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import StructureConfidentialButton from "../StructureConfidentialButton";
|
|
4
4
|
|
|
5
5
|
describe("<StructureConfidentialButton />", () => {
|
|
6
|
-
const
|
|
7
|
-
const props = {
|
|
6
|
+
const state = {
|
|
8
7
|
structure: { id: 1, confidential: false },
|
|
9
8
|
structureUpdating: false,
|
|
10
|
-
updateStructure: updateStructure,
|
|
11
9
|
userPermissions: {
|
|
12
10
|
update: true,
|
|
13
|
-
confidential: true
|
|
14
|
-
}
|
|
11
|
+
confidential: true,
|
|
12
|
+
},
|
|
15
13
|
};
|
|
14
|
+
|
|
16
15
|
it("matches the latest snapshot", () => {
|
|
17
|
-
const
|
|
18
|
-
expect(
|
|
16
|
+
const { container } = render(<StructureConfidentialButton />, { state });
|
|
17
|
+
expect(container).toMatchSnapshot();
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
confidential: true
|
|
26
|
-
}
|
|
19
|
+
|
|
20
|
+
it("matches snapshot without update permission", () => {
|
|
21
|
+
const userPermissions = {
|
|
22
|
+
update: false,
|
|
23
|
+
confidential: true,
|
|
27
24
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
expect(
|
|
25
|
+
const { container } = render(<StructureConfidentialButton />, {
|
|
26
|
+
state: { ...state, userPermissions },
|
|
27
|
+
});
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
confidential: false
|
|
38
|
-
}
|
|
31
|
+
it("matches snapshot without confidential permission", () => {
|
|
32
|
+
const userPermissions = {
|
|
33
|
+
update: true,
|
|
34
|
+
confidential: false,
|
|
39
35
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
);
|
|
43
|
-
expect(
|
|
36
|
+
const { container } = render(<StructureConfidentialButton />, {
|
|
37
|
+
state: { ...state, userPermissions },
|
|
38
|
+
});
|
|
39
|
+
expect(container).toMatchSnapshot();
|
|
44
40
|
});
|
|
45
41
|
});
|
|
@@ -2,25 +2,15 @@ import React from "react";
|
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { render } from "@truedat/test/render";
|
|
5
|
-
|
|
6
5
|
import { StructureGrantRequestButton } from "../StructureGrantRequestButton";
|
|
7
6
|
|
|
8
|
-
import messages from "../../messages/en";
|
|
9
|
-
|
|
10
|
-
const renderOpts = {
|
|
11
|
-
messages: { en: messages },
|
|
12
|
-
};
|
|
13
|
-
|
|
14
7
|
describe("<StructureGrantRequestButton />", () => {
|
|
15
8
|
it("render a button", async () => {
|
|
16
9
|
const props = {
|
|
17
10
|
requested: false,
|
|
18
11
|
authorized: true,
|
|
19
12
|
};
|
|
20
|
-
const { getByText } = render(
|
|
21
|
-
<StructureGrantRequestButton {...props} />,
|
|
22
|
-
renderOpts
|
|
23
|
-
);
|
|
13
|
+
const { getByText } = render(<StructureGrantRequestButton {...props} />);
|
|
24
14
|
expect(getByText("Request grant")).toMatchSnapshot();
|
|
25
15
|
});
|
|
26
16
|
|
|
@@ -33,10 +23,7 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
33
23
|
removeGrantRequestFromCart: removeRequest,
|
|
34
24
|
authorized: true,
|
|
35
25
|
};
|
|
36
|
-
const { findByText } = render(
|
|
37
|
-
<StructureGrantRequestButton {...props} />,
|
|
38
|
-
renderOpts
|
|
39
|
-
);
|
|
26
|
+
const { findByText } = render(<StructureGrantRequestButton {...props} />);
|
|
40
27
|
userEvent.click(await findByText("Request grant"));
|
|
41
28
|
await waitFor(() => {
|
|
42
29
|
expect(addRequest.mock.calls.length).toBe(1);
|
|
@@ -53,10 +40,7 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
53
40
|
removeGrantRequestFromCart: removeRequest,
|
|
54
41
|
authorized: true,
|
|
55
42
|
};
|
|
56
|
-
const { findByText } = render(
|
|
57
|
-
<StructureGrantRequestButton {...props} />,
|
|
58
|
-
renderOpts
|
|
59
|
-
);
|
|
43
|
+
const { findByText } = render(<StructureGrantRequestButton {...props} />);
|
|
60
44
|
userEvent.click(await findByText("Pending request"));
|
|
61
45
|
await waitFor(() => {
|
|
62
46
|
expect(addRequest.mock.calls.length).toBe(0);
|
|
@@ -73,10 +57,7 @@ describe("<StructureGrantRequestButton />", () => {
|
|
|
73
57
|
removeGrantRequestFromCart: removeRequest,
|
|
74
58
|
authorized: false,
|
|
75
59
|
};
|
|
76
|
-
const component = render(
|
|
77
|
-
<StructureGrantRequestButton {...props} />,
|
|
78
|
-
renderOpts
|
|
79
|
-
);
|
|
60
|
+
const component = render(<StructureGrantRequestButton {...props} />);
|
|
80
61
|
const { queryAllByText } = component;
|
|
81
62
|
expect(queryAllByText("Request grant")).toHaveLength(0);
|
|
82
63
|
expect(queryAllByText("Pending request")).toHaveLength(0);
|
|
@@ -4,17 +4,6 @@ import { waitFor } from "@testing-library/react";
|
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
import { render } from "@truedat/test/render";
|
|
6
6
|
import { StructureNoteActions } from "../StructureNoteActions";
|
|
7
|
-
import messages from "../../messages/en";
|
|
8
|
-
|
|
9
|
-
const renderOpts = {
|
|
10
|
-
messages: {
|
|
11
|
-
en: {
|
|
12
|
-
...messages,
|
|
13
|
-
"confirmation.no": "No",
|
|
14
|
-
"confirmation.yes": "Yes",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
7
|
|
|
19
8
|
describe("<StructureNoteActions />", () => {
|
|
20
9
|
it("matches the latest snapshot", () => {
|
|
@@ -47,10 +36,7 @@ describe("<StructureNoteActions />", () => {
|
|
|
47
36
|
structure: { id: 1 },
|
|
48
37
|
};
|
|
49
38
|
|
|
50
|
-
const { findByText } = render(
|
|
51
|
-
<StructureNoteActions {...props} />,
|
|
52
|
-
renderOpts
|
|
53
|
-
);
|
|
39
|
+
const { findByText } = render(<StructureNoteActions {...props} />);
|
|
54
40
|
|
|
55
41
|
userEvent.click(await findByText(/Delete/));
|
|
56
42
|
|
|
@@ -85,10 +71,7 @@ describe("<StructureNoteActions />", () => {
|
|
|
85
71
|
structure: { id: 1 },
|
|
86
72
|
};
|
|
87
73
|
|
|
88
|
-
const { findByText } = render(
|
|
89
|
-
<StructureNoteActions {...props} />,
|
|
90
|
-
renderOpts
|
|
91
|
-
);
|
|
74
|
+
const { findByText } = render(<StructureNoteActions {...props} />);
|
|
92
75
|
|
|
93
76
|
userEvent.click(await findByText(/Send to approve/));
|
|
94
77
|
|