@truedat/se 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.
Files changed (37) hide show
  1. package/package.json +43 -64
  2. package/src/components/CardResult.js +3 -4
  3. package/src/components/DeleteIndexButton.js +0 -1
  4. package/src/components/ElasticIndexes.js +5 -4
  5. package/src/components/Search.js +0 -1
  6. package/src/components/SearchHome.js +4 -4
  7. package/src/components/SearchInput.js +0 -1
  8. package/src/components/SearchLoader.js +17 -37
  9. package/src/components/SearchPagination.js +0 -1
  10. package/src/components/SearchResults.js +4 -5
  11. package/src/components/SearchRoutes.js +21 -67
  12. package/src/components/SearchTabs.js +7 -8
  13. package/src/components/__tests__/CardResult.spec.js +7 -7
  14. package/src/components/__tests__/DeleteIndexButton.spec.js +22 -37
  15. package/src/components/__tests__/ElasticIndexes.spec.js +5 -26
  16. package/src/components/__tests__/Search.spec.js +0 -1
  17. package/src/components/__tests__/SearchInput.spec.js +7 -12
  18. package/src/components/__tests__/SearchLoader.spec.js +64 -72
  19. package/src/components/__tests__/SearchPagination.spec.js +0 -1
  20. package/src/components/__tests__/SearchResults.spec.js +0 -1
  21. package/src/components/__tests__/SearchRoutes.spec.js +107 -7
  22. package/src/components/__tests__/SearchTabs.spec.js +6 -5
  23. package/src/components/__tests__/SearchTabsHide.spec.js +9 -25
  24. package/src/components/__tests__/__snapshots__/CardResult.spec.js.snap +29 -22
  25. package/src/components/__tests__/__snapshots__/ElasticIndexes.spec.js.snap +1 -12
  26. package/src/components/__tests__/__snapshots__/Search.spec.js.snap +6 -5
  27. package/src/components/__tests__/__snapshots__/SearchInput.spec.js.snap +15 -14
  28. package/src/components/__tests__/__snapshots__/SearchLoader.spec.js.snap +7 -1
  29. package/src/components/__tests__/__snapshots__/SearchResults.spec.js.snap +3 -2
  30. package/src/components/__tests__/__snapshots__/SearchRoutes.spec.js.snap +94 -5
  31. package/src/components/__tests__/__snapshots__/SearchTabs.spec.js.snap +4 -0
  32. package/src/hooks/__tests__/{useElasticIndexes.spec.js → useElasticIndexes.spec.js.disabled} +1 -1
  33. package/src/selectors/__tests__/getSearchQuery.spec.js +7 -7
  34. package/src/selectors/__tests__/searchIndicesSelector.spec.js +2 -2
  35. package/src/selectors/__tests__/searchResultsSelector.spec.js +13 -10
  36. package/src/selectors/defaultIndices.js +2 -2
  37. package/src/selectors/searchResultsSelector.js +4 -4
@@ -1,8 +1,97 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<SearchRoutes /> matches the latest snapshot 1`] = `
4
- <Route
5
- path="/search"
6
- render={[Function]}
7
- />
3
+ exports[`<SearchRoutes /> renders correctly with ELASTICINDEXES route 1`] = `
4
+ <div>
5
+ <div>
6
+ SearchLoader
7
+ </div>
8
+ <div>
9
+ ElasticIndexes
10
+ </div>
11
+ </div>
12
+ `;
13
+
14
+ exports[`<SearchRoutes /> renders correctly with SEARCH route 1`] = `
15
+ <div>
16
+ <div>
17
+ SearchLoader
18
+ </div>
19
+ <div>
20
+ SearchHome
21
+ </div>
22
+ </div>
23
+ `;
24
+
25
+ exports[`<SearchRoutes /> renders correctly with SEARCH_CONCEPTS route 1`] = `
26
+ <div>
27
+ <div>
28
+ SearchLoader
29
+ </div>
30
+ <div>
31
+ Search
32
+ </div>
33
+ </div>
34
+ `;
35
+
36
+ exports[`<SearchRoutes /> renders correctly with SEARCH_INGESTS route 1`] = `
37
+ <div>
38
+ <div>
39
+ SearchLoader
40
+ </div>
41
+ <div>
42
+ Search
43
+ </div>
44
+ </div>
45
+ `;
46
+
47
+ exports[`<SearchRoutes /> renders correctly with SEARCH_RESULTS route 1`] = `
48
+ <div>
49
+ <div>
50
+ SearchLoader
51
+ </div>
52
+ <div>
53
+ Search
54
+ </div>
55
+ </div>
56
+ `;
57
+
58
+ exports[`<SearchRoutes /> renders correctly with SEARCH_STRUCTURES route 1`] = `
59
+ <div>
60
+ <div>
61
+ SearchLoader
62
+ </div>
63
+ <div>
64
+ Search
65
+ </div>
66
+ </div>
67
+ `;
68
+
69
+ exports[`<SearchRoutes /> renders correctly with default route 1`] = `<div />`;
70
+
71
+ exports[`<SearchRoutes /> renders unauthorized component when not authorized 1`] = `
72
+ <div>
73
+ <div>
74
+ SearchLoader
75
+ </div>
76
+ <div
77
+ class="ui icon visible bottom attached message center"
78
+ >
79
+ <i
80
+ aria-hidden="true"
81
+ class="warning sign icon"
82
+ />
83
+ <div
84
+ class="content"
85
+ >
86
+ <div
87
+ class="header"
88
+ >
89
+ view.unauthorized.head
90
+ </div>
91
+ <p>
92
+ view.unauthorized.content
93
+ </p>
94
+ </div>
95
+ </div>
96
+ </div>
8
97
  `;
