@truedat/dd 6.8.2 → 6.8.3

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.
@@ -1,58 +1,75 @@
1
- import React, { Suspense } from "react";
1
+ import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
- import { domainsMock } from "@truedat/test/mocks";
5
- import { STRUCTURE_NOTES_QUERY } from "../../api/queries";
6
4
  import PendingStructureNotes from "../PendingStructureNotes";
7
5
 
8
- const domains = [
9
- { id: "1", name: "Domain 1", level: 0 },
10
- { id: "2", name: "Domain 2", level: 0 },
11
- ];
12
- const systems = [
13
- { external_id: "some_external_id", id: 10, name: "some system" },
14
- ];
15
-
16
- const structureNotes = {
17
- loading: false,
18
- structureNotes: [
6
+ const data = {
7
+ data: [
19
8
  {
20
9
  id: "7207",
21
- status: "draft",
22
- dataStructure: {
23
- currentVersion: {
24
- name: "bar",
25
- path: ["bar rute"],
26
- },
27
- domains: [{ name: "bar domain" }],
28
- system: { name: "bar system" },
29
- },
10
+ note: { status: "draft" },
11
+ name: "bar",
12
+ path: ["bar rute"],
13
+ domains: [{ name: "bar domain" }],
14
+ system: { name: "bar system" },
15
+ non_published_note: { id: 1, status: "draft" },
30
16
  },
31
17
  {
32
18
  id: "665214",
33
- status: "rejected",
34
- dataStructure: {
35
- currentVersion: {
36
- name: "foo",
37
- path: ["foo rute", "other route"],
38
- },
39
- domains: [{ name: "foo domain 1" }, { name: "foo domain 2" }],
40
- system: { name: "foo system" },
41
- },
19
+ note: { status: "rejected" },
20
+ name: "foo",
21
+ path: ["foo rute", "other route"],
22
+ domains: [{ name: "foo domain 1" }, { name: "foo domain 2" }],
23
+ system: { name: "foo system" },
24
+ non_published_note: { id: 2, status: "rejected" },
42
25
  },
43
26
  ],
44
27
  };
45
28
 
46
- const structureNotesMock = {
47
- request: { query: STRUCTURE_NOTES_QUERY },
48
- result: { data: { structureNotes } },
49
- };
29
+ jest.mock("@truedat/dd/hooks/useStructures", () => {
30
+ const originalModule = jest.requireActual("@truedat/dd/hooks/useStructures");
31
+ return {
32
+ __esModule: true,
33
+ ...originalModule,
34
+ useDataStructureFilters: () => ({
35
+ trigger: () => ({
36
+ then: (callback) =>
37
+ callback({
38
+ data: {},
39
+ }),
40
+ }),
41
+ }),
42
+ useDataStructureSearch: () => ({
43
+ trigger: () => ({
44
+ then: (callback) =>
45
+ callback({
46
+ data,
47
+ headers: {},
48
+ }),
49
+ }),
50
+ }),
51
+ };
52
+ });
50
53
 
51
- const renderOpts = {
52
- mocks: [structureNotesMock, domainsMock({ action: "publishStructureNote" })],
53
- state: { domains, systems },
54
+ const messages = {
55
+ en: {
56
+ "pendingStructureNotes.props.domain": "Domain",
57
+ "pendingStructureNotes.props.status": "Status",
58
+ "pendingStructureNotes.props.name": "Name",
59
+ "search.placeholder": "Search...",
60
+ "pendingStructureNotes.props.path": "Path",
61
+ "pendingStructureNotes.props.system": "System",
62
+ "pendingStructureNotes.search.results.empty": "Empty",
63
+ "structures.retrieved.results": "{count} structures found",
64
+ "pendingStructureNotes.subheader": "Subheader",
65
+ "pendingStructureNotes.header": "Header",
66
+ "pendingStructureNotes.status.rejected": "Rejected",
67
+ "pendingStructureNotes.status.draft": "Draft",
68
+ },
54
69
  };
55
70
 
71
+ const renderOpts = { messages };
72
+
56
73
  describe("<PendingStructureNotes />", () => {
57
74
  it("matches the latest snapshot", async () => {
58
75
  const { container, queryByText } = render(
@@ -62,11 +79,7 @@ describe("<PendingStructureNotes />", () => {
62
79
  expect(container).toMatchSnapshot();
63
80
 
64
81
  await waitFor(() => {
65
- expect(queryByText(/some system/)).toBeTruthy();
66
- });
67
-
68
- await waitFor(() => {
69
- expect(queryByText(/fooDomain/)).toBeTruthy();
82
+ expect(queryByText(/foo system/)).toBeTruthy();
70
83
  });
71
84
  });
72
85
  });
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import { SearchContextProvider } from "@truedat/core/search/SearchContext";
4
+ import PendingStructureNotesLabelResults from "../PendingStructureNotesLabelResults";
5
+
6
+ const useFilters = () => ({
7
+ trigger: () => ({
8
+ then: (callback) =>
9
+ callback({
10
+ data: { data: {} },
11
+ }),
12
+ }),
13
+ });
14
+
15
+ const useSearch = () => ({
16
+ trigger: () => ({
17
+ then: (callback) =>
18
+ callback({
19
+ data: { data: [] },
20
+ headers: { "x-total-count": 22 },
21
+ }),
22
+ }),
23
+ });
24
+
25
+ const searchProps = {
26
+ initialSortColumn: "name.raw",
27
+ initialSortDirection: "ascending",
28
+ useSearch: useSearch,
29
+ userFiltersType: "structures",
30
+ omitFilters: [],
31
+ useFilters: useFilters,
32
+ translations: jest.fn(),
33
+ };
34
+
35
+ describe("<PendingStructureNotesLabelResults />", () => {
36
+ it("matches the latest snapshot", () => {
37
+ const { container } = render(
38
+ <SearchContextProvider {...searchProps}>
39
+ <PendingStructureNotesLabelResults />
40
+ </SearchContextProvider>
41
+ );
42
+ expect(container).toMatchSnapshot();
43
+ });
44
+ });
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import { SearchContextProvider } from "@truedat/core/search/SearchContext";
4
+ import PendingStructureNotesPagination from "../PendingStructureNotesPagination";
5
+
6
+ const useFilters = () => ({
7
+ trigger: () => ({
8
+ then: (callback) =>
9
+ callback({
10
+ data: { data: {} },
11
+ }),
12
+ }),
13
+ });
14
+
15
+ const useSearch = () => ({
16
+ trigger: () => ({
17
+ then: (callback) =>
18
+ callback({
19
+ data: { data: [] },
20
+ headers: { "x-total-count": 22 },
21
+ }),
22
+ }),
23
+ });
24
+
25
+ const searchProps = {
26
+ useSearch: useSearch,
27
+ useFilters: useFilters,
28
+ count: 20,
29
+ size: 20,
30
+ page: 1,
31
+ selectPage: jest.fn(),
32
+ };
33
+
34
+ describe("<PendingStructureNotesPagination />", () => {
35
+ it("matches the latest snapshot", () => {
36
+ const { container } = render(
37
+ <SearchContextProvider {...searchProps}>
38
+ <PendingStructureNotesPagination />
39
+ </SearchContextProvider>
40
+ );
41
+ expect(container).toMatchSnapshot();
42
+ });
43
+ });
@@ -1,8 +1,39 @@
1
1
  import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
+ import SearchContext from "@truedat/core/search/SearchContext";
4
5
  import PendingStructureNotesTable from "../PendingStructureNotesTable";
5
6
 
7
+ const structures = {
8
+ data: [
9
+ {
10
+ id: "7207",
11
+ note: { status: "draft" },
12
+ name: "bar",
13
+ path: ["bar rute"],
14
+ domains: [{ name: "bar domain" }],
15
+ system: { name: "bar system" },
16
+ non_published_note: { id: 1, status: "draft" },
17
+ },
18
+ {
19
+ id: "665214",
20
+ note: { status: "rejected" },
21
+ name: "foo",
22
+ path: ["foo rute", "other route"],
23
+ domains: [{ name: "foo domain 1" }, { name: "foo domain 2" }],
24
+ system: { name: "foo system" },
25
+ non_published_note: { id: 2, status: "rejected" },
26
+ },
27
+ ],
28
+ };
29
+
30
+ const searchProps = {
31
+ searchData: structures,
32
+ sortColumn: "name.raw",
33
+ sortDirection: "descending",
34
+ handleSortSelection: jest.fn(),
35
+ };
36
+
6
37
  const renderOpts = {
7
38
  messages: {
8
39
  en: {
@@ -10,69 +41,52 @@ const renderOpts = {
10
41
  "pendingStructureNotes.props.structure": "Structure",
11
42
  "pendingStructureNotes.props.status": "Status",
12
43
  "pendingStructureNotes.props.system": "System",
13
- "pendingStructureNotes.props.domains": "Domains",
44
+ "pendingStructureNotes.props.domain": "Domain",
14
45
  "structure.notes.status.draft": "Draft",
15
46
  "structure.notes.status.rejected": "Rejected",
16
47
  "pendingStructureNotes.props.path": "Path",
48
+ "pendingStructureNotes.props.name": "Name",
49
+ "pendingStructureNotes.status.rejected": "Rejected",
50
+ "pendingStructureNotes.status.draft": "Draft",
17
51
  },
18
52
  },
19
53
  };
20
54
 
21
- const props = {
22
- loading: false,
23
- structureNotes: [
24
- {
25
- id: "7207",
26
- status: "draft",
27
- data_structure: {
28
- current_version: {
29
- name: "bar",
30
- path: ["bar rute"],
31
- },
32
- domains: [{ name: "bar domain" }],
33
- system: { name: "bar system" },
34
- },
35
- },
36
- {
37
- id: "665214",
38
- status: "rejected",
39
- data_structure: {
40
- current_version: {
41
- name: "foo",
42
- path: ["foo rute", "other route"],
43
- },
44
- domains: [{ name: "foo domain 1" }, { name: "foo domain 2" }],
45
- system: { name: "foo system" },
46
- },
47
- },
48
- ],
49
- };
50
-
51
55
  describe("<PendingStructureNotesTable />", () => {
56
+ const columns = [
57
+ { name: "foo", sort: { name: "name.raw" } },
58
+ { name: "bar", sort: { name: "bar.raw" } },
59
+ ];
60
+ const props = { columns };
61
+
52
62
  it("matches the latest snapshot", async () => {
53
63
  const { container, queryByText } = render(
54
- <PendingStructureNotesTable {...props} />,
64
+ <SearchContext.Provider value={searchProps}>
65
+ <PendingStructureNotesTable {...props} />
66
+ </SearchContext.Provider>,
55
67
  renderOpts
56
68
  );
57
69
  expect(container).toMatchSnapshot();
58
70
 
59
71
  await waitFor(() => {
60
- expect(queryByText(/Draft/)).toBeTruthy();
72
+ expect(queryByText(/bar system/)).toBeTruthy();
61
73
  });
62
74
 
63
75
  await waitFor(() => {
64
- expect(queryByText(/Rejected/)).toBeTruthy();
76
+ expect(queryByText(/foo system/)).toBeTruthy();
65
77
  });
66
78
  });
67
79
 
68
80
  it("matches when StructureNotes are empty and not loading", async () => {
69
- const props = {
70
- loading: false,
71
- structureNotes: [],
81
+ const newSearchProps = {
82
+ ...searchProps,
83
+ searchData: [],
72
84
  };
73
85
 
74
86
  const { container, queryByText } = render(
75
- <PendingStructureNotesTable {...props} />,
87
+ <SearchContext.Provider value={newSearchProps}>
88
+ <PendingStructureNotesTable {...props} />
89
+ </SearchContext.Provider>,
76
90
  renderOpts
77
91
  );
78
92
  expect(container).toMatchSnapshot();
@@ -8,7 +8,8 @@ exports[`<PendingStructureNoteRow /> matches the latest snapshot 1`] = `
8
8
  class=""
9
9
  >
10
10
  <td
11
- class=""
11
+ class="structure-cell-overflow"
12
+ title="bar"
12
13
  >
13
14
  bar
14
15
  </td>
@@ -25,12 +26,16 @@ exports[`<PendingStructureNoteRow /> matches the latest snapshot 1`] = `
25
26
  <td
26
27
  class=""
27
28
  >
28
- bar domain
29
+ bar domain, baz domain
29
30
  </td>
30
31
  <td
31
32
  class=""
32
33
  >
33
- bar rute
34
+ <span
35
+ title="bar rute"
36
+ >
37
+ bar rute
38
+ </span>
34
39
  </td>
35
40
  </tr>
36
41
  </tbody>
@@ -15,111 +15,193 @@ exports[`<PendingStructureNotes /> matches the latest snapshot 1`] = `
15
15
  <div
16
16
  class="content"
17
17
  >
18
- Pending Notes
18
+ Header
19
19
  <div
20
20
  class="sub header"
21
21
  >
22
- Structure notes pending some action
22
+ Subheader
23
23
  </div>
24
24
  </div>
25
25
  </h2>
26
- <form
27
- class="ui loading form"
26
+ <div
27
+ class="ui action left icon input"
28
28
  >
29
- <h5
30
- class="ui header"
31
- >
32
- Filters
33
- </h5>
29
+ <i
30
+ aria-hidden="true"
31
+ class="search link icon"
32
+ />
33
+ <input
34
+ placeholder="Search..."
35
+ type="text"
36
+ value=""
37
+ />
34
38
  <div
35
- class="field subscriptions-checkbox-filters"
39
+ aria-busy="false"
40
+ aria-disabled="false"
41
+ aria-expanded="false"
42
+ class="ui button floating labeled scrolling dropdown icon"
43
+ role="listbox"
44
+ tabindex="0"
36
45
  >
37
- <label>
38
- Status
39
- </label>
40
46
  <div
41
- class="ui checked checkbox"
47
+ aria-atomic="true"
48
+ aria-live="polite"
49
+ class="divider text"
50
+ role="alert"
42
51
  >
43
- <input
44
- checked=""
45
- class="hidden"
46
- readonly=""
47
- tabindex="0"
48
- type="checkbox"
49
- value=""
50
- />
51
- <label>
52
- Pending approval
53
- </label>
52
+ Filters
54
53
  </div>
54
+ <i
55
+ aria-hidden="true"
56
+ class="filter icon"
57
+ />
55
58
  <div
56
- class="ui checked checkbox"
59
+ class="menu transition"
57
60
  >
58
- <input
59
- checked=""
60
- class="hidden"
61
- readonly=""
62
- tabindex="0"
63
- type="checkbox"
64
- value=""
65
- />
66
- <label>
67
- Draft
68
- </label>
61
+ <div
62
+ class="item"
63
+ role="option"
64
+ >
65
+ <em>
66
+ (reset filters)
67
+ </em>
68
+ </div>
69
69
  </div>
70
+ </div>
71
+ </div>
72
+ <div
73
+ class="selectedFilters"
74
+ />
75
+ <div
76
+ class="dimmable"
77
+ >
78
+ <div
79
+ class="ui inverted dimmer"
80
+ style=""
81
+ >
70
82
  <div
71
- class="ui checked checkbox"
83
+ class="content"
72
84
  >
73
- <input
74
- checked=""
75
- class="hidden"
76
- readonly=""
77
- tabindex="0"
78
- type="checkbox"
79
- value=""
85
+ <div
86
+ class="ui loader"
80
87
  />
81
- <label>
82
- Rejected
83
- </label>
84
88
  </div>
85
89
  </div>
86
90
  <div
87
- class="field"
91
+ class="ui label structures-notes-label-results"
88
92
  >
89
- <label>
90
- System
91
- </label>
92
- <div
93
- aria-expanded="false"
94
- aria-multiselectable="true"
95
- class="ui multiple selection dropdown"
96
- role="listbox"
97
- tabindex="0"
93
+ 0 structures found
94
+ </div>
95
+ <table
96
+ class="ui selectable sortable table"
97
+ >
98
+ <thead
99
+ class=""
98
100
  >
99
- <i
100
- aria-hidden="true"
101
- class="dropdown icon"
102
- />
103
- <div
104
- class="menu transition"
101
+ <tr
102
+ class=""
105
103
  >
106
- <div
107
- aria-checked="false"
108
- aria-selected="true"
109
- class="selected item"
110
- role="option"
111
- style="pointer-events: all;"
104
+ <th
105
+ class="two wide"
106
+ >
107
+ Name
108
+ </th>
109
+ <th
110
+ class="one wide"
111
+ >
112
+ Status
113
+ </th>
114
+ <th
115
+ class="one wide"
116
+ >
117
+ System
118
+ </th>
119
+ <th
120
+ class="one wide disabled"
121
+ >
122
+ Domain
123
+ </th>
124
+ <th
125
+ class="one wide disabled"
126
+ >
127
+ Path
128
+ </th>
129
+ </tr>
130
+ </thead>
131
+ <tbody
132
+ class=""
133
+ >
134
+ <tr
135
+ class=""
136
+ >
137
+ <td
138
+ class="structure-cell-overflow"
139
+ title="bar"
140
+ >
141
+ bar
142
+ </td>
143
+ <td
144
+ class=""
145
+ >
146
+ Draft
147
+ </td>
148
+ <td
149
+ class=""
150
+ >
151
+ bar system
152
+ </td>
153
+ <td
154
+ class=""
155
+ >
156
+ bar domain
157
+ </td>
158
+ <td
159
+ class=""
112
160
  >
113
161
  <span
114
- class="text"
162
+ title="bar rute"
115
163
  >
116
- some system
164
+ bar rute
117
165
  </span>
118
- </div>
119
- </div>
120
- </div>
121
- </div>
122
- </form>
166
+ </td>
167
+ </tr>
168
+ <tr
169
+ class=""
170
+ >
171
+ <td
172
+ class="structure-cell-overflow"
173
+ title="foo"
174
+ >
175
+ foo
176
+ </td>
177
+ <td
178
+ class=""
179
+ >
180
+ Rejected
181
+ </td>
182
+ <td
183
+ class=""
184
+ >
185
+ foo system
186
+ </td>
187
+ <td
188
+ class=""
189
+ >
190
+ foo domain 1, foo domain 2
191
+ </td>
192
+ <td
193
+ class=""
194
+ >
195
+ <span
196
+ title="foo rute › other route"
197
+ >
198
+ foo rute › other route
199
+ </span>
200
+ </td>
201
+ </tr>
202
+ </tbody>
203
+ </table>
204
+ </div>
123
205
  </div>
124
206
  </div>
125
207
  `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<PendingStructureNotesLabelResults /> matches the latest snapshot 1`] = `
4
+ <div>
5
+ <div
6
+ class="ui label structures-notes-label-results"
7
+ >
8
+ 22 structures found
9
+ </div>
10
+ </div>
11
+ `;