@truedat/qx 5.14.0 → 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/qx",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
4
4
|
"description": "Truedat Web Quality Experience package",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@truedat/core": "5.
|
|
87
|
+
"@truedat/core": "5.15.0",
|
|
88
88
|
"prop-types": "^15.8.1",
|
|
89
89
|
"react-hook-form": "^7.45.4",
|
|
90
90
|
"react-intl": "^5.20.10",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"react-dom": ">= 16.8.6 < 17",
|
|
98
98
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "93bcd66804df32821aa0d563b863774554a39047"
|
|
101
101
|
}
|
package/src/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const API_DATA_VIEWS = "/api/data_views";
|
|
2
|
+
const API_DATA_VIEW = "/api/data_views/:id";
|
|
2
3
|
const API_FUNCTIONS = "/api/quality_functions";
|
|
3
4
|
const API_FUNCTION = "/api/quality_functions/:id";
|
|
4
5
|
|
|
5
|
-
export {
|
|
6
|
+
export { API_DATA_VIEWS, API_DATA_VIEW, API_FUNCTIONS, API_FUNCTION };
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { Route } from "react-router-dom";
|
|
3
3
|
import { Unauthorized } from "@truedat/core/components";
|
|
4
4
|
import { useAuthorized } from "@truedat/core/hooks";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { DATA_VIEWS, FUNCTIONS } from "@truedat/core/routes";
|
|
6
|
+
import DataViews from "./dataViews/DataViews";
|
|
7
7
|
import Functions from "./functions/Functions";
|
|
8
8
|
|
|
9
9
|
export default function QxRoutes() {
|
|
@@ -12,8 +12,8 @@ export default function QxRoutes() {
|
|
|
12
12
|
return (
|
|
13
13
|
<>
|
|
14
14
|
<Route
|
|
15
|
-
path={
|
|
16
|
-
render={() => (authorized ? <
|
|
15
|
+
path={DATA_VIEWS}
|
|
16
|
+
render={() => (authorized ? <DataViews /> : <Unauthorized />)}
|
|
17
17
|
/>
|
|
18
18
|
<Route
|
|
19
19
|
path={FUNCTIONS}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React, { useContext } from "react";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
6
|
+
import { Form, Dropdown } from "semantic-ui-react";
|
|
7
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
8
|
+
import {
|
|
9
|
+
DataViewSelector,
|
|
10
|
+
DataStructureSelector,
|
|
11
|
+
ReferenceDatasetSelector,
|
|
12
|
+
} from "./resourceSelectors";
|
|
13
|
+
|
|
14
|
+
export default function ResourceSelector({ required }) {
|
|
15
|
+
const { formatMessage } = useIntl();
|
|
16
|
+
const { field } = useContext(QxContext);
|
|
17
|
+
const { control, setValue, watch } = useFormContext();
|
|
18
|
+
|
|
19
|
+
const type = watch(`${field}.type`);
|
|
20
|
+
const resourceTypeOptions = _.map((v) => ({
|
|
21
|
+
key: v,
|
|
22
|
+
value: v,
|
|
23
|
+
text: formatMessage({ id: `queryables.resource.type.${v}` }),
|
|
24
|
+
}))(["data_structure", "reference_dataset", "data_view"]);
|
|
25
|
+
|
|
26
|
+
const resourceSelectorForType = {
|
|
27
|
+
data_view: DataViewSelector,
|
|
28
|
+
data_structure: DataStructureSelector,
|
|
29
|
+
reference_dataset: ReferenceDatasetSelector,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<Controller
|
|
35
|
+
name={`${field}.type`}
|
|
36
|
+
control={control}
|
|
37
|
+
render={({ field: { onBlur, onChange } }) => (
|
|
38
|
+
<Form.Field required={required}>
|
|
39
|
+
<label>{formatMessage({ id: "queryables.form.resource" })}</label>
|
|
40
|
+
<Dropdown
|
|
41
|
+
selection
|
|
42
|
+
placeholder={formatMessage({ id: "queryables.resource.type" })}
|
|
43
|
+
onBlur={onBlur}
|
|
44
|
+
options={resourceTypeOptions}
|
|
45
|
+
onChange={(_e, { value }) => {
|
|
46
|
+
onChange(value);
|
|
47
|
+
setValue(`${field}.id`, undefined);
|
|
48
|
+
setValue(`${field}.embedded`, undefined);
|
|
49
|
+
}}
|
|
50
|
+
value={type}
|
|
51
|
+
/>
|
|
52
|
+
</Form.Field>
|
|
53
|
+
)}
|
|
54
|
+
/>
|
|
55
|
+
{type ? (
|
|
56
|
+
<Controller
|
|
57
|
+
name={`${field}.id`}
|
|
58
|
+
control={control}
|
|
59
|
+
render={({ field: { onBlur, onChange, value } }) => {
|
|
60
|
+
const ResourceSelectorForType = resourceSelectorForType[type];
|
|
61
|
+
return (
|
|
62
|
+
<ResourceSelectorForType
|
|
63
|
+
onBlur={onBlur}
|
|
64
|
+
onChange={(value) => {
|
|
65
|
+
onChange(value?.id);
|
|
66
|
+
setValue(`${field}.embedded`, value);
|
|
67
|
+
}}
|
|
68
|
+
value={value}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
) : null}
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ResourceSelector.propTypes = {
|
|
79
|
+
required: PropTypes.bool,
|
|
80
|
+
};
|
|
@@ -4,9 +4,7 @@ import { FormProvider, useForm } from "react-hook-form";
|
|
|
4
4
|
import QxContext from "@truedat/qx/components/QxContext";
|
|
5
5
|
|
|
6
6
|
export default function TestFormWrapper({
|
|
7
|
-
|
|
8
|
-
field = "test",
|
|
9
|
-
functions = [],
|
|
7
|
+
context,
|
|
10
8
|
children,
|
|
11
9
|
watcher,
|
|
12
10
|
defaultValues,
|
|
@@ -14,11 +12,16 @@ export default function TestFormWrapper({
|
|
|
14
12
|
const form = useForm({ mode: "onChange", defaultValues });
|
|
15
13
|
watcher && watcher(form.watch());
|
|
16
14
|
|
|
15
|
+
const qxContext = {
|
|
16
|
+
type: "string",
|
|
17
|
+
field: "test",
|
|
18
|
+
functions: [],
|
|
19
|
+
...context,
|
|
20
|
+
};
|
|
21
|
+
|
|
17
22
|
return (
|
|
18
23
|
<FormProvider {...form}>
|
|
19
|
-
<QxContext.Provider value={{
|
|
20
|
-
{children}
|
|
21
|
-
</QxContext.Provider>
|
|
24
|
+
<QxContext.Provider value={qxContext}>{children}</QxContext.Provider>
|
|
22
25
|
</FormProvider>
|
|
23
26
|
);
|
|
24
27
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
3
4
|
import { Dropdown } from "semantic-ui-react";
|
|
4
5
|
import { typeToIcon, types } from "@truedat/qx/types";
|
|
5
6
|
|
|
@@ -10,11 +11,12 @@ export default function TypeSelector({
|
|
|
10
11
|
withoutTypeAny,
|
|
11
12
|
name = "type",
|
|
12
13
|
}) {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
13
15
|
const options = _.flow(
|
|
14
16
|
_.reject((value) => withoutTypeAny && value == "any"),
|
|
15
17
|
_.map((value) => ({
|
|
16
18
|
key: value,
|
|
17
|
-
text: value,
|
|
19
|
+
text: formatMessage({ id: `expressions.data_type.${value}` }),
|
|
18
20
|
value,
|
|
19
21
|
icon: typeToIcon(value),
|
|
20
22
|
}))
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { act } from "react-dom/test-utils";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import { render } from "@truedat/test/render";
|
|
6
|
+
import DescriptionInput from "../DescriptionInput";
|
|
7
|
+
|
|
8
|
+
const renderOpts = {
|
|
9
|
+
messages: {
|
|
10
|
+
en: {
|
|
11
|
+
"functions.form.add_description": "add_description",
|
|
12
|
+
"functions.form.description": "description",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<DescriptionInput />", () => {
|
|
18
|
+
it("matches the latest snapshot", () => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<DescriptionInput value="value" />,
|
|
21
|
+
renderOpts
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(container).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
it("handles user input", async () => {
|
|
27
|
+
const props = {
|
|
28
|
+
onBlur: jest.fn(),
|
|
29
|
+
onChange: jest.fn(),
|
|
30
|
+
};
|
|
31
|
+
const { getByRole } = render(<DescriptionInput {...props} />, renderOpts);
|
|
32
|
+
|
|
33
|
+
await act(async () => {
|
|
34
|
+
userEvent.click(getByRole("listitem"));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
userEvent.type(getByRole("textbox"), "description");
|
|
38
|
+
|
|
39
|
+
await act(async () => {
|
|
40
|
+
userEvent.click(getByRole("list"));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const [_event, { value: lastValue }] = props.onChange.mock.lastCall;
|
|
44
|
+
|
|
45
|
+
expect(lastValue).toBe("description");
|
|
46
|
+
expect(props.onBlur).toHaveBeenCalledTimes(1);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
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 TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
6
|
+
import ResourceSelector from "../ResourceSelector";
|
|
7
|
+
|
|
8
|
+
const renderOpts = {
|
|
9
|
+
messages: {
|
|
10
|
+
en: {
|
|
11
|
+
"queryables.form.resource": "resource",
|
|
12
|
+
"queryables.resource.type": "type",
|
|
13
|
+
"queryables.resource.type.data_structure": "data_structure",
|
|
14
|
+
"queryables.resource.type.reference_dataset": "reference_dataset",
|
|
15
|
+
"queryables.resource.type.data_view": "data_view",
|
|
16
|
+
"queryables.resource.selector.data_view": "data_view",
|
|
17
|
+
"queryables.resource.selector.reference_dataset": "reference_dataset",
|
|
18
|
+
"structures.not_found.body": "body",
|
|
19
|
+
"structures.not_found.header": "header",
|
|
20
|
+
"structures.search.placeholder": "placeholder",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("<ResourceSelector />", () => {
|
|
26
|
+
it("matches the latest snapshot", () => {
|
|
27
|
+
const { container } = render(
|
|
28
|
+
<TestFormWrapper>
|
|
29
|
+
<ResourceSelector />
|
|
30
|
+
</TestFormWrapper>,
|
|
31
|
+
renderOpts
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(container).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("select data_view", async () => {
|
|
38
|
+
const watcher = jest.fn();
|
|
39
|
+
const { container, getByRole } = render(
|
|
40
|
+
<TestFormWrapper
|
|
41
|
+
context={{
|
|
42
|
+
dataViews: [{ name: "UserDataView", id: 1 }],
|
|
43
|
+
}}
|
|
44
|
+
watcher={watcher}
|
|
45
|
+
>
|
|
46
|
+
<ResourceSelector />
|
|
47
|
+
</TestFormWrapper>,
|
|
48
|
+
renderOpts
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
await act(async () => {
|
|
52
|
+
userEvent.click(getByRole("option", { name: /data_view/i }));
|
|
53
|
+
});
|
|
54
|
+
await act(async () => {
|
|
55
|
+
userEvent.click(getByRole("option", { name: /UserDataView/i }));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(watcher).lastCalledWith({
|
|
59
|
+
test: {
|
|
60
|
+
embedded: {
|
|
61
|
+
fields: [],
|
|
62
|
+
id: 1,
|
|
63
|
+
name: "UserDataView",
|
|
64
|
+
},
|
|
65
|
+
id: 1,
|
|
66
|
+
type: "data_view",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(container).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("select data_structure", async () => {
|
|
74
|
+
const watcher = jest.fn();
|
|
75
|
+
const { container, getByRole } = render(
|
|
76
|
+
<TestFormWrapper>
|
|
77
|
+
<ResourceSelector />
|
|
78
|
+
</TestFormWrapper>,
|
|
79
|
+
renderOpts
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
await act(async () => {
|
|
83
|
+
userEvent.click(getByRole("option", { name: /data_structure/i }));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(container).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("select reference_dataset", async () => {
|
|
90
|
+
const watcher = jest.fn();
|
|
91
|
+
const { container, getByRole } = render(
|
|
92
|
+
<TestFormWrapper
|
|
93
|
+
context={{
|
|
94
|
+
referenceDatasets: [{ name: "UserReferenceDataset", id: 1 }],
|
|
95
|
+
}}
|
|
96
|
+
watcher={watcher}
|
|
97
|
+
>
|
|
98
|
+
<ResourceSelector />
|
|
99
|
+
</TestFormWrapper>,
|
|
100
|
+
renderOpts
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
await act(async () => {
|
|
104
|
+
userEvent.click(getByRole("option", { name: /reference_dataset/i }));
|
|
105
|
+
});
|
|
106
|
+
await act(async () => {
|
|
107
|
+
userEvent.click(getByRole("option", { name: /UserReferenceDataset/i }));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(watcher).lastCalledWith({
|
|
111
|
+
test: {
|
|
112
|
+
embedded: {
|
|
113
|
+
fields: [],
|
|
114
|
+
id: 1,
|
|
115
|
+
name: "UserReferenceDataset",
|
|
116
|
+
},
|
|
117
|
+
id: 1,
|
|
118
|
+
type: "reference_dataset",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(container).toMatchSnapshot();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import TypeSelector from "../TypeSelector";
|
|
4
|
+
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
messages: {
|
|
7
|
+
en: {
|
|
8
|
+
"expressions.data_type.timestamp": "timestamp",
|
|
9
|
+
"expressions.data_type.date": "date",
|
|
10
|
+
"expressions.data_type.number": "number",
|
|
11
|
+
"expressions.data_type.string": "string",
|
|
12
|
+
"expressions.data_type.boolean": "boolean",
|
|
13
|
+
"expressions.data_type.any": "any",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("<TypeSelector />", () => {
|
|
19
|
+
it("matches the latest snapshot", () => {
|
|
20
|
+
const { container } = render(<TypeSelector />, renderOpts);
|
|
21
|
+
|
|
22
|
+
expect(container).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
it("matches the latest snapshot withoutTypeAny", () => {
|
|
25
|
+
const { container } = render(<TypeSelector withoutTypeAny />, renderOpts);
|
|
26
|
+
|
|
27
|
+
expect(container).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<DescriptionInput /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="ui horizontal link list"
|
|
7
|
+
role="list"
|
|
8
|
+
>
|
|
9
|
+
<a
|
|
10
|
+
class="item"
|
|
11
|
+
role="listitem"
|
|
12
|
+
style="font-style: italic; font-size: 13px; padding: 9.5px 14px;"
|
|
13
|
+
tabindex="0"
|
|
14
|
+
>
|
|
15
|
+
value
|
|
16
|
+
</a>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|