@truedat/dd 6.5.5 → 6.6.1

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.
Files changed (99) hide show
  1. package/package.json +6 -6
  2. package/src/components/CatalogCustomViewCards.js +9 -32
  3. package/src/components/DictionaryRoutes.js +1 -9
  4. package/src/components/GrantRemovalDirectButton.js +1 -3
  5. package/src/components/GrantRequestCancel.js +1 -1
  6. package/src/components/GrantRoutes.js +1 -14
  7. package/src/components/StructureGrantListButton.js +4 -4
  8. package/src/components/StructureSelector.js +70 -44
  9. package/src/components/StructureStructureForm.js +1 -1
  10. package/src/components/StructuresBulkUpdate.js +10 -14
  11. package/src/components/StructuresDownloadOption.js +31 -27
  12. package/src/components/StructuresEditableDownloadOption.js +12 -7
  13. package/src/components/StructuresGrantRequestView.js +55 -24
  14. package/src/components/StructuresLabelResults.js +5 -11
  15. package/src/components/StructuresPagination.js +13 -15
  16. package/src/components/StructuresRoutes.js +17 -33
  17. package/src/components/StructuresTable.js +79 -115
  18. package/src/components/StructuresUpdateOption.js +77 -9
  19. package/src/components/StructuresView.js +67 -52
  20. package/src/components/__tests__/CatalogCustomViewCards.spec.js +44 -7
  21. package/src/components/__tests__/StructureGrantListButton.spec.js +27 -17
  22. package/src/components/__tests__/StructureSelector.spec.js +70 -25
  23. package/src/components/__tests__/StructureStructureForm.spec.js +92 -60
  24. package/src/components/__tests__/StructureStructureLinks.spec.js +1 -1
  25. package/src/components/__tests__/StructuresBulkUpdate.spec.js +26 -14
  26. package/src/components/__tests__/StructuresDownloadOption.spec.js +38 -5
  27. package/src/components/__tests__/StructuresEditableDownloadOption.spec.js +20 -8
  28. package/src/components/__tests__/StructuresGrantRequestView.spec.js +43 -15
  29. package/src/components/__tests__/StructuresLabelResults.spec.js +37 -10
  30. package/src/components/__tests__/StructuresOptions.spec.js +62 -1
  31. package/src/components/__tests__/StructuresSearchResults.spec.js +67 -12
  32. package/src/components/__tests__/StructuresTable.spec.js +77 -88
  33. package/src/components/__tests__/StructuresUpdateOption.spec.js +53 -6
  34. package/src/components/__tests__/StructuresView.spec.js +126 -31
  35. package/src/components/__tests__/__snapshots__/StructureSelector.spec.js.snap +206 -42
  36. package/src/components/__tests__/__snapshots__/StructuresDownloadOption.spec.js.snap +17 -0
  37. package/src/components/__tests__/__snapshots__/StructuresGrantRequestView.spec.js.snap +68 -5
  38. package/src/components/__tests__/__snapshots__/StructuresLabelResults.spec.js.snap +7 -12
  39. package/src/components/__tests__/__snapshots__/StructuresSearchResults.spec.js.snap +72 -27
  40. package/src/components/__tests__/__snapshots__/StructuresTable.spec.js.snap +226 -153
  41. package/src/components/__tests__/__snapshots__/StructuresUpdateOption.spec.js.snap +3 -3
  42. package/src/components/index.js +0 -8
  43. package/src/hooks/useStructures.js +6 -6
  44. package/src/reducers/__tests__/selectedUserSearchFilter.spec.js +2 -23
  45. package/src/reducers/__tests__/structureQuery.spec.js +1 -63
  46. package/src/reducers/index.js +0 -18
  47. package/src/reducers/previousStructureQuery.js +3 -6
  48. package/src/reducers/selectedUserSearchFilter.js +1 -10
  49. package/src/reducers/structureQuery.js +1 -33
  50. package/src/routines.js +1 -15
  51. package/src/sagas/__tests__/bulkUpdateStructures.spec.js +7 -7
  52. package/src/sagas/__tests__/downloadEditableStructures.spec.js +1 -6
  53. package/src/sagas/__tests__/downloadStructures.spec.js +2 -7
  54. package/src/sagas/__tests__/fetchStructures.spec.js +4 -4
  55. package/src/sagas/bulkUpdateStructures.js +6 -4
  56. package/src/sagas/downloadEditableStructures.js +2 -3
  57. package/src/sagas/downloadStructures.js +2 -3
  58. package/src/sagas/index.js +0 -3
  59. package/src/selectors/__tests__/getGrantSelectedFilters.spec.js +1 -1
  60. package/src/selectors/__tests__/structureColumnsSelector.spec.js +5 -19
  61. package/src/selectors/__tests__/templateNamesSelector.spec.js +19 -0
  62. package/src/selectors/index.js +1 -8
  63. package/src/selectors/structureColumnsSelector.js +6 -46
  64. package/src/selectors/templateNamesSelector.js +7 -0
  65. package/src/utils/structureCustomTranslations.js +19 -0
  66. package/src/components/StructureDateFilter.js +0 -32
  67. package/src/components/StructureFilters.js +0 -19
  68. package/src/components/StructureFiltersLoader.js +0 -32
  69. package/src/components/StructureSelectedFilters.js +0 -94
  70. package/src/components/__tests__/StructureDateFilter.spec.js +0 -11
  71. package/src/components/__tests__/__snapshots__/StructureDateFilter.spec.js.snap +0 -13
  72. package/src/reducers/__tests__/structureActiveFilters.spec.js +0 -100
  73. package/src/reducers/__tests__/structureDateFilter.spec.js +0 -57
  74. package/src/reducers/__tests__/structureFilters.spec.js +0 -37
  75. package/src/reducers/__tests__/structureUserFilters.spec.js +0 -76
  76. package/src/reducers/__tests__/structuresActions.spec.js +0 -38
  77. package/src/reducers/__tests__/structuresLoading.spec.js +0 -26
  78. package/src/reducers/structureActiveFilters.js +0 -58
  79. package/src/reducers/structureCount.js +0 -20
  80. package/src/reducers/structureDateFilter.js +0 -33
  81. package/src/reducers/structureFilters.js +0 -21
  82. package/src/reducers/structureFiltersLoading.js +0 -14
  83. package/src/reducers/structureSelectedFilter.js +0 -34
  84. package/src/reducers/structuresActions.js +0 -18
  85. package/src/reducers/structuresLoading.js +0 -14
  86. package/src/reducers/structuresPageSize.js +0 -15
  87. package/src/sagas/fetchStructureFilters.js +0 -29
  88. package/src/selectors/__tests__/bulkUpdateDisabledSelector.spec.js +0 -72
  89. package/src/selectors/__tests__/getStructureAvailableFilters.spec.js +0 -15
  90. package/src/selectors/__tests__/getStructureSelectedFilterActiveValues.spec.js +0 -20
  91. package/src/selectors/__tests__/getStructureSelectedFilterValues.spec.js +0 -15
  92. package/src/selectors/__tests__/getStructureSelectedFilters.spec.js +0 -15
  93. package/src/selectors/bulkUpdateDisabledSelector.js +0 -46
  94. package/src/selectors/getPreviousStructureQuery.js +0 -2
  95. package/src/selectors/getStructureAvailableFilters.js +0 -15
  96. package/src/selectors/getStructureFilterTypes.js +0 -7
  97. package/src/selectors/getStructureSelectedFilterActiveValues.js +0 -9
  98. package/src/selectors/getStructureSelectedFilterValues.js +0 -12
  99. package/src/selectors/getStructureSelectedFilters.js +0 -7
