@truedat/qx 5.14.1 → 5.15.0
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 +3 -3
- package/src/api.js +3 -2
- package/src/components/QxRoutes.js +4 -4
- package/src/components/common/ResourceSelector.js +80 -0
- package/src/components/common/TestFormWrapper.js +9 -6
- package/src/components/common/TypeSelector.js +3 -1
- package/src/components/common/__tests__/DescriptionInput.spec.js +48 -0
- package/src/components/common/__tests__/ResourceSelector.spec.js +124 -0
- package/src/components/common/__tests__/TypeSelector.spec.js +29 -0
- package/src/components/common/__tests__/__snapshots__/DescriptionInput.spec.js.snap +19 -0
- package/src/components/common/__tests__/__snapshots__/ResourceSelector.spec.js.snap +484 -0
- package/src/components/common/__tests__/__snapshots__/TypeSelector.spec.js.snap +230 -0
- package/src/components/common/expressions/Clauses.js +100 -0
- package/src/components/common/expressions/Condition.js +178 -0
- package/src/components/common/expressions/Expression.js +54 -0
- package/src/components/common/expressions/FieldSelector.js +66 -0
- package/src/components/{functions → common}/expressions/FunctionArgs.js +1 -0
- package/src/components/{functions → common}/expressions/FunctionSelector.js +24 -4
- package/src/components/{functions → common}/expressions/ParamSelector.js +3 -3
- package/src/components/{functions → common}/expressions/ShapeSelector.js +22 -6
- package/src/components/common/expressions/__tests__/Clauses.spec.js +53 -0
- package/src/components/common/expressions/__tests__/Condition.spec.js +33 -0
- package/src/components/{functions → common}/expressions/__tests__/ConstantSelector.spec.js +6 -1
- package/src/components/{functions → common}/expressions/__tests__/Expression.spec.js +7 -5
- package/src/components/common/expressions/__tests__/FieldSelector.spec.js +24 -0
- package/src/components/{functions → common}/expressions/__tests__/FunctionArgs.spec.js +20 -6
- package/src/components/{functions → common}/expressions/__tests__/FunctionSelector.spec.js +1 -1
- package/src/components/{functions → common}/expressions/__tests__/ParamSelector.spec.js +22 -10
- package/src/components/{functions → common}/expressions/__tests__/ShapeSelector.spec.js +3 -3
- package/src/components/common/expressions/__tests__/__snapshots__/Clauses.spec.js.snap +64 -0
- package/src/components/common/expressions/__tests__/__snapshots__/Condition.spec.js.snap +316 -0
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ConstantSelector.spec.js.snap +1 -1
- package/src/components/common/expressions/__tests__/__snapshots__/Expression.spec.js.snap +939 -0
- package/src/components/common/expressions/__tests__/__snapshots__/FieldSelector.spec.js.snap +5 -0
- package/src/components/common/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +344 -0
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ParamSelector.spec.js.snap +4 -4
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ShapeSelector.spec.js.snap +17 -24
- package/src/components/common/expressions/constantInputs/AnySelector.js +44 -0
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/AnySelector.spec.js +21 -14
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/DefaultSelector.spec.js +5 -2
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/AnySelector.spec.js.snap +2 -2
- package/src/components/common/expressions/index.js +4 -0
- package/src/components/common/resourceSelectors/DataStructureSelector.js +63 -0
- package/src/components/common/resourceSelectors/DataViewSelector.js +65 -0
- package/src/components/common/resourceSelectors/ReferenceDatasetSelector.js +61 -0
- package/src/components/common/resourceSelectors/__tests__/DataStructureSelector.spec.js +31 -0
- package/src/components/common/resourceSelectors/__tests__/DataViewSelector.spec.js +133 -0
- package/src/components/common/resourceSelectors/__tests__/ReferenceDatasetSelector.spec.js +97 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataStructureSelector.spec.js.snap +105 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataViewSelector.spec.js.snap +50 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/ReferenceDatasetSelector.spec.js.snap +50 -0
- package/src/components/common/resourceSelectors/index.js +5 -0
- package/src/components/dataViews/DataViewEditor.js +170 -0
- package/src/components/dataViews/DataViewSelect.js +47 -0
- package/src/components/dataViews/DataViews.js +169 -0
- package/src/components/dataViews/Queryable.js +138 -0
- package/src/components/dataViews/Queryables.js +53 -0
- package/src/components/dataViews/__tests__/DataViewEditor.spec.js +293 -0
- package/src/components/dataViews/__tests__/DataViewSelect.spec.js +28 -0
- package/src/components/dataViews/__tests__/DataViews.spec.js +57 -0
- package/src/components/dataViews/__tests__/Queryable.spec.js +201 -0
- package/src/components/dataViews/__tests__/Queryables.spec.js +183 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViewEditor.spec.js.snap +1000 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViewSelect.spec.js.snap +55 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViews.spec.js.snap +77 -0
- package/src/components/dataViews/__tests__/__snapshots__/Queryable.spec.js.snap +874 -0
- package/src/components/dataViews/__tests__/__snapshots__/Queryables.spec.js.snap +911 -0
- package/src/components/dataViews/__tests__/queryableFunctions.spec.js +193 -0
- package/src/components/dataViews/queryableFunctions.js +80 -0
- package/src/components/dataViews/queryableProperties/From.js +15 -0
- package/src/components/dataViews/queryableProperties/GroupBy.js +124 -0
- package/src/components/dataViews/queryableProperties/Join.js +62 -0
- package/src/components/dataViews/queryableProperties/JoinTypeIcon.js +49 -0
- package/src/components/dataViews/queryableProperties/Select.js +76 -0
- package/src/components/dataViews/queryableProperties/SelectField.js +116 -0
- package/src/components/dataViews/queryableProperties/Where.js +15 -0
- package/src/components/dataViews/queryableProperties/__tests__/From.spec.js +30 -0
- package/src/components/dataViews/queryableProperties/__tests__/GroupBy.spec.js +75 -0
- package/src/components/dataViews/queryableProperties/__tests__/Join.spec.js +38 -0
- package/src/components/dataViews/queryableProperties/__tests__/JoinTypeIcon.spec.js +36 -0
- package/src/components/dataViews/queryableProperties/__tests__/Select.spec.js +144 -0
- package/src/components/dataViews/queryableProperties/__tests__/SelectField.spec.js +107 -0
- package/src/components/dataViews/queryableProperties/__tests__/Where.spec.js +27 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/From.spec.js.snap +75 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/GroupBy.spec.js.snap +276 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Join.spec.js.snap +252 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/JoinTypeIcon.spec.js.snap +77 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Select.spec.js.snap +411 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/SelectField.spec.js.snap +343 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Where.spec.js.snap +22 -0
- package/src/components/dataViews/queryableProperties/index.js +7 -0
- package/src/components/functions/FunctionEditor.js +30 -29
- package/src/components/functions/Functions.js +3 -11
- package/src/components/functions/__tests__/FunctionEditor.spec.js +6 -0
- package/src/components/functions/__tests__/FunctionParams.spec.js +6 -0
- package/src/components/functions/__tests__/__snapshots__/FunctionEditor.spec.js.snap +490 -466
- package/src/components/functions/__tests__/__snapshots__/FunctionParams.spec.js.snap +1 -1
- package/src/hooks/__tests__/{useDataSets.spec.js → useDataViews.spec.js} +5 -5
- package/src/hooks/useDataViews.js +33 -0
- package/src/styles/Expression.less +150 -0
- package/src/types.js +11 -3
- package/src/components/DataSets.js +0 -64
- package/src/components/__tests__/DataSets.spec.js +0 -46
- package/src/components/__tests__/__snapshots__/DataSets.spec.js.snap +0 -82
- package/src/components/functions/expressions/Expression.js +0 -40
- package/src/components/functions/expressions/FieldSelector.js +0 -56
- package/src/components/functions/expressions/__tests__/__snapshots__/Expression.spec.js.snap +0 -904
- package/src/components/functions/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +0 -392
- package/src/components/functions/expressions/constantInputs/AnySelector.js +0 -29
- package/src/hooks/useDataSets.js +0 -8
- /package/src/components/{functions → common}/expressions/ConstantSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/__tests__/__snapshots__/FunctionSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common/expressions}/__tests__/useWatchParams.spec.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/BooleanSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/DefaultSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/BooleanSelector.spec.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/BooleanSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/DefaultSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/index.js +0 -0
- /package/src/components/{functions → common/expressions}/useWatchParams.js +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act } from "react-dom/test-utils";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
import DataViewEditor from "../DataViewEditor";
|
|
6
|
+
|
|
7
|
+
const renderOpts = {
|
|
8
|
+
messages: {
|
|
9
|
+
en: {
|
|
10
|
+
"actions.cancel": "cancel",
|
|
11
|
+
"actions.delete": "delete",
|
|
12
|
+
"actions.discard.confirmation.content": "content",
|
|
13
|
+
"actions.discard.confirmation.header": "header",
|
|
14
|
+
"actions.save": "save",
|
|
15
|
+
"confirmation.no": "confirmation_no",
|
|
16
|
+
"confirmation.yes": "confirmation_yes",
|
|
17
|
+
"dataViews.action.delete.content": "content",
|
|
18
|
+
"dataViews.action.delete.header": "header",
|
|
19
|
+
"dataViews.action.new": "new",
|
|
20
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
21
|
+
"dataViews.form.name": "name",
|
|
22
|
+
"dataViews.form.queryable.alias": "alias",
|
|
23
|
+
"dataViews.form.queryable.from": "from",
|
|
24
|
+
"dataViews.form.queryable.group_by": "group_by",
|
|
25
|
+
"dataViews.form.queryable.join": "join",
|
|
26
|
+
"dataViews.form.queryable.select": "select",
|
|
27
|
+
"dataViews.form.queryable.where": "where",
|
|
28
|
+
"dataViews.form.select": "select",
|
|
29
|
+
"expression.clause.action.addExpression": "addExpression",
|
|
30
|
+
"expression.clause.action.addGroup": "addGroup",
|
|
31
|
+
"expression.condition.customExpression": "customExpression",
|
|
32
|
+
"expression.condition.selectFunction": "selectFunction",
|
|
33
|
+
"expression.form.clause": "clause",
|
|
34
|
+
"form.validation.required": "required",
|
|
35
|
+
"functions.expression.shape.constant": "constant",
|
|
36
|
+
"functions.expression.shape.field": "field",
|
|
37
|
+
"functions.expression.shape.function": "function",
|
|
38
|
+
"functions.form.add_description": "add_description",
|
|
39
|
+
"functions.form.required": "required",
|
|
40
|
+
"group.props.name": "name",
|
|
41
|
+
"queryables.form.resource": "resource",
|
|
42
|
+
"queryables.resource.selector.data_structure": "data_structure",
|
|
43
|
+
"queryables.resource.selector.data_view": "data_view",
|
|
44
|
+
"queryables.resource.type.data_structure": "data_structure",
|
|
45
|
+
"queryables.resource.type.data_view": "data_view",
|
|
46
|
+
"queryables.resource.type.reference_dataset": "reference_dataset",
|
|
47
|
+
"queryables.resource.type": "type",
|
|
48
|
+
"queryables.select.form.add_all_select_fields": "add_all_select_fields",
|
|
49
|
+
"queryables.select.form.add_select_field": "add_select_field",
|
|
50
|
+
"queryables.select.form.alias": "alias",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const defaultProps = {
|
|
56
|
+
selectedDataView: null,
|
|
57
|
+
context: {},
|
|
58
|
+
onSubmit: jest.fn(),
|
|
59
|
+
onCancel: jest.fn(),
|
|
60
|
+
onDelete: jest.fn(),
|
|
61
|
+
isSubmitting: false,
|
|
62
|
+
setDirty: jest.fn(),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
describe("<DataViewEditor />", () => {
|
|
66
|
+
it("matches the latest snapshot for empty", async () => {
|
|
67
|
+
const { container } = render(
|
|
68
|
+
<DataViewEditor {...defaultProps} />,
|
|
69
|
+
renderOpts
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
await act(async () => {
|
|
73
|
+
expect(container).toMatchSnapshot();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
it("matches the latest snapshot with content", async () => {
|
|
77
|
+
const props = {
|
|
78
|
+
...defaultProps,
|
|
79
|
+
selectedDataView: {
|
|
80
|
+
id: 4,
|
|
81
|
+
description: "Description",
|
|
82
|
+
name: "StructureView",
|
|
83
|
+
queryables: [
|
|
84
|
+
{
|
|
85
|
+
id: 0,
|
|
86
|
+
properties: {
|
|
87
|
+
resource: {
|
|
88
|
+
embedded: {
|
|
89
|
+
fields: [
|
|
90
|
+
{
|
|
91
|
+
id: 8,
|
|
92
|
+
name: "Column1",
|
|
93
|
+
parent_name: "ParentTable",
|
|
94
|
+
type: "string",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
id: 123,
|
|
98
|
+
name: "ParentTable",
|
|
99
|
+
},
|
|
100
|
+
id: 123,
|
|
101
|
+
type: "data_structure",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
type: "from",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
select: {
|
|
108
|
+
properties: {
|
|
109
|
+
fields: [
|
|
110
|
+
{
|
|
111
|
+
alias: "Column1",
|
|
112
|
+
expression: {
|
|
113
|
+
shape: "field",
|
|
114
|
+
value: {
|
|
115
|
+
id: 8,
|
|
116
|
+
name: "Column1",
|
|
117
|
+
parent_id: 0,
|
|
118
|
+
type: "string",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
id: 8,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
type: "select",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
const { container } = render(<DataViewEditor {...props} />, renderOpts);
|
|
130
|
+
|
|
131
|
+
await act(async () => {
|
|
132
|
+
expect(container).toMatchSnapshot();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("handles user interaction", async () => {
|
|
137
|
+
const onSubmit = jest.fn();
|
|
138
|
+
const props = {
|
|
139
|
+
...defaultProps,
|
|
140
|
+
onSubmit,
|
|
141
|
+
selectedDataView: {
|
|
142
|
+
name: "",
|
|
143
|
+
description: "",
|
|
144
|
+
queryables: [
|
|
145
|
+
{
|
|
146
|
+
id: 0,
|
|
147
|
+
alias: "",
|
|
148
|
+
type: "from",
|
|
149
|
+
properties: {
|
|
150
|
+
resource: null,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
select: {
|
|
155
|
+
type: "select",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
context: {
|
|
159
|
+
dataViews: [
|
|
160
|
+
{
|
|
161
|
+
id: 4,
|
|
162
|
+
description: "Description",
|
|
163
|
+
name: "AnotherDataView",
|
|
164
|
+
select: {
|
|
165
|
+
properties: {
|
|
166
|
+
fields: [
|
|
167
|
+
{
|
|
168
|
+
alias: "Column1",
|
|
169
|
+
expression: {
|
|
170
|
+
shape: "field",
|
|
171
|
+
value: {
|
|
172
|
+
id: 8,
|
|
173
|
+
name: "Column1",
|
|
174
|
+
parent_id: 0,
|
|
175
|
+
type: "string",
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
id: 8,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
type: "select",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const { container, getAllByRole, getByRole } = render(
|
|
189
|
+
<DataViewEditor {...props} />,
|
|
190
|
+
renderOpts
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
// Insert name
|
|
194
|
+
userEvent.type(getAllByRole("textbox")[0], "data_view_name");
|
|
195
|
+
|
|
196
|
+
// Insert From information
|
|
197
|
+
userEvent.type(getAllByRole("textbox")[1], "from_alias");
|
|
198
|
+
userEvent.click(getByRole("option", { name: /data_view/i }));
|
|
199
|
+
userEvent.click(getByRole("option", { name: /AnotherDataView/i }));
|
|
200
|
+
|
|
201
|
+
expect(getByRole("button", { name: /save/i })).toBeDisabled();
|
|
202
|
+
|
|
203
|
+
await act(async () => {
|
|
204
|
+
userEvent.click(getByRole("button", { name: /add_all_select_fields/i }));
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(getByRole("button", { name: /save/i })).toBeEnabled();
|
|
208
|
+
|
|
209
|
+
expect(container).toMatchSnapshot();
|
|
210
|
+
|
|
211
|
+
await act(async () => {
|
|
212
|
+
userEvent.click(getByRole("button", { name: /cancel/i }));
|
|
213
|
+
});
|
|
214
|
+
await act(async () => {
|
|
215
|
+
userEvent.click(getByRole("button", { name: /modal-negative-action/i }));
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
await act(async () => {
|
|
219
|
+
userEvent.click(getByRole("button", { name: /save/i }));
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
expect(onSubmit).toHaveBeenCalledWith({
|
|
223
|
+
description: "",
|
|
224
|
+
name: "data_view_name",
|
|
225
|
+
queryables: [
|
|
226
|
+
{
|
|
227
|
+
alias: "from_alias",
|
|
228
|
+
id: 0,
|
|
229
|
+
properties: {
|
|
230
|
+
resource: {
|
|
231
|
+
embedded: {
|
|
232
|
+
description: "Description",
|
|
233
|
+
fields: [
|
|
234
|
+
{
|
|
235
|
+
id: 0,
|
|
236
|
+
name: "Column1",
|
|
237
|
+
parent_name: "AnotherDataView",
|
|
238
|
+
type: "string",
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
id: 4,
|
|
242
|
+
name: "AnotherDataView",
|
|
243
|
+
select: {
|
|
244
|
+
properties: {
|
|
245
|
+
fields: [
|
|
246
|
+
{
|
|
247
|
+
alias: "Column1",
|
|
248
|
+
expression: {
|
|
249
|
+
shape: "field",
|
|
250
|
+
value: {
|
|
251
|
+
id: 8,
|
|
252
|
+
name: "Column1",
|
|
253
|
+
parent_id: 0,
|
|
254
|
+
type: "string",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
id: 8,
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
type: "select",
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
id: 4,
|
|
265
|
+
type: "data_view",
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
type: "from",
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
select: {
|
|
272
|
+
properties: {
|
|
273
|
+
fields: [
|
|
274
|
+
{
|
|
275
|
+
alias: "Column1",
|
|
276
|
+
expression: {
|
|
277
|
+
shape: "field",
|
|
278
|
+
value: {
|
|
279
|
+
id: 0,
|
|
280
|
+
name: "Column1",
|
|
281
|
+
parent_id: 0,
|
|
282
|
+
type: "string",
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
id: 0,
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
type: "select",
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
4
|
+
import DataViewSelect from "../DataViewSelect";
|
|
5
|
+
|
|
6
|
+
const renderOpts = {
|
|
7
|
+
messages: {
|
|
8
|
+
en: {
|
|
9
|
+
"queryables.select.form.add_all_select_fields": "add_all_select_fields",
|
|
10
|
+
"queryables.select.form.add_select_field": "add_select_field",
|
|
11
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
12
|
+
"dataViews.form.select": "select",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<DataViewSelect />", () => {
|
|
18
|
+
it("matches the latest snapshot", () => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<TestFormWrapper>
|
|
21
|
+
<DataViewSelect />
|
|
22
|
+
</TestFormWrapper>,
|
|
23
|
+
renderOpts
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(container).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
|
|
4
|
+
import DataViews from "../DataViews";
|
|
5
|
+
|
|
6
|
+
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
7
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
__esModule: true,
|
|
11
|
+
...originalModule,
|
|
12
|
+
useDataViews: jest.fn(() => ({
|
|
13
|
+
data: {
|
|
14
|
+
data: [
|
|
15
|
+
{
|
|
16
|
+
id: 4,
|
|
17
|
+
description: "Description",
|
|
18
|
+
name: "StructureView",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
loading: false,
|
|
23
|
+
})),
|
|
24
|
+
useDataViewCreate: jest.fn(() => ({
|
|
25
|
+
trigger: jest.fn(() => new Promise(() => {})),
|
|
26
|
+
isMutating: false,
|
|
27
|
+
})),
|
|
28
|
+
useDataViewDelete: jest.fn(() => ({
|
|
29
|
+
trigger: jest.fn(() => new Promise(() => {})),
|
|
30
|
+
isMutating: false,
|
|
31
|
+
})),
|
|
32
|
+
useDataViewUpdate: jest.fn(() => ({
|
|
33
|
+
trigger: jest.fn(() => new Promise(() => {})),
|
|
34
|
+
isMutating: false,
|
|
35
|
+
})),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const renderOpts = {
|
|
40
|
+
messages: {
|
|
41
|
+
en: {
|
|
42
|
+
"dataViews.action.new": "new",
|
|
43
|
+
"dataViews.empty_list": "empty_list",
|
|
44
|
+
"dataViews.no_selection": "no_selection",
|
|
45
|
+
"dataViews.subheader": "subheader",
|
|
46
|
+
"dataViews.header": "header",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
describe("<DataViews />", () => {
|
|
52
|
+
it("matches the latest snapshot", () => {
|
|
53
|
+
const { container } = render(<DataViews />, renderOpts);
|
|
54
|
+
|
|
55
|
+
expect(container).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
4
|
+
import Queryable from "../Queryable";
|
|
5
|
+
|
|
6
|
+
const renderOpts = {
|
|
7
|
+
messages: {
|
|
8
|
+
en: {
|
|
9
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
10
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
11
|
+
"dataViews.form.queryable.alias": "alias",
|
|
12
|
+
"dataViews.form.queryable.from": "from",
|
|
13
|
+
"dataViews.form.queryable.group_by": "group_by",
|
|
14
|
+
"dataViews.form.queryable.join": "join",
|
|
15
|
+
"dataViews.form.queryable.select": "select",
|
|
16
|
+
"expression.clause.action.addGroup": "addGroup",
|
|
17
|
+
"expression.form.clause": "clause",
|
|
18
|
+
"joinType.full_outer": "full_outer",
|
|
19
|
+
"joinType.inner": "inner",
|
|
20
|
+
"joinType.left": "left",
|
|
21
|
+
"joinType.right": "right",
|
|
22
|
+
"queryables.form.join.type": "type",
|
|
23
|
+
"queryables.form.resource": "resource",
|
|
24
|
+
"queryables.group_by.form.add_aggregate_field": "add_aggregate_field",
|
|
25
|
+
"queryables.group_by.form.add_group_field": "add_group_field",
|
|
26
|
+
"queryables.group_by.form.aggregate_fields": "aggregate_fields",
|
|
27
|
+
"queryables.group_by.form.group_fields": "group_fields",
|
|
28
|
+
"queryables.resource.selector.data_view": "data_view",
|
|
29
|
+
"queryables.resource.type.data_structure": "data_structure",
|
|
30
|
+
"queryables.resource.type.data_view": "data_view",
|
|
31
|
+
"queryables.resource.type.reference_dataset": "reference_dataset",
|
|
32
|
+
"queryables.resource.type": "type",
|
|
33
|
+
"queryables.select.form.add_all_select_fields": "add_all_select_fields",
|
|
34
|
+
"queryables.select.form.add_select_field": "add_select_field",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
describe("<Queryable />", () => {
|
|
40
|
+
it("matches the latest snapshot with from queryable", () => {
|
|
41
|
+
const { container } = render(
|
|
42
|
+
<TestFormWrapper
|
|
43
|
+
defaultValues={{
|
|
44
|
+
queryables: [
|
|
45
|
+
{
|
|
46
|
+
id: 0,
|
|
47
|
+
alias: "",
|
|
48
|
+
type: "from",
|
|
49
|
+
properties: {
|
|
50
|
+
resource: null,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Queryable index={0} />
|
|
57
|
+
</TestFormWrapper>,
|
|
58
|
+
renderOpts
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(container).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("matches the latest snapshot with join queryable", () => {
|
|
65
|
+
const { container } = render(
|
|
66
|
+
<TestFormWrapper
|
|
67
|
+
defaultValues={{
|
|
68
|
+
queryables: [
|
|
69
|
+
{
|
|
70
|
+
id: 0,
|
|
71
|
+
alias: "",
|
|
72
|
+
type: "join",
|
|
73
|
+
properties: {
|
|
74
|
+
resource: null,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<Queryable index={0} />
|
|
81
|
+
</TestFormWrapper>,
|
|
82
|
+
renderOpts
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
expect(container).toMatchSnapshot();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("matches the latest snapshot with select queryable", () => {
|
|
89
|
+
const { container } = render(
|
|
90
|
+
<TestFormWrapper
|
|
91
|
+
defaultValues={{
|
|
92
|
+
queryables: [
|
|
93
|
+
{
|
|
94
|
+
id: 0,
|
|
95
|
+
alias: "",
|
|
96
|
+
type: "select",
|
|
97
|
+
properties: {
|
|
98
|
+
fields: [],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
<Queryable index={0} />
|
|
105
|
+
</TestFormWrapper>,
|
|
106
|
+
renderOpts
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(container).toMatchSnapshot();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("matches the latest snapshot with from queryable", () => {
|
|
113
|
+
const { container } = render(
|
|
114
|
+
<TestFormWrapper
|
|
115
|
+
defaultValues={{
|
|
116
|
+
queryables: [
|
|
117
|
+
{
|
|
118
|
+
id: 0,
|
|
119
|
+
alias: "",
|
|
120
|
+
type: "group_by",
|
|
121
|
+
properties: {
|
|
122
|
+
group_fields: [],
|
|
123
|
+
aggregate_fields: [],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<Queryable index={0} />
|
|
130
|
+
</TestFormWrapper>,
|
|
131
|
+
renderOpts
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(container).toMatchSnapshot();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("matches the latest snapshot with duplicated alias", () => {
|
|
138
|
+
const { container } = render(
|
|
139
|
+
<TestFormWrapper
|
|
140
|
+
defaultValues={{
|
|
141
|
+
queryables: [
|
|
142
|
+
{
|
|
143
|
+
id: 0,
|
|
144
|
+
alias: "alias1",
|
|
145
|
+
type: "from",
|
|
146
|
+
properties: {
|
|
147
|
+
resource: null,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 0,
|
|
152
|
+
alias: "alias1",
|
|
153
|
+
type: "group_by",
|
|
154
|
+
properties: {
|
|
155
|
+
group_fields: [],
|
|
156
|
+
aggregate_fields: [],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
<Queryable index={0} />
|
|
163
|
+
</TestFormWrapper>,
|
|
164
|
+
renderOpts
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
expect(container).toMatchSnapshot();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("matches the latest snapshot with duplicated resource", () => {
|
|
171
|
+
const { container } = render(
|
|
172
|
+
<TestFormWrapper
|
|
173
|
+
defaultValues={{
|
|
174
|
+
queryables: [
|
|
175
|
+
{
|
|
176
|
+
id: 0,
|
|
177
|
+
alias: "alias1",
|
|
178
|
+
type: "from",
|
|
179
|
+
properties: {
|
|
180
|
+
resource: { id: 1, type: "data_view" },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: 0,
|
|
185
|
+
alias: "",
|
|
186
|
+
type: "join",
|
|
187
|
+
properties: {
|
|
188
|
+
resource: { id: 1, type: "data_view" },
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
<Queryable index={0} />
|
|
195
|
+
</TestFormWrapper>,
|
|
196
|
+
renderOpts
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
expect(container).toMatchSnapshot();
|
|
200
|
+
});
|
|
201
|
+
});
|