@truedat/qx 5.14.1 → 5.15.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.
- 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,116 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState, useContext, useEffect } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
6
|
+
import { Button, Grid, Form, GridColumn } from "semantic-ui-react";
|
|
7
|
+
import { Expression } from "@truedat/qx/components/common/expressions";
|
|
8
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
9
|
+
|
|
10
|
+
export const newSelectField = (id) => ({
|
|
11
|
+
id,
|
|
12
|
+
alias: "",
|
|
13
|
+
expression: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default function SelectField({ onDelete }) {
|
|
17
|
+
const context = useContext(QxContext);
|
|
18
|
+
const { field } = context;
|
|
19
|
+
const { formatMessage } = useIntl();
|
|
20
|
+
const { control, watch, setValue } = useFormContext();
|
|
21
|
+
const [isShownDelete, setIsShownDelete] = useState();
|
|
22
|
+
|
|
23
|
+
const { alias, expression, id } = watch(field) || {};
|
|
24
|
+
const fieldName = expression?.value?.name;
|
|
25
|
+
|
|
26
|
+
const parentField = field.match(/(.*)\.properties\.\w+\[\d+\]/)[1];
|
|
27
|
+
const queryable = watch(parentField);
|
|
28
|
+
const queryableFields =
|
|
29
|
+
queryable?.type == "select"
|
|
30
|
+
? queryable.properties.fields
|
|
31
|
+
: _.concat(queryable?.properties.aggregate_fields)(
|
|
32
|
+
queryable?.properties.group_fields
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const queryableFieldsAlias = _.flow(
|
|
36
|
+
_.remove((field) => field.id == id),
|
|
37
|
+
_.map("alias")
|
|
38
|
+
)(queryableFields);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!alias && fieldName)
|
|
42
|
+
setValue(`${field}.alias`, fieldName, { shouldValidate: true });
|
|
43
|
+
}, [field, fieldName, alias]);
|
|
44
|
+
|
|
45
|
+
const validateField = (value) =>
|
|
46
|
+
_.includes(value)(queryableFieldsAlias)
|
|
47
|
+
? formatMessage({
|
|
48
|
+
id: "dataViews.form.queryable.alias.duplicated",
|
|
49
|
+
})
|
|
50
|
+
: true;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
onMouseEnter={() => setIsShownDelete(true)}
|
|
55
|
+
onMouseLeave={() => setIsShownDelete(false)}
|
|
56
|
+
>
|
|
57
|
+
<Grid>
|
|
58
|
+
<Grid.Row>
|
|
59
|
+
<Grid.Column></Grid.Column>
|
|
60
|
+
<GridColumn width={9}>
|
|
61
|
+
<QxContext.Provider
|
|
62
|
+
value={{
|
|
63
|
+
...context,
|
|
64
|
+
type: "any",
|
|
65
|
+
field: `${field}.expression`,
|
|
66
|
+
defaultShape: "field",
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<Expression />
|
|
70
|
+
</QxContext.Provider>
|
|
71
|
+
</GridColumn>
|
|
72
|
+
<Grid.Column width={6}>
|
|
73
|
+
<Form.Group inline className="no-margin">
|
|
74
|
+
<Controller
|
|
75
|
+
control={control}
|
|
76
|
+
name={`${field}.alias`}
|
|
77
|
+
rules={{
|
|
78
|
+
required: formatMessage({ id: "functions.form.required" }),
|
|
79
|
+
validate: validateField,
|
|
80
|
+
}}
|
|
81
|
+
render={({
|
|
82
|
+
field: { onBlur, onChange },
|
|
83
|
+
fieldState: { error },
|
|
84
|
+
}) => (
|
|
85
|
+
<Form.Input
|
|
86
|
+
autoComplete="off"
|
|
87
|
+
placeholder={formatMessage({
|
|
88
|
+
id: "queryables.select.form.alias",
|
|
89
|
+
})}
|
|
90
|
+
error={error?.message}
|
|
91
|
+
onBlur={onBlur}
|
|
92
|
+
onChange={(_e, { value }) => onChange(value)}
|
|
93
|
+
value={alias}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
/>
|
|
97
|
+
{isShownDelete ? (
|
|
98
|
+
<Button
|
|
99
|
+
onClick={onDelete}
|
|
100
|
+
icon="trash alternate outline"
|
|
101
|
+
basic
|
|
102
|
+
color="red"
|
|
103
|
+
aria-label="delete"
|
|
104
|
+
/>
|
|
105
|
+
) : null}
|
|
106
|
+
</Form.Group>
|
|
107
|
+
</Grid.Column>
|
|
108
|
+
</Grid.Row>
|
|
109
|
+
</Grid>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
SelectField.propTypes = {
|
|
115
|
+
onDelete: PropTypes.func,
|
|
116
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import { Clauses } from "@truedat/qx/components/common/expressions";
|
|
4
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
5
|
+
|
|
6
|
+
export default function Where() {
|
|
7
|
+
const context = useContext(QxContext);
|
|
8
|
+
const { field } = context;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<QxContext.Provider value={{ ...context, field: `${field}.clauses` }}>
|
|
12
|
+
<Clauses />
|
|
13
|
+
</QxContext.Provider>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
|
|
5
|
+
import From from "../From";
|
|
6
|
+
|
|
7
|
+
const renderOpts = {
|
|
8
|
+
messages: {
|
|
9
|
+
en: {
|
|
10
|
+
"queryables.form.resource": "resource",
|
|
11
|
+
"queryables.resource.type.data_structure": "data_structure",
|
|
12
|
+
"queryables.resource.type.data_view": "data_view",
|
|
13
|
+
"queryables.resource.type.reference_dataset": "reference_dataset",
|
|
14
|
+
"queryables.resource.type": "type",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe("<From />", () => {
|
|
20
|
+
it("matches the latest snapshot", () => {
|
|
21
|
+
const { container } = render(
|
|
22
|
+
<TestFormWrapper>
|
|
23
|
+
<From />
|
|
24
|
+
</TestFormWrapper>,
|
|
25
|
+
renderOpts
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act } from "react-dom/test-utils";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
|
+
import { render } from "@truedat/test/render";
|
|
6
|
+
|
|
7
|
+
import GroupBy from "../GroupBy";
|
|
8
|
+
|
|
9
|
+
const renderOpts = {
|
|
10
|
+
messages: {
|
|
11
|
+
en: {
|
|
12
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
13
|
+
"queryables.group_by.form.add_aggregate_field": "add_aggregate_field",
|
|
14
|
+
"queryables.group_by.form.add_group_field": "add_group_field",
|
|
15
|
+
"queryables.group_by.form.aggregate_fields": "aggregate_fields",
|
|
16
|
+
"queryables.group_by.form.group_fields": "group_fields",
|
|
17
|
+
"queryables.select.form.alias": "alias",
|
|
18
|
+
"functions.form.required": "required",
|
|
19
|
+
"functions.form.expression.function.placeholder": "placeholder",
|
|
20
|
+
"functions.expression.shape.function": "function",
|
|
21
|
+
"functions.expression.shape.constant": "constant",
|
|
22
|
+
"functions.form.required": "required",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe("<GroupBy />", () => {
|
|
28
|
+
it("matches the latest snapshot", async () => {
|
|
29
|
+
const { container, debug, getByRole, getAllByRole } = render(
|
|
30
|
+
<TestFormWrapper
|
|
31
|
+
context={{
|
|
32
|
+
field: "queryables[0].properties",
|
|
33
|
+
functions: [{ class: "aggregator", name: "func", type: "number" }],
|
|
34
|
+
}}
|
|
35
|
+
defaultValues={{
|
|
36
|
+
queryables: [
|
|
37
|
+
{
|
|
38
|
+
id: 0,
|
|
39
|
+
type: "group_by",
|
|
40
|
+
properties: {
|
|
41
|
+
group_fields: [{ name: "abc", id: 1 }],
|
|
42
|
+
aggregate_fields: [{ name: "def", id: 2 }],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<GroupBy />
|
|
49
|
+
</TestFormWrapper>,
|
|
50
|
+
renderOpts
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
await act(async () => {
|
|
54
|
+
userEvent.click(getByRole("button", { name: /add_group_field/i }));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
userEvent.hover(getAllByRole("textbox")[2]);
|
|
58
|
+
await act(async () => {
|
|
59
|
+
userEvent.click(getByRole("button", { name: /delete/i }));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await act(async () => {
|
|
63
|
+
userEvent.click(getByRole("button", { name: /add_aggregate_field/i }));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
userEvent.hover(getAllByRole("textbox")[3]);
|
|
67
|
+
await act(async () => {
|
|
68
|
+
userEvent.click(getByRole("button", { name: /delete/i }));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await act(async () => {
|
|
72
|
+
expect(container).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
|
|
5
|
+
import Join from "../Join";
|
|
6
|
+
|
|
7
|
+
const renderOpts = {
|
|
8
|
+
messages: {
|
|
9
|
+
en: {
|
|
10
|
+
"dataViews.form.queryable.alias": "alias",
|
|
11
|
+
"joinType.full_outer": "full_outer",
|
|
12
|
+
"joinType.inner": "inner",
|
|
13
|
+
"joinType.left": "left",
|
|
14
|
+
"joinType.right": "right",
|
|
15
|
+
"queryables.form.join.type": "type",
|
|
16
|
+
"expression.clause.action.addGroup": "addGroup",
|
|
17
|
+
"expression.form.clause": "clause",
|
|
18
|
+
"queryables.resource.type": "type",
|
|
19
|
+
"queryables.form.resource": "resource",
|
|
20
|
+
"queryables.resource.type.data_view": "data_view",
|
|
21
|
+
"queryables.resource.type.reference_dataset": "reference_dataset",
|
|
22
|
+
"queryables.resource.type.data_structure": "data_structure",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe("<Join />", () => {
|
|
28
|
+
it("matches the latest snapshot", () => {
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<TestFormWrapper>
|
|
31
|
+
<Join />
|
|
32
|
+
</TestFormWrapper>,
|
|
33
|
+
renderOpts
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(container).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
|
|
4
|
+
import JoinTypeIcon from "../JoinTypeIcon";
|
|
5
|
+
|
|
6
|
+
const renderOpts = {
|
|
7
|
+
messages: {
|
|
8
|
+
en: {},
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe("<JoinTypeIcon />", () => {
|
|
13
|
+
it("matches the latest snapshot for inner join", () => {
|
|
14
|
+
const { container } = render(<JoinTypeIcon type="inner" />, renderOpts);
|
|
15
|
+
|
|
16
|
+
expect(container).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
it("matches the latest snapshot for left join", () => {
|
|
19
|
+
const { container } = render(<JoinTypeIcon type="left" />, renderOpts);
|
|
20
|
+
|
|
21
|
+
expect(container).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
it("matches the latest snapshot for right join", () => {
|
|
24
|
+
const { container } = render(<JoinTypeIcon type="right" />, renderOpts);
|
|
25
|
+
|
|
26
|
+
expect(container).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it("matches the latest snapshot for full_outer join", () => {
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<JoinTypeIcon type="full_outer" />,
|
|
31
|
+
renderOpts
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(container).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act } from "react-dom/test-utils";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
|
+
import { render } from "@truedat/test/render";
|
|
6
|
+
|
|
7
|
+
import Select from "../Select";
|
|
8
|
+
|
|
9
|
+
const renderOpts = {
|
|
10
|
+
messages: {
|
|
11
|
+
en: {
|
|
12
|
+
"dataViews.form.error.empty_select": "empty_select",
|
|
13
|
+
"queryables.select.form.add_select_field": "add_select_field",
|
|
14
|
+
"queryables.select.form.add_all_select_fields": "add_all_select_fields",
|
|
15
|
+
"queryables.select.form.alias": "alias",
|
|
16
|
+
"functions.expression.shape.field": "field",
|
|
17
|
+
"functions.expression.shape.function": "function",
|
|
18
|
+
"functions.expression.shape.constant": "constant",
|
|
19
|
+
"functions.form.required": "required",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe("<Select />", () => {
|
|
25
|
+
it("matches the latest snapshot", () => {
|
|
26
|
+
const { container } = render(
|
|
27
|
+
<TestFormWrapper>
|
|
28
|
+
<Select />
|
|
29
|
+
</TestFormWrapper>,
|
|
30
|
+
renderOpts
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(container).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
it("matches the latest snapshot with content", async () => {
|
|
36
|
+
const { container, getByRole } = render(
|
|
37
|
+
<TestFormWrapper
|
|
38
|
+
context={{
|
|
39
|
+
fields: [{ name: "abc", id: 1 }],
|
|
40
|
+
field: "select.properties",
|
|
41
|
+
}}
|
|
42
|
+
defaultValues={{
|
|
43
|
+
queryables: [
|
|
44
|
+
{
|
|
45
|
+
id: 0,
|
|
46
|
+
properties: {
|
|
47
|
+
resource: {
|
|
48
|
+
embedded: {
|
|
49
|
+
fields: [
|
|
50
|
+
{
|
|
51
|
+
id: 8,
|
|
52
|
+
name: "Column1",
|
|
53
|
+
parent_name: "ParentTable",
|
|
54
|
+
type: "string",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
id: 123,
|
|
58
|
+
name: "ParentTable",
|
|
59
|
+
},
|
|
60
|
+
id: 123,
|
|
61
|
+
type: "data_structure",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
type: "from",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
select: {
|
|
68
|
+
type: "select",
|
|
69
|
+
properties: {
|
|
70
|
+
fields: [{ name: "foo", id: 2 }],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<Select />
|
|
76
|
+
</TestFormWrapper>,
|
|
77
|
+
renderOpts
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
await act(async () => {
|
|
81
|
+
userEvent.click(getByRole("button", { name: /add_select_field/i }));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
expect(container).toMatchSnapshot();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it("handles add all fields", async () => {
|
|
89
|
+
const { container, getByRole, getAllByRole } = render(
|
|
90
|
+
<TestFormWrapper
|
|
91
|
+
context={{
|
|
92
|
+
fields: [{ name: "abc", id: 1 }],
|
|
93
|
+
field: "select.properties",
|
|
94
|
+
}}
|
|
95
|
+
defaultValues={{
|
|
96
|
+
queryables: [
|
|
97
|
+
{
|
|
98
|
+
id: 0,
|
|
99
|
+
properties: {
|
|
100
|
+
resource: {
|
|
101
|
+
embedded: {
|
|
102
|
+
fields: [
|
|
103
|
+
{
|
|
104
|
+
id: 8,
|
|
105
|
+
name: "Column1",
|
|
106
|
+
parent_name: "ParentTable",
|
|
107
|
+
type: "string",
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
id: 123,
|
|
111
|
+
name: "ParentTable",
|
|
112
|
+
},
|
|
113
|
+
id: 123,
|
|
114
|
+
type: "data_structure",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
type: "from",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
select: {
|
|
121
|
+
type: "select",
|
|
122
|
+
},
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<Select />
|
|
126
|
+
</TestFormWrapper>,
|
|
127
|
+
renderOpts
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
await act(async () => {
|
|
131
|
+
userEvent.click(getByRole("button", { name: /add_all_select_fields/i }));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
userEvent.hover(getAllByRole("textbox")[0]);
|
|
135
|
+
|
|
136
|
+
await act(async () => {
|
|
137
|
+
userEvent.click(getByRole("button", { name: /delete/i }));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await act(async () => {
|
|
141
|
+
expect(container).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act } from "react-dom/test-utils";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
|
+
import { render } from "@truedat/test/render";
|
|
6
|
+
|
|
7
|
+
import SelectField from "../SelectField";
|
|
8
|
+
|
|
9
|
+
const renderOpts = {
|
|
10
|
+
messages: {
|
|
11
|
+
en: {
|
|
12
|
+
"dataViews.form.queryable.alias.duplicated": "duplicated",
|
|
13
|
+
"functions.form.required": "required",
|
|
14
|
+
"queryables.select.form.alias": "alias",
|
|
15
|
+
"functions.form.expression.function.placeholder": "placeholder",
|
|
16
|
+
"functions.expression.shape.function": "function",
|
|
17
|
+
"functions.expression.shape.constant": "constant",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("<SelectField />", () => {
|
|
23
|
+
it("matches the latest snapshot for select", () => {
|
|
24
|
+
const { container } = render(
|
|
25
|
+
<TestFormWrapper
|
|
26
|
+
context={{
|
|
27
|
+
field: "select.properties.fields[0]",
|
|
28
|
+
}}
|
|
29
|
+
defaultValues={{
|
|
30
|
+
select: {
|
|
31
|
+
type: "select",
|
|
32
|
+
properties: {
|
|
33
|
+
fields: [{ name: "foo", id: 1 }],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<SelectField />
|
|
39
|
+
</TestFormWrapper>,
|
|
40
|
+
renderOpts
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(container).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
it("matches the latest snapshot for group_by", () => {
|
|
46
|
+
const { container } = render(
|
|
47
|
+
<TestFormWrapper
|
|
48
|
+
context={{
|
|
49
|
+
functions: [{ class: "aggregator", name: "func", type: "number" }],
|
|
50
|
+
field: "queryables[0].properties.fields[0]",
|
|
51
|
+
}}
|
|
52
|
+
defaultValues={{
|
|
53
|
+
queryables: [
|
|
54
|
+
{
|
|
55
|
+
type: "group_by",
|
|
56
|
+
properties: {
|
|
57
|
+
group_fields: [{ name: "foo", id: 1 }],
|
|
58
|
+
aggregate_fields: [{ name: "foo", id: 1 }],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<SelectField />
|
|
65
|
+
</TestFormWrapper>,
|
|
66
|
+
renderOpts
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(container).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("handles delete", async () => {
|
|
73
|
+
const onDelete = jest.fn();
|
|
74
|
+
const { getByRole, getAllByRole } = render(
|
|
75
|
+
<TestFormWrapper
|
|
76
|
+
context={{
|
|
77
|
+
functions: [{ class: "aggregator", name: "func", type: "number" }],
|
|
78
|
+
field: "queryables[0].properties.fields[0]",
|
|
79
|
+
}}
|
|
80
|
+
defaultValues={{
|
|
81
|
+
queryables: [
|
|
82
|
+
{
|
|
83
|
+
type: "group_by",
|
|
84
|
+
properties: {
|
|
85
|
+
group_fields: [{ name: "foo", id: 1 }],
|
|
86
|
+
aggregate_fields: [{ name: "foo", id: 1 }],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<SelectField onDelete={onDelete} />
|
|
93
|
+
</TestFormWrapper>,
|
|
94
|
+
renderOpts
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
userEvent.hover(getAllByRole("textbox")[0]);
|
|
98
|
+
userEvent.unhover(getAllByRole("textbox")[0]);
|
|
99
|
+
userEvent.hover(getAllByRole("textbox")[0]);
|
|
100
|
+
|
|
101
|
+
await act(async () => {
|
|
102
|
+
userEvent.click(getByRole("button", { name: /delete/i }));
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(onDelete).toHaveBeenCalledTimes(1);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
|
|
5
|
+
import Where from "../Where";
|
|
6
|
+
|
|
7
|
+
const renderOpts = {
|
|
8
|
+
messages: {
|
|
9
|
+
en: {
|
|
10
|
+
"expression.clause.action.addGroup": "Add Group",
|
|
11
|
+
"expression.form.clause": "Clause",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("<Where />", () => {
|
|
17
|
+
it("matches the latest snapshot", () => {
|
|
18
|
+
const { container } = render(
|
|
19
|
+
<TestFormWrapper>
|
|
20
|
+
<Where />
|
|
21
|
+
</TestFormWrapper>,
|
|
22
|
+
renderOpts
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(container).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/From.spec.js.snap
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<From /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="required field"
|
|
7
|
+
>
|
|
8
|
+
<label>
|
|
9
|
+
resource
|
|
10
|
+
</label>
|
|
11
|
+
<div
|
|
12
|
+
aria-expanded="false"
|
|
13
|
+
class="ui selection dropdown"
|
|
14
|
+
role="listbox"
|
|
15
|
+
tabindex="0"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
aria-atomic="true"
|
|
19
|
+
aria-live="polite"
|
|
20
|
+
class="divider default text"
|
|
21
|
+
role="alert"
|
|
22
|
+
>
|
|
23
|
+
type
|
|
24
|
+
</div>
|
|
25
|
+
<i
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
class="dropdown icon"
|
|
28
|
+
/>
|
|
29
|
+
<div
|
|
30
|
+
class="menu transition"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
aria-checked="false"
|
|
34
|
+
aria-selected="true"
|
|
35
|
+
class="selected item"
|
|
36
|
+
role="option"
|
|
37
|
+
style="pointer-events: all;"
|
|
38
|
+
>
|
|
39
|
+
<span
|
|
40
|
+
class="text"
|
|
41
|
+
>
|
|
42
|
+
data_structure
|
|
43
|
+
</span>
|
|
44
|
+
</div>
|
|
45
|
+
<div
|
|
46
|
+
aria-checked="false"
|
|
47
|
+
aria-selected="false"
|
|
48
|
+
class="item"
|
|
49
|
+
role="option"
|
|
50
|
+
style="pointer-events: all;"
|
|
51
|
+
>
|
|
52
|
+
<span
|
|
53
|
+
class="text"
|
|
54
|
+
>
|
|
55
|
+
reference_dataset
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
58
|
+
<div
|
|
59
|
+
aria-checked="false"
|
|
60
|
+
aria-selected="false"
|
|
61
|
+
class="item"
|
|
62
|
+
role="option"
|
|
63
|
+
style="pointer-events: all;"
|
|
64
|
+
>
|
|
65
|
+
<span
|
|
66
|
+
class="text"
|
|
67
|
+
>
|
|
68
|
+
data_view
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|