@@ -7,12 +7,17 @@ import { Header, Icon, Segment, Divider } from "semantic-ui-react";
7
7
  import { FormattedMessage } from "react-intl";
8
8
  import { linkTo } from "@truedat/core/routes";
9
9
  import { BUCKETS_VIEW } from "@truedat/core/routes";
10
- import { fetchStructureFilters as fetchStructureFiltersRoutine } from "@truedat/dd/routines";
11
- import { structureRowsSelector } from "../selectors";
12
- import StructureSelectedFilters from "./StructureSelectedFilters";
10
+ import SearchWidget from "@truedat/core/search/SearchWidget";
11
+ import {
12
+ SearchContextProvider,
13
+ useSearchContext,
14
+ } from "@truedat/core/search/SearchContext";
15
+ import {
16
+ useDataStructureFilters,
17
+ useDataStructureSearch,
18
+ } from "../hooks/useStructures";
19
+ import translations from "../utils/structureCustomTranslations";
13
20
  import StructuresOptions from "./StructuresOptions";
14
- import StructureDateFilter from "./StructureDateFilter";
15
- import StructuresSearch from "./StructuresSearch";
16
21
  import StructuresSearchResults from "./StructuresSearchResults";
17
22
  import SystemCards from "./SystemCards";
18
23
  import CatalogCustomViewCards from "./CatalogCustomViewCards";
