@truedat/ie 7.5.7 → 7.5.10
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 +42 -67
- package/src/ingests/components/EventRow.js +1 -2
- package/src/ingests/components/Events.js +3 -4
- package/src/ingests/components/FieldGroupTable.js +1 -2
- package/src/ingests/components/Ingest.js +1 -2
- package/src/ingests/components/IngestActions.js +1 -2
- package/src/ingests/components/IngestArchive.js +2 -3
- package/src/ingests/components/IngestArchiveLoader.js +16 -38
- package/src/ingests/components/IngestArchiveRow.js +5 -6
- package/src/ingests/components/IngestCompleteness.js +0 -1
- package/src/ingests/components/IngestCrumbs.js +2 -4
- package/src/ingests/components/IngestDetails.js +3 -3
- package/src/ingests/components/IngestDuplicate.js +5 -8
- package/src/ingests/components/IngestEdit.js +5 -8
- package/src/ingests/components/IngestExecutions.js +7 -7
- package/src/ingests/components/IngestExecutionsLoader.js +2 -2
- package/src/ingests/components/IngestFilters.js +5 -6
- package/src/ingests/components/IngestForm.js +4 -5
- package/src/ingests/components/IngestHeader.js +0 -1
- package/src/ingests/components/IngestLoader.js +16 -58
- package/src/ingests/components/IngestRoutes.js +272 -231
- package/src/ingests/components/IngestRow.js +4 -5
- package/src/ingests/components/IngestSelectedFilters.js +10 -10
- package/src/ingests/components/IngestSummary.js +0 -2
- package/src/ingests/components/IngestTabs.js +13 -13
- package/src/ingests/components/Ingests.js +0 -1
- package/src/ingests/components/IngestsActions.js +1 -2
- package/src/ingests/components/IngestsLabelResults.js +1 -2
- package/src/ingests/components/IngestsLoader.js +1 -1
- package/src/ingests/components/IngestsSearch.js +0 -1
- package/src/ingests/components/IngestsSelector.js +0 -1
- package/src/ingests/components/IngestsTable.js +85 -94
- package/src/ingests/components/IngestsTabs.js +2 -3
- package/src/ingests/components/__tests__/Events.spec.js +10 -10
- package/src/ingests/components/__tests__/Ingest.spec.js +16 -5
- package/src/ingests/components/__tests__/IngestActions.spec.js +7 -7
- package/src/ingests/components/__tests__/IngestArchive.spec.js +7 -7
- package/src/ingests/components/__tests__/IngestArchiveLoader.spec.js +70 -69
- package/src/ingests/components/__tests__/IngestArchiveRow.spec.js +10 -12
- package/src/ingests/components/__tests__/IngestCompleteness.spec.js +0 -1
- package/src/ingests/components/__tests__/IngestDetails.spec.js +10 -10
- package/src/ingests/components/__tests__/IngestExecutions.spec.js +7 -7
- package/src/ingests/components/__tests__/IngestExecutionsLoader.spec.js +38 -47
- package/src/ingests/components/__tests__/IngestFilters.spec.js +0 -1
- package/src/ingests/components/__tests__/IngestForm.spec.js +18 -40
- package/src/ingests/components/__tests__/IngestHeader.spec.js +9 -9
- package/src/ingests/components/__tests__/IngestLabelResults.spec.js +0 -1
- package/src/ingests/components/__tests__/IngestLoader.spec.js +70 -41
- package/src/ingests/components/__tests__/IngestRoutes.spec.js +176 -0
- package/src/ingests/components/__tests__/IngestSelectedFilters.spec.js +33 -5
- package/src/ingests/components/__tests__/Ingests.spec.js +32 -6
- package/src/ingests/components/__tests__/IngestsActions.spec.js +5 -5
- package/src/ingests/components/__tests__/IngestsLoader.spec.js +65 -36
- package/src/ingests/components/__tests__/IngestsTable.spec.js +16 -7
- package/src/ingests/components/__tests__/__snapshots__/Events.spec.js.snap +83 -43
- package/src/ingests/components/__tests__/__snapshots__/Ingest.spec.js.snap +27 -14
- package/src/ingests/components/__tests__/__snapshots__/IngestActions.spec.js.snap +19 -20
- package/src/ingests/components/__tests__/__snapshots__/IngestArchive.spec.js.snap +79 -65
- package/src/ingests/components/__tests__/__snapshots__/IngestArchiveLoader.spec.js.snap +1 -1
- package/src/ingests/components/__tests__/__snapshots__/IngestArchiveRow.spec.js.snap +30 -30
- package/src/ingests/components/__tests__/__snapshots__/IngestDetails.spec.js.snap +30 -13
- package/src/ingests/components/__tests__/__snapshots__/IngestExecutions.spec.js.snap +121 -101
- package/src/ingests/components/__tests__/__snapshots__/IngestExecutionsLoader.spec.js.snap +1 -1
- package/src/ingests/components/__tests__/__snapshots__/IngestFilters.spec.js.snap +1 -1
- package/src/ingests/components/__tests__/__snapshots__/IngestForm.spec.js.snap +28 -27
- package/src/ingests/components/__tests__/__snapshots__/IngestHeader.spec.js.snap +21 -19
- package/src/ingests/components/__tests__/__snapshots__/IngestLabelResults.spec.js.snap +1 -1
- package/src/ingests/components/__tests__/__snapshots__/IngestLoader.spec.js.snap +1 -15
- package/src/ingests/components/__tests__/__snapshots__/IngestRoutes.spec.js.snap +243 -0
- package/src/ingests/components/__tests__/__snapshots__/IngestSelectedFilters.spec.js.snap +22 -16
- package/src/ingests/components/__tests__/__snapshots__/Ingests.spec.js.snap +50 -33
- package/src/ingests/components/__tests__/__snapshots__/IngestsActions.spec.js.snap +17 -50
- package/src/ingests/components/__tests__/__snapshots__/IngestsLoader.spec.js.snap +1 -21
- package/src/ingests/components/__tests__/__snapshots__/IngestsTable.spec.js.snap +15 -24
- package/src/ingests/components/index.js +1 -1
- package/src/ingests/constants/mappings.js +6 -6
- package/src/ingests/relations/components/IngestLinkActions.js +0 -1
- package/src/ingests/relations/components/IngestLinksActions.js +1 -2
- package/src/ingests/relations/components/IngestRelationsRoutes.js +67 -69
- package/src/ingests/relations/components/IngestToDataStructureRelations.js +2 -2
- package/src/ingests/relations/components/IngestToIngestForm.js +4 -4
- package/src/ingests/relations/components/IngestToIngestRelations.js +4 -4
- package/src/ingests/relations/components/IngestToStructureForm.js +6 -6
- package/src/ingests/relations/components/__tests__/IngestRelationsRoutes.spec.js +80 -4
- package/src/ingests/relations/components/__tests__/IngestToIngestForm.spec.js +24 -25
- package/src/ingests/relations/components/__tests__/IngestToStructureForm.spec.js +42 -23
- package/src/ingests/relations/components/__tests__/__snapshots__/IngestRelationsRoutes.spec.js.snap +49 -23
- package/src/ingests/relations/components/__tests__/__snapshots__/IngestToIngestForm.spec.js.snap +85 -27
- package/src/ingests/relations/components/__tests__/__snapshots__/IngestToStructureForm.spec.js.snap +30 -35
- package/src/ingests/relations/selectors/__tests__/getIngestLinks.spec.js +20 -20
- package/src/ingests/relations/selectors/__tests__/getRelations.spec.js +17 -17
- package/src/ingests/relations/selectors/getIngestLinks.js +1 -2
- package/src/ingests/relations/selectors/getRelations.js +6 -6
- package/src/ingests/sagas/fetchIngest.js +1 -1
- package/src/ingests/sagas/fetchIngestArchive.js +1 -1
- package/src/ingests/sagas/fetchIngestExecutions.js +1 -1
- package/src/ingests/selectors/getIngestColumns.js +12 -13
- package/src/ingests/selectors/getIngestTemplate.js +1 -1
- package/src/ingests/selectors/getParsedEvents.js +15 -15
- package/src/ingests/selectors/getTemplateFields.js +3 -3
- package/src/ingests/selectors/getTemplateGroups.js +1 -1
- package/src/ingests/utils/filterOptions.js +3 -2
- package/src/ingests/components/__tests__/IngestDuplicate.spec.js +0 -67
- package/src/ingests/components/__tests__/IngestEdit.spec.js +0 -79
- package/src/ingests/components/__tests__/__snapshots__/IngestDuplicate.spec.js.snap +0 -85
- package/src/ingests/components/__tests__/__snapshots__/IngestEdit.spec.js.snap +0 -80
|
@@ -1,82 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { fetchIngestArchive, clearIngestArchive } from "../../routines";
|
|
3
|
+
import IngestArchiveLoader from "../IngestArchiveLoader";
|
|
4
|
+
import { useParams } from "react-router";
|
|
5
|
+
|
|
6
|
+
// Mock useParams
|
|
7
|
+
jest.mock("react-router", () => ({
|
|
8
|
+
...jest.requireActual("react-router"),
|
|
9
|
+
useParams: () => ({ id: "1" }),
|
|
10
|
+
}));
|
|
4
11
|
|
|
5
12
|
describe("<IngestArchiveLoader />", () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const mockDispatch = jest.fn();
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.clearAllMocks();
|
|
17
|
+
mockDispatch.mockClear();
|
|
18
|
+
});
|
|
10
19
|
|
|
11
|
-
it("matches the latest snapshot", () => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const wrapper = shallow(<IngestArchiveLoader {...props} />);
|
|
20
|
-
expect(wrapper).toMatchSnapshot();
|
|
20
|
+
it("matches the latest snapshot", async () => {
|
|
21
|
+
const rendered = render(<IngestArchiveLoader />, {
|
|
22
|
+
state: { ingestArchiveLoading: false },
|
|
23
|
+
dispatch: mockDispatch,
|
|
24
|
+
});
|
|
25
|
+
await waitForLoad(rendered);
|
|
26
|
+
expect(rendered.container).toMatchSnapshot();
|
|
21
27
|
});
|
|
22
28
|
|
|
23
|
-
it("renders a loader if ingestArchiveLoading is true", () => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
match
|
|
30
|
-
};
|
|
31
|
-
const wrapper = shallow(<IngestArchiveLoader {...props} />);
|
|
32
|
-
expect(wrapper.find("Loading").length).toBe(1);
|
|
29
|
+
it("renders a loader if ingestArchiveLoading is true", async () => {
|
|
30
|
+
const rendered = render(<IngestArchiveLoader />, {
|
|
31
|
+
state: { ingestArchiveLoading: true },
|
|
32
|
+
dispatch: mockDispatch,
|
|
33
|
+
});
|
|
34
|
+
expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
it("renders null if ingestArchiveLoading is false", () => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
const wrapper = shallow(<IngestArchiveLoader {...props} />);
|
|
44
|
-
expect(wrapper.getElement()).toBeNull();
|
|
37
|
+
it("renders null if ingestArchiveLoading is false", async () => {
|
|
38
|
+
const rendered = render(<IngestArchiveLoader />, {
|
|
39
|
+
state: { ingestArchiveLoading: false },
|
|
40
|
+
dispatch: mockDispatch,
|
|
41
|
+
});
|
|
42
|
+
await waitForLoad(rendered);
|
|
43
|
+
expect(rendered.container.firstChild).toBeNull();
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
it("
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
expect(
|
|
46
|
+
it("dispatches fetchIngestArchive when component mounts but not when it unmounts", async () => {
|
|
47
|
+
const rendered = render(<IngestArchiveLoader />, {
|
|
48
|
+
state: { ingestArchiveLoading: false },
|
|
49
|
+
dispatch: mockDispatch,
|
|
50
|
+
});
|
|
51
|
+
await waitForLoad(rendered);
|
|
52
|
+
expect(mockDispatch).toHaveBeenCalledWith(fetchIngestArchive({ id: "1" }));
|
|
53
|
+
|
|
54
|
+
const initialCallCount = mockDispatch.mock.calls.length;
|
|
55
|
+
rendered.unmount();
|
|
56
|
+
|
|
57
|
+
// Verify fetchIngestArchive wasn't called again
|
|
58
|
+
const fetchCalls = mockDispatch.mock.calls.filter(
|
|
59
|
+
(call) => call[0].type === fetchIngestArchive.TRIGGER
|
|
60
|
+
);
|
|
61
|
+
expect(fetchCalls.length).toBe(1);
|
|
63
62
|
});
|
|
64
63
|
|
|
65
|
-
it("
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
64
|
+
it("dispatches clearIngestArchive when component unmounts but not when it mounts", async () => {
|
|
65
|
+
const rendered = render(<IngestArchiveLoader />, {
|
|
66
|
+
state: { ingestArchiveLoading: false },
|
|
67
|
+
dispatch: mockDispatch,
|
|
68
|
+
});
|
|
69
|
+
await waitForLoad(rendered);
|
|
70
|
+
|
|
71
|
+
// Verify clearIngestArchive wasn't called on mount
|
|
72
|
+
const clearCallsBeforeUnmount = mockDispatch.mock.calls.filter(
|
|
73
|
+
(call) => call[0].type === clearIngestArchive.TRIGGER
|
|
74
|
+
);
|
|
75
|
+
expect(clearCallsBeforeUnmount.length).toBe(0);
|
|
76
|
+
|
|
77
|
+
mockDispatch.mockClear();
|
|
78
|
+
rendered.unmount();
|
|
79
|
+
|
|
80
|
+
// Verify clearIngestArchive was called on unmount
|
|
81
|
+
expect(mockDispatch).toHaveBeenCalledWith(clearIngestArchive());
|
|
81
82
|
});
|
|
82
83
|
});
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import IngestArchiveRow from "../IngestArchiveRow";
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
push: jest.fn()
|
|
7
|
-
};
|
|
4
|
+
const mockNavigate = jest.fn();
|
|
8
5
|
|
|
9
|
-
jest.mock("react-router
|
|
10
|
-
...jest.requireActual("react-router
|
|
11
|
-
|
|
6
|
+
jest.mock("react-router", () => ({
|
|
7
|
+
...jest.requireActual("react-router"),
|
|
8
|
+
useNavigate: () => mockNavigate,
|
|
12
9
|
}));
|
|
13
10
|
|
|
14
11
|
describe("<IngestArchiveRow />", () => {
|
|
15
|
-
it("matches the latest snapshot", () => {
|
|
12
|
+
it("matches the latest snapshot", async () => {
|
|
16
13
|
const props = {
|
|
17
14
|
id: 123,
|
|
18
15
|
status: "status",
|
|
19
16
|
last_change_at: "2018-06-27T07:32:53.154377Z",
|
|
20
17
|
last_change_by: "maixu",
|
|
21
|
-
version: 1
|
|
18
|
+
version: 1,
|
|
22
19
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
20
|
+
const rendered = render(<IngestArchiveRow {...props} />);
|
|
21
|
+
await waitForLoad(rendered);
|
|
22
|
+
expect(rendered.container).toMatchSnapshot();
|
|
25
23
|
});
|
|
26
24
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { IngestDetails } from "../IngestDetails";
|
|
4
3
|
|
|
5
4
|
describe("<IngestDetails />", () => {
|
|
6
5
|
const props = {
|
|
7
|
-
ingest: { name: "Ingest1", type: "type", status: "draft" },
|
|
6
|
+
ingest: { name: "Ingest1", type: "type", status: "draft", description: {} },
|
|
8
7
|
fieldValues: [
|
|
9
8
|
["group1", [{ field: "Field1", value: "Value1" }]],
|
|
10
9
|
[
|
|
11
10
|
"group2",
|
|
12
11
|
[
|
|
13
12
|
{ field: "Field2", value: "Value2" },
|
|
14
|
-
{ field: "Field3", value: "Value3" }
|
|
15
|
-
]
|
|
16
|
-
]
|
|
17
|
-
]
|
|
13
|
+
{ field: "Field3", value: "Value3" },
|
|
14
|
+
],
|
|
15
|
+
],
|
|
16
|
+
],
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
it("matches the latest snapshot", () => {
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
it("matches the latest snapshot", async () => {
|
|
20
|
+
const rendered = render(<IngestDetails {...props} />);
|
|
21
|
+
await waitForLoad(rendered);
|
|
22
|
+
expect(rendered.container).toMatchSnapshot();
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { IngestExecutions } from "../IngestExecutions";
|
|
4
3
|
|
|
5
4
|
describe("<IngestExecutions />", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
5
|
+
it("matches the latest snapshot", async () => {
|
|
7
6
|
const ingestExecutions = [
|
|
8
7
|
{
|
|
9
8
|
status: "status",
|
|
10
9
|
start_timestamp: "2018-06-27T07:32:53.154377Z",
|
|
11
10
|
end_timestamp: "2018-06-27T07:32:53.154377Z",
|
|
12
11
|
file_name: "file_name",
|
|
13
|
-
file_size: 5432
|
|
14
|
-
}
|
|
12
|
+
file_size: 5432,
|
|
13
|
+
},
|
|
15
14
|
];
|
|
16
15
|
const props = { ingestExecutions };
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const rendered = render(<IngestExecutions {...props} />);
|
|
17
|
+
await waitForLoad(rendered);
|
|
18
|
+
expect(rendered.container).toMatchSnapshot();
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -1,82 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { IngestExecutionsLoader } from "../IngestExecutionsLoader";
|
|
4
3
|
|
|
5
4
|
describe("<IngestExecutionsLoader />", () => {
|
|
6
|
-
const ingestExecutionsLoading = false;
|
|
7
5
|
const fetchIngestExecutions = jest.fn();
|
|
8
6
|
const clearIngestExecutions = jest.fn();
|
|
9
7
|
const ingest = { ingest_id: 3 };
|
|
10
8
|
|
|
11
|
-
it("matches the latest snapshot", () => {
|
|
12
|
-
const ingestExecutionsLoading = false;
|
|
9
|
+
it("matches the latest snapshot", async () => {
|
|
13
10
|
const props = {
|
|
14
11
|
clearIngestExecutions,
|
|
15
12
|
fetchIngestExecutions,
|
|
16
|
-
ingestExecutionsLoading,
|
|
17
|
-
ingest
|
|
13
|
+
ingestExecutionsLoading: false,
|
|
14
|
+
ingest,
|
|
18
15
|
};
|
|
19
|
-
const
|
|
20
|
-
|
|
16
|
+
const rendered = render(<IngestExecutionsLoader {...props} />);
|
|
17
|
+
await waitForLoad(rendered);
|
|
18
|
+
expect(rendered.container).toMatchSnapshot();
|
|
21
19
|
});
|
|
22
20
|
|
|
23
|
-
it("renders a loader if
|
|
24
|
-
const ingestExecutionsLoading = true;
|
|
21
|
+
it("renders a loader if ingestExecutionsLoading is true", async () => {
|
|
25
22
|
const props = {
|
|
26
23
|
clearIngestExecutions,
|
|
27
24
|
fetchIngestExecutions,
|
|
28
|
-
ingestExecutionsLoading,
|
|
29
|
-
ingest
|
|
25
|
+
ingestExecutionsLoading: true,
|
|
26
|
+
ingest,
|
|
30
27
|
};
|
|
31
|
-
const
|
|
32
|
-
expect(
|
|
28
|
+
const rendered = render(<IngestExecutionsLoader {...props} />);
|
|
29
|
+
expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
|
|
33
30
|
});
|
|
34
31
|
|
|
35
|
-
it("renders null if
|
|
36
|
-
const ingestExecutionsLoading = false;
|
|
32
|
+
it("renders null if ingestExecutionsLoading is false", async () => {
|
|
37
33
|
const props = {
|
|
38
34
|
clearIngestExecutions,
|
|
39
35
|
fetchIngestExecutions,
|
|
40
|
-
ingestExecutionsLoading,
|
|
41
|
-
ingest
|
|
36
|
+
ingestExecutionsLoading: false,
|
|
37
|
+
ingest,
|
|
42
38
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
39
|
+
const rendered = render(<IngestExecutionsLoader {...props} />);
|
|
40
|
+
await waitForLoad(rendered);
|
|
41
|
+
expect(rendered.container.firstChild).toBeNull();
|
|
45
42
|
});
|
|
46
43
|
|
|
47
|
-
it("calls fetchIngestExecutions when component mounts but not when it unmounts", () => {
|
|
48
|
-
const
|
|
44
|
+
it("calls fetchIngestExecutions when component mounts but not when it unmounts", async () => {
|
|
45
|
+
const fetchIngestExecutionsMock = jest.fn();
|
|
49
46
|
const props = {
|
|
50
47
|
clearIngestExecutions,
|
|
51
|
-
fetchIngestExecutions,
|
|
52
|
-
ingestExecutionsLoading,
|
|
53
|
-
ingest
|
|
48
|
+
fetchIngestExecutions: fetchIngestExecutionsMock,
|
|
49
|
+
ingestExecutionsLoading: false,
|
|
50
|
+
ingest,
|
|
54
51
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
expect(
|
|
58
|
-
|
|
59
|
-
).
|
|
60
|
-
expect(fetchIngestExecutions.mock.calls.length).toBe(1);
|
|
61
|
-
wrapper.unmount();
|
|
62
|
-
expect(fetchIngestExecutions.mock.calls.length).toBe(1);
|
|
52
|
+
const rendered = render(<IngestExecutionsLoader {...props} />);
|
|
53
|
+
await waitForLoad(rendered);
|
|
54
|
+
expect(fetchIngestExecutionsMock).toHaveBeenCalledTimes(1);
|
|
55
|
+
rendered.unmount();
|
|
56
|
+
expect(fetchIngestExecutionsMock).toHaveBeenCalledTimes(1);
|
|
63
57
|
});
|
|
64
58
|
|
|
65
|
-
it("calls clearIngestExecutions when component unmounts but not when it mounts", () => {
|
|
66
|
-
const
|
|
59
|
+
it("calls clearIngestExecutions when component unmounts but not when it mounts", async () => {
|
|
60
|
+
const clearIngestExecutionsMock = jest.fn();
|
|
67
61
|
const props = {
|
|
68
|
-
clearIngestExecutions,
|
|
62
|
+
clearIngestExecutions: clearIngestExecutionsMock,
|
|
69
63
|
fetchIngestExecutions,
|
|
70
|
-
ingestExecutionsLoading,
|
|
71
|
-
ingest
|
|
64
|
+
ingestExecutionsLoading: false,
|
|
65
|
+
ingest,
|
|
72
66
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
expect(
|
|
76
|
-
|
|
77
|
-
expect(
|
|
78
|
-
IngestExecutionsLoader.prototype.componentWillUnmount.mock.calls.length
|
|
79
|
-
).toBe(1);
|
|
80
|
-
expect(clearIngestExecutions.mock.calls.length).toBe(1);
|
|
67
|
+
const rendered = render(<IngestExecutionsLoader {...props} />);
|
|
68
|
+
await waitForLoad(rendered);
|
|
69
|
+
expect(clearIngestExecutionsMock).not.toHaveBeenCalled();
|
|
70
|
+
rendered.unmount();
|
|
71
|
+
expect(clearIngestExecutionsMock).toHaveBeenCalledTimes(1);
|
|
81
72
|
});
|
|
82
73
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import { waitFor } from "@testing-library/react";
|
|
4
1
|
import userEvent from "@testing-library/user-event";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
5
4
|
import {
|
|
6
5
|
multipleTemplatesMock,
|
|
7
6
|
singleTemplateMock,
|
|
@@ -24,32 +23,24 @@ describe("<IngestForm />", () => {
|
|
|
24
23
|
ingestActionLoading: "",
|
|
25
24
|
domains: [{ id: 1, name: "domain1" }],
|
|
26
25
|
},
|
|
27
|
-
fallback: "lazy",
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
it("matches the latest snapshot", async () => {
|
|
31
|
-
const
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
{ timeout: 10000 }
|
|
35
|
-
);
|
|
36
|
-
await waitFor(() =>
|
|
37
|
-
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
38
|
-
);
|
|
39
|
-
expect(container).toMatchSnapshot();
|
|
29
|
+
const rendered = render(<IngestForm />, renderOpts);
|
|
30
|
+
await waitForLoad(rendered);
|
|
31
|
+
expect(rendered.container).toMatchSnapshot();
|
|
40
32
|
});
|
|
41
33
|
|
|
42
34
|
it("contains a template selector if domain is selected", async () => {
|
|
43
|
-
const
|
|
44
|
-
await
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
35
|
+
const rendered = render(<IngestForm />, renderOpts);
|
|
36
|
+
await waitForLoad(rendered);
|
|
37
|
+
|
|
38
|
+
const user = userEvent.setup({ delay: null });
|
|
39
|
+
await user.click(await rendered.findByText(/foodomain/i));
|
|
40
|
+
|
|
48
41
|
await waitFor(() =>
|
|
49
|
-
expect(queryByText(/
|
|
42
|
+
expect(rendered.queryByText(/template1/i)).toBeInTheDocument()
|
|
50
43
|
);
|
|
51
|
-
userEvent.click(await findByText("fooDomain"));
|
|
52
|
-
await waitFor(() => expect(queryByText("template1")).toBeInTheDocument());
|
|
53
44
|
});
|
|
54
45
|
});
|
|
55
46
|
|
|
@@ -64,31 +55,18 @@ describe("<IngestForm />", () => {
|
|
|
64
55
|
ingestActionLoading: "",
|
|
65
56
|
domains: [{ id: 1, name: "domain1" }],
|
|
66
57
|
},
|
|
67
|
-
fallback: "lazy",
|
|
68
58
|
};
|
|
69
59
|
|
|
70
60
|
it("matches the latest snapshot", async () => {
|
|
71
|
-
const
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
{ timeout: 10000 }
|
|
75
|
-
);
|
|
76
|
-
await waitFor(() =>
|
|
77
|
-
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
78
|
-
);
|
|
79
|
-
expect(container).toMatchSnapshot();
|
|
61
|
+
const rendered = render(<IngestForm />, renderOpts);
|
|
62
|
+
await waitForLoad(rendered);
|
|
63
|
+
expect(rendered.container).toMatchSnapshot();
|
|
80
64
|
});
|
|
81
65
|
|
|
82
66
|
it("contains no <TemplateSelector />", async () => {
|
|
83
|
-
const
|
|
84
|
-
await
|
|
85
|
-
|
|
86
|
-
{ timeout: 10000 }
|
|
87
|
-
);
|
|
88
|
-
await waitFor(() =>
|
|
89
|
-
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
90
|
-
);
|
|
91
|
-
expect(queryByText("template1")).not.toBeInTheDocument();
|
|
67
|
+
const rendered = render(<IngestForm />, renderOpts);
|
|
68
|
+
await waitForLoad(rendered);
|
|
69
|
+
expect(rendered.queryByText(/template1/i)).not.toBeInTheDocument();
|
|
92
70
|
});
|
|
93
71
|
});
|
|
94
72
|
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { IngestHeader } from "../IngestHeader";
|
|
4
3
|
|
|
5
4
|
describe("<IngestHeader />", () => {
|
|
6
5
|
const props = {
|
|
7
6
|
ingest: {
|
|
8
|
-
name: "Ingest1"
|
|
7
|
+
name: "Ingest1",
|
|
9
8
|
},
|
|
10
9
|
domain: {
|
|
11
|
-
name: "Domain name"
|
|
10
|
+
name: "Domain name",
|
|
12
11
|
},
|
|
13
12
|
template: {
|
|
14
|
-
label: "Template1"
|
|
15
|
-
}
|
|
13
|
+
label: "Template1",
|
|
14
|
+
},
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
it("matches the latest snapshot", () => {
|
|
19
|
-
const
|
|
20
|
-
|
|
17
|
+
it("matches the latest snapshot", async () => {
|
|
18
|
+
const rendered = render(<IngestHeader {...props} />);
|
|
19
|
+
await waitForLoad(rendered);
|
|
20
|
+
expect(rendered.container).toMatchSnapshot();
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -1,54 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { fetchIngest, clearIngest } from "../../routines";
|
|
3
|
+
import IngestLoader from "../IngestLoader";
|
|
4
|
+
import { useParams } from "react-router";
|
|
5
|
+
|
|
6
|
+
// Mock useParams
|
|
7
|
+
jest.mock("react-router", () => ({
|
|
8
|
+
...jest.requireActual("react-router"),
|
|
9
|
+
useParams: () => ({ id: "1" }),
|
|
10
|
+
}));
|
|
4
11
|
|
|
5
12
|
describe("<IngestLoader />", () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
it("matches the latest snapshot", () => {
|
|
12
|
-
const ingestLoading = true;
|
|
13
|
-
const props = { clearIngest, fetchIngest, ingestLoading, match };
|
|
14
|
-
const wrapper = shallow(<IngestLoader {...props} />);
|
|
15
|
-
expect(wrapper).toMatchSnapshot();
|
|
13
|
+
const mockDispatch = jest.fn();
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.clearAllMocks();
|
|
17
|
+
mockDispatch.mockClear();
|
|
16
18
|
});
|
|
17
19
|
|
|
18
|
-
it("
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
it("matches the latest snapshot", async () => {
|
|
21
|
+
const rendered = render(<IngestLoader />, {
|
|
22
|
+
state: { ingestLoading: false },
|
|
23
|
+
dispatch: mockDispatch,
|
|
24
|
+
});
|
|
25
|
+
await waitForLoad(rendered);
|
|
26
|
+
expect(rendered.container).toMatchSnapshot();
|
|
23
27
|
});
|
|
24
28
|
|
|
25
|
-
it("renders
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
it("renders a loader if ingestLoading is true", async () => {
|
|
30
|
+
const rendered = render(<IngestLoader />, {
|
|
31
|
+
state: { ingestLoading: true },
|
|
32
|
+
dispatch: mockDispatch,
|
|
33
|
+
});
|
|
34
|
+
expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
|
|
29
35
|
});
|
|
30
36
|
|
|
31
|
-
it("
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
expect(
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
it("renders null if ingestLoading is false", async () => {
|
|
38
|
+
const rendered = render(<IngestLoader />, {
|
|
39
|
+
state: { ingestLoading: false },
|
|
40
|
+
dispatch: mockDispatch,
|
|
41
|
+
});
|
|
42
|
+
await waitForLoad(rendered);
|
|
43
|
+
expect(rendered.container.firstChild).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("dispatches fetchIngest when component mounts but not when it unmounts", async () => {
|
|
47
|
+
const rendered = render(<IngestLoader />, {
|
|
48
|
+
state: { ingestLoading: false },
|
|
49
|
+
dispatch: mockDispatch,
|
|
50
|
+
});
|
|
51
|
+
await waitForLoad(rendered);
|
|
52
|
+
expect(mockDispatch).toHaveBeenCalledWith(fetchIngest({ id: "1" }));
|
|
53
|
+
|
|
54
|
+
const initialCallCount = mockDispatch.mock.calls.length;
|
|
55
|
+
rendered.unmount();
|
|
56
|
+
|
|
57
|
+
// Verify fetchIngest wasn't called again
|
|
58
|
+
const fetchCalls = mockDispatch.mock.calls.filter(
|
|
59
|
+
(call) => call[0].type === fetchIngest.TRIGGER
|
|
60
|
+
);
|
|
61
|
+
expect(fetchCalls.length).toBe(1);
|
|
40
62
|
});
|
|
41
63
|
|
|
42
|
-
it("
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
it("dispatches clearIngest when component unmounts but not when it mounts", async () => {
|
|
65
|
+
const rendered = render(<IngestLoader />, {
|
|
66
|
+
state: { ingestLoading: false },
|
|
67
|
+
dispatch: mockDispatch,
|
|
68
|
+
});
|
|
69
|
+
await waitForLoad(rendered);
|
|
70
|
+
|
|
71
|
+
// Verify clearIngest wasn't called on mount
|
|
72
|
+
const clearCallsBeforeUnmount = mockDispatch.mock.calls.filter(
|
|
73
|
+
(call) => call[0].type === clearIngest.TRIGGER
|
|
51
74
|
);
|
|
52
|
-
expect(
|
|
75
|
+
expect(clearCallsBeforeUnmount.length).toBe(0);
|
|
76
|
+
|
|
77
|
+
mockDispatch.mockClear();
|
|
78
|
+
rendered.unmount();
|
|
79
|
+
|
|
80
|
+
// Verify clearIngest was called on unmount
|
|
81
|
+
expect(mockDispatch).toHaveBeenCalledWith(clearIngest());
|
|
53
82
|
});
|
|
54
83
|
});
|