@@ -7,24 +7,28 @@ exports[`<SearchTabs /> matches the latest snapshot 1`] = `
7
7
  >
8
8
  <a
9
9
  class="active item"
10
+ data-discover="true"
10
11
  href="/search/results"
11
12
  >
12
13
  All
13
14
  </a>
14
15
  <a
15
16
  class="item"
17
+ data-discover="true"
16
18
  href="/search/concepts"
17
19
  >
18
20
  Concepts
19
21
  </a>
20
22
  <a
21
23
  class="item"
24
+ data-discover="true"
22
25
  href="/search/structures"
23
26
  >
24
27
  Structures
25
28
  </a>
26
29
  <a
27
30
  class="item"
31
+ data-discover="true"
28
32
  href="/search/ingests"
29
33
  >
30
34
  Ingests
@@ -2,7 +2,7 @@ import _ from "lodash/fp";
2
2
  import { compile } from "path-to-regexp";
3
3
  import useSWR from "swr";
4
4
  import useSWRMutations from "swr/mutation";
5
- import { renderHook } from "@testing-library/react-hooks";
5
+ import { renderHook } from "@testing-library/react";
6
6
  import { apiJson, apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
7
7
  import { API_ELASTIC_INDEXES, API_ELASTIC_INDEX } from "../../api";
8
8
  import { useElasticIndexes, useElasticIndexDelete } from "../useElasticIndexes";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SEARCH_CONCEPTS,
3
3
  SEARCH_INGESTS,
4
- SEARCH_RESULTS
4
+ SEARCH_RESULTS,
5
5
  } from "@truedat/core/routes";
6
6
  import { getSearchQuery } from "..";
7
7
 
@@ -13,7 +13,7 @@ describe("selectors: getSearchQuery", () => {
13
13
  expect(result).toEqual({
14
14
  page: 4,
15
15
  size: 20,
16
- indexes: ["concepts", "ingests", "structures"]
16
+ indexes: ["concepts", "ingests", "structures"],
17
17
  });
18
18
  });
19
19
 
@@ -25,7 +25,7 @@ describe("selectors: getSearchQuery", () => {
25
25
  expect(result).toEqual({
26
26
  page: 4,
27
27
  size: 20,
28
- indexes: ["concepts"]
28
+ indexes: ["concepts"],
29
29
  });
30
30
  });
31
31
 
@@ -34,7 +34,7 @@ describe("selectors: getSearchQuery", () => {
34
34
  query: "My q",
35
35
  path: SEARCH_CONCEPTS,
36
36
  page: 5,
37
- size: 20
37
+ size: 20,
38
38
  };
39
39
  const result = getSearchQuery({ searchQuery });
40
40
 
@@ -42,7 +42,7 @@ describe("selectors: getSearchQuery", () => {
42
42
  query: "My q",
43
43
  page: 4,
44
44
  size: 20,
45
- indexes: ["concepts"]
45
+ indexes: ["concepts"],
46
46
  });
47
47
  });
48
48
 
@@ -51,7 +51,7 @@ describe("selectors: getSearchQuery", () => {
51
51
  query: "My q",
52
52
  path: SEARCH_INGESTS,
53
53
  page: 5,
54
- size: 20
54
+ size: 20,
55
55
  };
56
56
  const result = getSearchQuery({ searchQuery });
57
57
 
@@ -59,7 +59,7 @@ describe("selectors: getSearchQuery", () => {
59
59
  query: "My q",
60
60
  page: 4,
61
61
  size: 20,
62
- indexes: ["ingests"]
62
+ indexes: ["ingests"],
63
63
  });
64
64
  });
65
65
  });
@@ -6,14 +6,14 @@ describe("selectors: searchIndicesSelector", () => {
6
6
  expect(searchIndicesSelector(state)).toEqual([
7
7
  "concepts",
8
8
  "ingests",
9
- "structures"
9
+ "structures",
10
10
  ]);
11
11
  });
12
12
 
13
13
  it("should return unique values present searchIndexes", () => {
14
14
  const searchIndexes = {
15
15
  bar: ["bar", "baz"],
16
- foo: ["foo", "bar"]
16
+ foo: ["foo", "bar"],
17
17
  };
18
18
  const state = { searchIndexes };
19
19
  expect(searchIndicesSelector(state)).toEqual(["bar", "baz", "foo"]);
@@ -4,15 +4,18 @@ describe("selectors: searchResultsSelector", () => {
4
4
  const searchResults = [
5
5
  {
6
6
  results: [
7
- { id: 1, name: "BC 1", index: "concepts", business_concept_id: 42 }
7
+ { id: "1", name: "BC 1", index: "concepts", business_concept_id: "42" },
8
8
  ],
9
- index: "concepts"
9
+ index: "concepts",
10
10
  },
11
11
  {
12
- results: [{ id: 2, name: "DS 1", index: "structures" }],
13
- index: "structures"
12
+ results: [{ id: "2", name: "DS 1", index: "structures" }],
13
+ index: "structures",
14
+ },
15
+ {
16
+ results: [{ id: "3", name: "IG 1", index: "ingests" }],
17
+ index: "ingests",
14
18
  },
15
- { results: [{ id: 3, name: "IG 1", index: "ingests" }], index: "ingests" }
16
19
  ];
17
20
 
18
21
  it("should return all search results removing the aggroupation by index", () => {
@@ -20,14 +23,14 @@ describe("selectors: searchResultsSelector", () => {
20
23
  expect(systems.length).toBe(3);
21
24
  expect(systems).toEqual([
22
25
  {
23
- id: 1,
26
+ id: "1",
24
27
  name: "BC 1",
25
28
  index: "concepts",
26
- business_concept_id: 42,
27
- to: "/concepts/42/versions/1"
29
+ business_concept_id: "42",
30
+ to: "/concepts/42/versions/1",
28
31
  },
29
- { id: 3, name: "IG 1", index: "ingests", to: "/ingests/3" },
30
- { id: 2, name: "DS 1", index: "structures", to: "/structures/2" }
32
+ { id: "3", name: "IG 1", index: "ingests", to: "/ingests/3" },
33
+ { id: "2", name: "DS 1", index: "structures", to: "/structures/2" },
31
34
  ]);
32
35
  });
33
36
  });
@@ -3,7 +3,7 @@ import {
3
3
  SEARCH_CONCEPTS,
4
4
  SEARCH_INGESTS,
5
5
  SEARCH_RESULTS,
6
- SEARCH_STRUCTURES
6
+ SEARCH_STRUCTURES,
7
7
  } from "@truedat/core/routes";
8
8
 
9
9
  export const defaultIndices = {
@@ -11,7 +11,7 @@ export const defaultIndices = {
11
11
  [SEARCH_RESULTS]: ["concepts", "ingests", "structures"],
12
12
  [SEARCH_CONCEPTS]: ["concepts"],
13
13
  [SEARCH_INGESTS]: ["ingests"],
14
- [SEARCH_STRUCTURES]: ["structures"]
14
+ [SEARCH_STRUCTURES]: ["structures"],
15
15
  };
16
16
 
17
17
  export default defaultIndices;
@@ -5,8 +5,8 @@ import { getSearchResults } from "./getSearchResults";
5
5
 
6
6
  const conceptUrl = (business_concept_id, id) =>
7
7
  linkTo.CONCEPT_VERSION({ business_concept_id, id });
8
- const structureUrl = id => linkTo.STRUCTURE({ id });
9
- const ingestUrl = id => linkTo.INGEST({ id });
8
+ const structureUrl = (id) => linkTo.STRUCTURE({ id });
9
+ const ingestUrl = (id) => linkTo.INGEST({ id });
10
10
 
11
11
  const indexUrl = ({ index, id, business_concept_id }) => {
12
12
  switch (index) {
@@ -21,10 +21,10 @@ const indexUrl = ({ index, id, business_concept_id }) => {
21
21
 
22
22
  export const searchResultsSelector = createSelector(
23
23
  [getSearchResults],
24
- searchResults =>
24
+ (searchResults) =>
25
25
  _.flow(
26
26
  _.reduce((acc, el) => [...acc, ..._.propOr([], "results")(el)], []),
27
27
  _.orderBy(["index"], ["asc"]),
28
- _.map(item => ({ ...item, to: indexUrl(item) }))
28
+ _.map((item) => ({ ...item, to: indexUrl(item) }))
29
29
  )(searchResults)
30
30
  );