@@ -45,23 +50,26 @@ const StructuresHeader = () => {
45
50
  );
46
51
  };
47
52
 
48
- const StructuresViewContent = ({
49
- actions = {},
50
- loading,
51
- structures,
52
- hasFilterApplied,
53
- embedded,
54
- customView,
55
- }) => {
53
+ export const StructuresViewContent = ({ embedded, customView }) => {
54
+ const { searchData, loading, query, allActiveFilters, toggleDateFilter } =
55
+ useSearchContext();
56
+ const actions = _.propOr({}, "_actions")(searchData);
57
+ const structures = searchData?.data;
58
+
59
+ const selectedFilters = (allActiveFilters, toggleDateFilter) =>
60
+ toggleDateFilter
61
+ ? true
62
+ : !_.isEmpty(allActiveFilters) &&
63
+ _.flow(_.values, _.some(_.negate(_.isEmpty)))(allActiveFilters);
64
+ const hasFilterApplied =
65
+ !_.isEmpty(query) || selectedFilters(allActiveFilters, toggleDateFilter);
56
66
  const history = useHistory();
57
67
  return (
58
68
  <>
59
69
  {!customView ? (
60
70
  <>
61
71
  <StructuresOptions hasFilterApplied={hasFilterApplied} {...actions} />
62
- <StructuresSearch />
63
- <StructureSelectedFilters />
64
- <StructureDateFilter />
72
+ <SearchWidget dateFilter />
65
73
  </>
66
74
  ) : null}
67
75
 
@@ -81,53 +89,60 @@ const StructuresViewContent = ({
81
89
  };
82
90
 
83
91
  StructuresViewContent.propTypes = {
84
- actions: PropTypes.object,
85
92
  grantable: PropTypes.bool,
86
- structures: PropTypes.array,
87
- loading: PropTypes.bool,
88
- hasFilterApplied: PropTypes.bool,
89
93
  embedded: PropTypes.bool,
90
94
  customView: PropTypes.bool,
91
95
  };
92
96
 
93
97
  export const StructuresView = (props) => {
94
- const { systemsLoading, embedded } = props;
95
- return embedded ? (
96
- <StructuresViewContent {...props} />
97
- ) : (
98
- <Segment loading={systemsLoading}>
99
- <StructuresHeader />
100
- <Divider hidden />
101
- <StructuresViewContent {...props} />
102
- </Segment>
98
+ const { systemsLoading, embedded, customView } = props;
99
+ const defaultFilters = _.propOr({}, "defaultFilters")(props);
100
+ const filtersGroup = _.propOr([], "filtersGroup")(props);
101
+ const enrichSearchPayload = {
102
+ my_grant_requests: false,
103
+ with_data_fields: false,
104
+ };
105
+
106
+ const searchProps = {
107
+ initialSortColumn: "name.raw",
108
+ initialSortDirection: "ascending",
109
+ useSearch: useDataStructureSearch,
110
+ useFilters: useDataStructureFilters,
111
+ pageSize: 20,
112
+ userFiltersType: "user_search_filters",
113
+ userFilterScope: "data_structure",
114
+ translations,
115
+ filtersGroup,
116
+ defaultFilters,
117
+ enrichSearchPayload,
118
+ };
119
+ return (
120
+ <SearchContextProvider {...searchProps}>
121
+ {embedded ? (
122
+ <StructuresViewContent embedded={embedded} customView={customView} />
123
+ ) : (
124
+ <Segment loading={systemsLoading}>
125
+ <StructuresHeader />
126
+ <Divider hidden />
127
+ <StructuresViewContent embedded={embedded} customView={customView} />
128
+ </Segment>
129
+ )}
130
+ </SearchContextProvider>
103
131
  );
104
132
  };
105
133
 
106
134
  StructuresView.propTypes = {
107
- actions: PropTypes.object,
108
- structures: PropTypes.array,
109
- loading: PropTypes.bool,
110
- systemsLoading: PropTypes.bool,
111
- hasFilterApplied: PropTypes.bool,
135
+ defaultFilters: PropTypes.object,
112
136
  embedded: PropTypes.bool,
137
+ customView: PropTypes.bool,
138
+ systemsLoading: PropTypes.bool,
139
+ filtersGroup: PropTypes.array,
113
140
  };
114
141
 
115
- const selectedFilters = ({ structureActiveFilters, structureDateFilter }) =>
116
- structureDateFilter?.active
117
- ? true
118
- : !_.isEmpty(structureActiveFilters) &&
119
- _.flow(_.values, _.some(_.negate(_.isEmpty)))(structureActiveFilters);
120
-
121
- const isEmptyPath = (state, path) => _.flow(_.path(path), _.isEmpty)(state);
122
-
123
- const mapStateToProps = (state) => ({
124
- structures: structureRowsSelector(state),
125
- actions: state.structuresActions,
126
- fetchStructureFilters: fetchStructureFiltersRoutine,
127
- loading: state.structuresLoading,
128
- systemsLoading: state.systemsLoading,
129
- hasFilterApplied:
130
- !isEmptyPath(state, "structureQuery.query") || selectedFilters(state),
131
- });
132
-
142
+ const mapStateToProps = (state) => {
143
+ return {
144
+ systemsLoading: state?.systemsLoading,
145
+ filtersGroup: state?.structureFiltersGroup,
146
+ };
147
+ };
133
148
  export default connect(mapStateToProps)(StructuresView);
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
3
  import { within } from "@testing-library/react";
4
- import { CatalogCustomViewCards } from "../CatalogCustomViewCards";
4
+ import SearchContext from "@truedat/core/search/SearchContext";
5
+ import CatalogCustomViewCards from "../CatalogCustomViewCards";
5
6
  import es from "../../messages/en";
6
7
 
7
8
  const structureFilters = {
@@ -24,7 +25,30 @@ const structureFilters = {
24
25
  },
25
26
  };
26
27
 
27
- const fetchStructureFilters = jest.fn();
28
+ jest.mock("@truedat/dd/hooks/useStructures", () => {
29
+ const originalModule = jest.requireActual("@truedat/dd/hooks/useStructures");
30
+ return {
31
+ __esModule: true,
32
+ ...originalModule,
33
+ useDataStructureFilters: () => ({
34
+ trigger: () => ({
35
+ then: (callback) =>
36
+ callback({
37
+ data: {},
38
+ }),
39
+ }),
40
+ }),
41
+ useDataStructureSearch: () => ({
42
+ trigger: () => ({
43
+ then: (callback) =>
44
+ callback({
45
+ data: { data: [] },
46
+ headers: {},
47
+ }),
48
+ }),
49
+ }),
50
+ };
51
+ });
28
52
 
29
53
  const messages = {
30
54
  es: {
@@ -38,13 +62,26 @@ jest.mock("react-router-dom", () => ({
38
62
  useParams: () => ({ propertyPath: "metadata.database" }),
39
63
  }));
40
64
 
65
+ const searchProps = {
66
+ loading: false,
67
+ filtersLoading: false,
68
+ allFilters: structureFilters,
69
+ searchData: { data: [] },
70
+ };
71
+
41
72
  describe("<CatalogCustomViewCard />", () => {
42
73
  it("Shows a structure filter value and count inside each Card", () => {
43
- const props = { structureFilters, fetchStructureFilters };
44
- const { getByRole } = render(<CatalogCustomViewCards {...props} />, {
45
- locale: "es",
46
- messages,
47
- });
74
+ const { getByRole } = render(
75
+ <SearchContext.Provider value={searchProps}>
76
+ <CatalogCustomViewCards />
77
+ </SearchContext.Provider>,
78
+
79
+ {
80
+ locale: "es",
81
+ messages,
82
+ }
83
+ );
84
+
48
85
  const missingCard = getByRole("link", { name: /_missing/ });
49
86
  expect(missingCard).toBeInTheDocument();
50
87
  const databaseOneCard = getByRole("link", { name: /database_1/ });
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
+ import SearchContextWrapper from "@truedat/core/components/common/SearchContextWrapper";
3
4
  import StructureGrantListButton from "../StructureGrantListButton";
4
5
 
5
6
  const structure = {
@@ -22,7 +23,6 @@ const structure = {
22
23
  const renderOpts = {
23
24
  state: {
24
25
  structureGrantPopup: ["structureGrantPopup"],
25
- previousStructureQuery: { foo: "bar" },
26
26
  grantRequestsCart: {
27
27
  structures: [{ id: 1 }],
28
28
  },
@@ -30,10 +30,14 @@ const renderOpts = {
30
30
  fallback: "lazy",
31
31
  };
32
32
 
33
+ const searchProps = { filterParams: { foo: "bar" } };
34
+
33
35
  describe("<StructureGrantListButton />", () => {
34
36
  it("matches the latest snapshot", () => {
35
37
  const { container } = render(
36
- <StructureGrantListButton structure={structure} />,
38
+ <SearchContextWrapper props={searchProps}>
39
+ <StructureGrantListButton structure={structure} />
40
+ </SearchContextWrapper>,
37
41
  renderOpts
38
42
  );
39
43
  expect(container).toMatchSnapshot();
@@ -41,7 +45,9 @@ describe("<StructureGrantListButton />", () => {
41
45
 
42
46
  it("matches the latest snapshot for requested structure", () => {
43
47
  const { container } = render(
44
- <StructureGrantListButton structure={{ ...structure, id: 1 }} />,
48
+ <SearchContextWrapper props={searchProps}>
49
+ <StructureGrantListButton structure={{ ...structure, id: 1 }} />
50
+ </SearchContextWrapper>,
45
51
  renderOpts
46
52
  );
47
53
  expect(container).toMatchSnapshot();
@@ -49,17 +55,19 @@ describe("<StructureGrantListButton />", () => {
49
55
 
50
56
  it("matches the latest snapshot with grant", () => {
51
57
  const { container } = render(
52
- <StructureGrantListButton
53
- structure={{
54
- ...structure,
55
- my_grants: [
56
- {
57
- id: 2,
58
- user_id: 564,
59
- },
60
- ],
61
- }}
62
- />,
58
+ <SearchContextWrapper props={searchProps}>
59
+ <StructureGrantListButton
60
+ structure={{
61
+ ...structure,
62
+ my_grants: [
63
+ {
64
+ id: 2,
65
+ user_id: 564,
66
+ },
67
+ ],
68
+ }}
69
+ />
70
+ </SearchContextWrapper>,
63
71
  renderOpts
64
72
  );
65
73
  expect(container).toMatchSnapshot();
@@ -67,9 +75,11 @@ describe("<StructureGrantListButton />", () => {
67
75
 
68
76
  it("matches the latest snapshot with grant request", () => {
69
77
  const { container } = render(
70
- <StructureGrantListButton
71
- structure={{ ...structure, my_grant_request: { status: "pending" } }}
72
- />,
78
+ <SearchContextWrapper props={searchProps}>
79
+ <StructureGrantListButton
80
+ structure={{ ...structure, my_grant_request: { status: "pending" } }}
81
+ />
82
+ </SearchContextWrapper>,
73
83
  renderOpts
74
84
  );
75
85
  expect(container).toMatchSnapshot();
@@ -1,36 +1,81 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { StructureSelector, mapStateToProps } from "../StructureSelector";
2
+ import { render } from "@truedat/test/render";
3
+ import { StructureSelector } from "../StructureSelector";
4
+
5
+ const data = {
6
+ _actions: { bulkUpdate: {} },
7
+ data: [
8
+ { id: 1, name: "1", updated_at: "2021-12-10T12:22:37.797978Z" },
9
+ { id: 2, name: "2", updated_at: "2021-12-10T12:22:37.797978Z" },
10
+ ],
11
+ headers: { "x-total-count": 2 },
12
+ };
13
+
14
+ const filterData = {
15
+ data: {
16
+ some: {
17
+ values: ["some_xxx", "some_yyy", "some_xwy"],
18
+ },
19
+ },
20
+ };
21
+
22
+ jest.mock("@truedat/dd/hooks/useStructures", () => {
23
+ const originalModule = jest.requireActual("@truedat/dd/hooks/useStructures");
24
+
25
+ return {
26
+ __esModule: true,
27
+ ...originalModule,
28
+ useDataStructureFilters: () => ({
29
+ trigger: () => ({
30
+ then: (callback) =>
31
+ callback({
32
+ data: filterData,
33
+ }),
34
+ }),
35
+ }),
36
+ useDataStructureSearch: () => ({
37
+ trigger: () => ({
38
+ then: (callback) =>
39
+ callback({
40
+ data,
41
+ headers: {},
42
+ }),
43
+ }),
44
+ }),
45
+ };
46
+ });
47
+
48
+ const messages = {
49
+ en: {
50
+ "search.placeholder": "Search...",
51
+ "structure.group": "Group",
52
+ "structure.system": "System",
53
+ "structure.name": "Name",
54
+ "structures.retrieved.results": "Results",
55
+ "structures.loading.header": "Header",
56
+ "structure.type.undefined.text": "text",
57
+ "structure.relation.relation_type_name": "relation",
58
+ "structure.updated_at": "Updated at",
59
+ "structure.type": "type",
60
+ },
61
+ };
62
+ const renderOpts = { messages };
4
63
 
5
64
  describe("<StructureSelector />", () => {
6
65
  it("matches the latest snapshot", () => {
7
- const columns = ["name", "system", "group"].map(name => ({ name }));
8
- const structures = [{ id: 1 }, { id: 2 }];
9
- const structuresRows = [{ id: 1 }, { id: 2 }];
66
+ const columns = ["name", "system", "group"].map((name) => ({ name }));
67
+
68
+ const structuresRows = [
69
+ { id: 1, name: 1 },
70
+ { id: 2, name: 2 },
71
+ ];
10
72
 
11
73
  const props = {
12
- structures,
13
74
  structuresRows,
14
75
  columns,
15
- onSelect: jest.fn()
76
+ onSelect: jest.fn(),
16
77
  };
17
- const wrapper = shallow(<StructureSelector {...props} />);
18
- expect(wrapper).toMatchSnapshot();
19
- });
20
-
21
- describe("mapStateToProps", () => {
22
- it("excludes system from columns if the default filters include system.name.raw", () => {
23
- const defaultFilters = { "system.name.raw": ["foo"] };
24
- const structuresColumns = ["foo", "bar", "system", "baz"].map(name => ({
25
- name
26
- }));
27
- const structuresLoading = false;
28
- const state = { structuresColumns, structuresLoading };
29
- const ownProps = { defaultFilters };
30
- const props = mapStateToProps(state, ownProps);
31
- expect(props).toMatchObject({
32
- columns: [{ name: "foo" }, { name: "bar" }, { name: "baz" }]
33
- });
34
- });
78
+ const { container } = render(<StructureSelector {...props} />, renderOpts);
79
+ expect(container).toMatchSnapshot();
35
80
  });
36
81
  });
@@ -2,10 +2,75 @@ import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
4
  import userEvent from "@testing-library/user-event";
5
+ import SearchContext from "@truedat/core/search/SearchContext";
5
6
  import StructureStructureForm from "../StructureStructureForm";
6
7
  import { linkStructureToStructure } from "../../routines";
7
8
  import { LINK_LABELS_QUERY } from "../../api/queries";
8
9
 
10
+ const structure = {
11
+ external_id: "external_id",
12
+ id: 67583,
13
+ updated_at: "2021-06-10T12:01:17.343065Z",
14
+ name: "structure",
15
+ };
16
+
17
+ jest.mock("@truedat/dd/hooks/useStructures", () => {
18
+ const originalModule = jest.requireActual("@truedat/dd/hooks/useStructures");
19
+
20
+ const data = {
21
+ _actions: { bulkUpdate: { href: "/structures/bulkUpdate" } },
22
+ data: [structure],
23
+ };
24
+
25
+ return {
26
+ __esModule: true,
27
+ ...originalModule,
28
+ useDataStructureFilters: () => ({
29
+ trigger: () => ({
30
+ then: (callback) =>
31
+ callback({
32
+ data: { data: {} },
33
+ }),
34
+ }),
35
+ }),
36
+ useDataStructureSearch: () => ({
37
+ trigger: () => ({
38
+ then: (callback) =>
39
+ callback({
40
+ data,
41
+ headers: {},
42
+ }),
43
+ }),
44
+ }),
45
+ };
46
+ });
47
+
48
+ const useFilters = jest.fn(() => ({
49
+ trigger: jest.fn(() => new Promise(() => {})),
50
+ isMutating: false,
51
+ }));
52
+
53
+ const useSearch = () => ({
54
+ trigger: () => ({
55
+ then: (callback) =>
56
+ callback({
57
+ data: {
58
+ data: [structure],
59
+ },
60
+ }),
61
+ }),
62
+ });
63
+
64
+ const searchProps = {
65
+ initialSortColumn: "name.raw",
66
+ initialSortDirection: "ascending",
67
+ useSearch: useSearch,
68
+ useFilters: useFilters,
69
+ userFiltersType: "structures",
70
+ omitFilters: [],
71
+ translations: jest.fn(),
72
+ };
73
+
9
74
  const linkLabels = {
10
75
  labels: [
11
76
  {
@@ -29,61 +94,12 @@ const linkLabelsMock = {
29
94
  };
30
95
 
31
96
  describe("<StructureStructureForm />", () => {
32
- const structure = {
33
- alias: null,
34
- confidential: false,
35
- domain_ids: [1],
36
- domains: [
37
- {
38
- external_id: "Acme",
39
- id: 1,
40
- name: "Acme",
41
- parent_id: null,
42
- parents: [],
43
- updated_at: "2022-03-22 12:56:39.639127Z",
44
- },
45
- ],
46
- external_id: "external_id",
47
- id: 67583,
48
- inserted_at: "2019-11-27T08:35:44.000000Z",
49
- updated_at: "2021-06-10T12:01:17.343065Z",
50
- class: null,
51
- classes: null,
52
- data_structure_link_count: 0,
53
- data_structure_type: {
54
- metadata_views: [],
55
- template_id: 9,
56
- translation: null,
57
- },
58
- degree: null,
59
- deleted_at: null,
60
- description: null,
61
- grant: null,
62
- grants: [],
63
- group: "group",
64
- implementation_count: 0,
65
- metadata: {
66
- database: "database",
67
- host: "host",
68
- },
69
- name: "structure",
70
- note: {},
71
- siblings: [],
72
- source: {
73
- external_id: "oracle_meta_ds2",
74
- id: 19,
75
- },
76
- system: {
77
- id: 2,
78
- name: "SYSTEM_1",
79
- },
80
- type: "Schema",
81
- };
82
-
83
- it("matches the latest snapshot", async () => {
97
+ it.only("matches the latest snapshot", async () => {
84
98
  const columns = ["name", "system", "group"].map((name) => ({ name }));
85
- const structureActiveFilters = {};
86
- const structuresRows = [{ id: 1 }, { id: 2 }];
99
+ const structuresRows = [
100
+ { id: 1, name: 1 },
101
+ { id: 2, name: 1 },
102
+ ];
87
103
  const dispatch = jest.fn();
88
104
 
89
105
  const props = {
@@ -95,16 +111,32 @@ describe("<StructureStructureForm />", () => {
95
111
 
96
112
  const renderOpts = {
97
113
  mocks: [linkLabelsMock],
98
- state: {
99
- structure,
100
- structures: [structure],
101
- structureActiveFilters,
102
- },
103
114
  dispatch,
115
+ state: { structure },
116
+ messages: {
117
+ en: {
118
+ "search.placeholder": "Search...",
119
+ "structure.type.undefined.text": "type",
120
+ "structureLink.selector.placeholder": "Select a relation label...",
121
+ "actions.save": "Save",
122
+ "actions.cancel": "Cancel",
123
+ "structureLink.selector.label": "Label",
124
+ "structure.updated_at": "updated at",
125
+ "structure.group": "group",
126
+ "structure.relation.relation_type_name": "relation type name",
127
+ "structure.system": "system",
128
+ "structure.type": "type",
129
+ "structure.name": "name",
130
+ "structures.retrieved.results": "results",
131
+ "structures.loading.header": "loading header",
132
+ },
133
+ },
104
134
  };
105
135
 
106
136
  const { queryByText, findByText, getByRole } = render(
107
- <StructureStructureForm {...props} />,
137
+ <SearchContext.Provider value={{ ...searchProps }}>
138
+ <StructureStructureForm {...props} />
139
+ </SearchContext.Provider>,
108
140
  renderOpts
109
141
  );
110
142
  await waitFor(() =>
@@ -203,7 +203,7 @@ describe("<StructureStructureLinks />", () => {
203
203
  });
204
204
 
205
205
  it("matches the latest snapshot of StructureStructureLinks for alias check", async () => {
206
- const { getByRole, debug, container } = render(
206
+ const { getByRole, container } = render(
207
207
  <StructureStructureLinks {...props} />,
208
208
  {
209
209
  routes: ["/structures/60217/structureLinks"],