@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,63 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useContext, useState } from "react";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Icon, Form } from "semantic-ui-react";
|
|
6
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
7
|
+
import StructureSelector from "@truedat/dd/components/StructureSelector";
|
|
8
|
+
|
|
9
|
+
export default function DataStructureSelector({ onChange }) {
|
|
10
|
+
const { formatMessage } = useIntl();
|
|
11
|
+
const { field } = useContext(QxContext);
|
|
12
|
+
const { watch } = useFormContext();
|
|
13
|
+
const selectedStructure = watch(`${field}.embedded`);
|
|
14
|
+
|
|
15
|
+
const [active, setActive] = useState(!selectedStructure);
|
|
16
|
+
|
|
17
|
+
const onClick = () => setActive(!active);
|
|
18
|
+
|
|
19
|
+
const handleSelect = (structure) => {
|
|
20
|
+
setActive(false);
|
|
21
|
+
onChange({
|
|
22
|
+
...structure,
|
|
23
|
+
fields: _.map(({ id, name, metadata }) => ({
|
|
24
|
+
id,
|
|
25
|
+
name,
|
|
26
|
+
parent_name: structure.name,
|
|
27
|
+
type: metadata?.data_type_class || "string",
|
|
28
|
+
}))(structure.data_fields),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
{active ? (
|
|
35
|
+
<div onClick={onClick}>
|
|
36
|
+
<Icon name="dropdown" />
|
|
37
|
+
{_.path("name")(selectedStructure) || ""}
|
|
38
|
+
</div>
|
|
39
|
+
) : (
|
|
40
|
+
<Form.Input
|
|
41
|
+
icon
|
|
42
|
+
value={selectedStructure?.name || ""}
|
|
43
|
+
placeholder={formatMessage({
|
|
44
|
+
id: "queryables.resource.selector.data_structure",
|
|
45
|
+
})}
|
|
46
|
+
required
|
|
47
|
+
fluid
|
|
48
|
+
onClick={onClick}
|
|
49
|
+
>
|
|
50
|
+
<input className="action-pointer" />
|
|
51
|
+
</Form.Input>
|
|
52
|
+
)}
|
|
53
|
+
{active && (
|
|
54
|
+
<StructureSelector
|
|
55
|
+
withDataFields
|
|
56
|
+
defaultFilters={{ "class.raw": ["table"] }}
|
|
57
|
+
selectedStructure={selectedStructure}
|
|
58
|
+
onSelect={handleSelect}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useContext, useState } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { Dropdown } from "semantic-ui-react";
|
|
5
|
+
import { matchSorter } from "match-sorter";
|
|
6
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
7
|
+
|
|
8
|
+
export default function DataViewSelector({ onChange, onBlur, value }) {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
11
|
+
const { dataViews, currentDataViewId } = useContext(QxContext);
|
|
12
|
+
|
|
13
|
+
const matchSorterFp = (items) =>
|
|
14
|
+
matchSorter(items, searchTerm, {
|
|
15
|
+
keys: ["name", "description"],
|
|
16
|
+
threshold: matchSorter.rankings.CONTAINS,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const options = _.flow(
|
|
20
|
+
_.reject(({ id }) => currentDataViewId && currentDataViewId == id),
|
|
21
|
+
_.cond([
|
|
22
|
+
[() => _.isEmpty(searchTerm), _.identity],
|
|
23
|
+
[_.stubTrue, matchSorterFp],
|
|
24
|
+
]),
|
|
25
|
+
_.map(({ id, name }) => ({
|
|
26
|
+
key: id,
|
|
27
|
+
value: id,
|
|
28
|
+
text: name,
|
|
29
|
+
}))
|
|
30
|
+
)(dataViews);
|
|
31
|
+
|
|
32
|
+
const buildEmbedded = (id) =>
|
|
33
|
+
_.flow(_.find({ id }), (dataView) => ({
|
|
34
|
+
...dataView,
|
|
35
|
+
fields: _.flow(
|
|
36
|
+
_.prop("select.properties.fields"),
|
|
37
|
+
_.map.convert({ cap: false })((field, id) => ({
|
|
38
|
+
id,
|
|
39
|
+
name: field.alias,
|
|
40
|
+
type: _.prop("expression.value.type")(field),
|
|
41
|
+
parent_name: dataView.name,
|
|
42
|
+
}))
|
|
43
|
+
)(dataView),
|
|
44
|
+
}))(dataViews);
|
|
45
|
+
|
|
46
|
+
const handleSearchChange = (_e, { searchQuery }) =>
|
|
47
|
+
setSearchTerm(searchQuery);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Dropdown
|
|
51
|
+
selection
|
|
52
|
+
onSearchChange={handleSearchChange}
|
|
53
|
+
search
|
|
54
|
+
fluid
|
|
55
|
+
searchQuery={searchTerm}
|
|
56
|
+
placeholder={formatMessage({
|
|
57
|
+
id: "queryables.resource.selector.data_view",
|
|
58
|
+
})}
|
|
59
|
+
onBlur={onBlur}
|
|
60
|
+
options={options}
|
|
61
|
+
onChange={(_e, { value }) => onChange && onChange(buildEmbedded(value))}
|
|
62
|
+
value={value}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useContext, useState } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { Dropdown } from "semantic-ui-react";
|
|
5
|
+
import { matchSorter } from "match-sorter";
|
|
6
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
7
|
+
|
|
8
|
+
export default function ReferenceDatasetSelector({ onChange, onBlur, value }) {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
11
|
+
const { referenceDatasets } = useContext(QxContext);
|
|
12
|
+
|
|
13
|
+
const matchSorterFp = (items) =>
|
|
14
|
+
matchSorter(items, searchTerm, {
|
|
15
|
+
keys: ["name", "headers"],
|
|
16
|
+
threshold: matchSorter.rankings.CONTAINS,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const options = _.flow(
|
|
20
|
+
_.cond([
|
|
21
|
+
[() => _.isEmpty(searchTerm), _.identity],
|
|
22
|
+
[_.stubTrue, matchSorterFp],
|
|
23
|
+
]),
|
|
24
|
+
_.map(({ id, name }) => ({
|
|
25
|
+
key: id,
|
|
26
|
+
value: id,
|
|
27
|
+
text: name,
|
|
28
|
+
}))
|
|
29
|
+
)(referenceDatasets);
|
|
30
|
+
|
|
31
|
+
const handleSearchChange = (_e, { searchQuery }) =>
|
|
32
|
+
setSearchTerm(searchQuery);
|
|
33
|
+
|
|
34
|
+
const buildEmbedded = (id) =>
|
|
35
|
+
_.flow(_.find({ id }), (refDataset) => ({
|
|
36
|
+
...refDataset,
|
|
37
|
+
fields: _.map.convert({ cap: false })((name, id) => ({
|
|
38
|
+
id,
|
|
39
|
+
name,
|
|
40
|
+
type: "string",
|
|
41
|
+
parent_name: refDataset.name,
|
|
42
|
+
}))(refDataset.headers),
|
|
43
|
+
}))(referenceDatasets);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
selection
|
|
48
|
+
onSearchChange={handleSearchChange}
|
|
49
|
+
search
|
|
50
|
+
fluid
|
|
51
|
+
searchQuery={searchTerm}
|
|
52
|
+
placeholder={formatMessage({
|
|
53
|
+
id: "queryables.resource.selector.reference_dataset",
|
|
54
|
+
})}
|
|
55
|
+
onBlur={onBlur}
|
|
56
|
+
options={options}
|
|
57
|
+
onChange={(_e, { value }) => onChange(buildEmbedded(value))}
|
|
58
|
+
value={value}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act } from "react-dom/test-utils";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
|
+
import DataStructureSelector from "../DataStructureSelector";
|
|
6
|
+
|
|
7
|
+
const renderOpts = {
|
|
8
|
+
messages: {
|
|
9
|
+
en: {
|
|
10
|
+
"queryables.resource.selector.data_structure": "data_structure",
|
|
11
|
+
"structures.not_found.body": "body",
|
|
12
|
+
"structures.search.placeholder": "placeholder",
|
|
13
|
+
"structures.not_found.header": "header",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("<DataStructureSelector />", () => {
|
|
19
|
+
it("matches the latest snapshot", async () => {
|
|
20
|
+
const { container } = render(
|
|
21
|
+
<TestFormWrapper>
|
|
22
|
+
<DataStructureSelector />
|
|
23
|
+
</TestFormWrapper>,
|
|
24
|
+
renderOpts
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
await act(async () => {
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/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 TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
7
|
+
import DataViewSelector from "../DataViewSelector";
|
|
8
|
+
|
|
9
|
+
const renderOpts = {
|
|
10
|
+
messages: {
|
|
11
|
+
en: {
|
|
12
|
+
"queryables.resource.selector.data_view": "data_view",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<DataViewSelector />", () => {
|
|
18
|
+
it("matches the latest snapshot", async () => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<TestFormWrapper
|
|
21
|
+
context={{
|
|
22
|
+
dataViews: [{ name: "UserDataView", id: 1 }],
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<DataViewSelector />
|
|
26
|
+
</TestFormWrapper>,
|
|
27
|
+
renderOpts
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
await act(async () => {
|
|
31
|
+
expect(container).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it("hides current data_view", async () => {
|
|
35
|
+
const { queryByText } = render(
|
|
36
|
+
<TestFormWrapper
|
|
37
|
+
context={{
|
|
38
|
+
dataViews: [
|
|
39
|
+
{ name: "UserDataView", id: 1 },
|
|
40
|
+
{ name: "SelectedDataView", id: 2 },
|
|
41
|
+
],
|
|
42
|
+
currentDataViewId: 2,
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<DataViewSelector />
|
|
46
|
+
</TestFormWrapper>,
|
|
47
|
+
renderOpts
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
await waitFor(() =>
|
|
51
|
+
expect(queryByText(/SelectedDataView/i)).not.toBeInTheDocument()
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
it("handles onChange", async () => {
|
|
55
|
+
const onChange = jest.fn();
|
|
56
|
+
const { getByRole } = render(
|
|
57
|
+
<TestFormWrapper
|
|
58
|
+
context={{
|
|
59
|
+
dataViews: [
|
|
60
|
+
{ name: "UserDataView", id: 1 },
|
|
61
|
+
{
|
|
62
|
+
name: "SelectedDataView",
|
|
63
|
+
id: 2,
|
|
64
|
+
select: {
|
|
65
|
+
properties: {
|
|
66
|
+
fields: [
|
|
67
|
+
{
|
|
68
|
+
alias: "field1",
|
|
69
|
+
id: 3,
|
|
70
|
+
expression: { value: { type: "string" } },
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<DataViewSelector onChange={onChange} />
|
|
80
|
+
</TestFormWrapper>,
|
|
81
|
+
renderOpts
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
userEvent.click(getByRole("option", { name: /SelectedDataView/i }));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(onChange).lastCalledWith({
|
|
89
|
+
fields: [
|
|
90
|
+
{
|
|
91
|
+
id: 0,
|
|
92
|
+
name: "field1",
|
|
93
|
+
parent_name: "SelectedDataView",
|
|
94
|
+
type: "string",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
id: 2,
|
|
98
|
+
name: "SelectedDataView",
|
|
99
|
+
select: {
|
|
100
|
+
properties: {
|
|
101
|
+
fields: [
|
|
102
|
+
{
|
|
103
|
+
alias: "field1",
|
|
104
|
+
id: 3,
|
|
105
|
+
expression: { value: { type: "string" } },
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("handles search", async () => {
|
|
114
|
+
const { getByRole, queryByText } = render(
|
|
115
|
+
<TestFormWrapper
|
|
116
|
+
context={{
|
|
117
|
+
dataViews: [
|
|
118
|
+
{ name: "UserDataView", id: 1 },
|
|
119
|
+
{ name: "SelectedDataView", id: 2 },
|
|
120
|
+
],
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<DataViewSelector />
|
|
124
|
+
</TestFormWrapper>,
|
|
125
|
+
renderOpts
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
userEvent.type(getByRole("textbox"), "User");
|
|
129
|
+
await waitFor(() =>
|
|
130
|
+
expect(queryByText(/SelectedDataView/i)).not.toBeInTheDocument()
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/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 TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
7
|
+
import ReferenceDatasetSelector from "../ReferenceDatasetSelector";
|
|
8
|
+
|
|
9
|
+
const renderOpts = {
|
|
10
|
+
messages: {
|
|
11
|
+
en: {
|
|
12
|
+
"queryables.resource.selector.reference_dataset": "reference_dataset",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<ReferenceDatasetSelector />", () => {
|
|
18
|
+
it("matches the latest snapshot", async () => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<TestFormWrapper
|
|
21
|
+
context={{
|
|
22
|
+
referenceDatasets: [{ name: "UserReferenceDataset", id: 1 }],
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<ReferenceDatasetSelector />
|
|
26
|
+
</TestFormWrapper>,
|
|
27
|
+
renderOpts
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
await act(async () => {
|
|
31
|
+
expect(container).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("handles onChange", async () => {
|
|
36
|
+
const onChange = jest.fn();
|
|
37
|
+
const { getByRole } = render(
|
|
38
|
+
<TestFormWrapper
|
|
39
|
+
context={{
|
|
40
|
+
referenceDatasets: [
|
|
41
|
+
{ name: "UserReferenceDataset", id: 1 },
|
|
42
|
+
{
|
|
43
|
+
name: "SelectedReferenceDataset",
|
|
44
|
+
id: 2,
|
|
45
|
+
headers: ["field1"],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<ReferenceDatasetSelector onChange={onChange} />
|
|
51
|
+
</TestFormWrapper>,
|
|
52
|
+
renderOpts
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
await act(async () => {
|
|
56
|
+
userEvent.click(
|
|
57
|
+
getByRole("option", { name: /SelectedReferenceDataset/i })
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(onChange).lastCalledWith({
|
|
62
|
+
fields: [
|
|
63
|
+
{
|
|
64
|
+
id: 0,
|
|
65
|
+
name: "field1",
|
|
66
|
+
parent_name: "SelectedReferenceDataset",
|
|
67
|
+
type: "string",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
id: 2,
|
|
71
|
+
name: "SelectedReferenceDataset",
|
|
72
|
+
headers: ["field1"],
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("handles search", async () => {
|
|
77
|
+
const { getByRole, queryByText } = render(
|
|
78
|
+
<TestFormWrapper
|
|
79
|
+
context={{
|
|
80
|
+
referenceDatasets: [
|
|
81
|
+
{ name: "UserReferenceDataset", id: 1 },
|
|
82
|
+
{ name: "SelectedReferenceDataset", id: 2 },
|
|
83
|
+
],
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<ReferenceDatasetSelector />
|
|
87
|
+
</TestFormWrapper>,
|
|
88
|
+
renderOpts
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
userEvent.type(getByRole("textbox"), "User");
|
|
92
|
+
|
|
93
|
+
await waitFor(() =>
|
|
94
|
+
expect(queryByText(/SelectedReferenceDataset/i)).not.toBeInTheDocument()
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<DataStructureSelector /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div>
|
|
6
|
+
<i
|
|
7
|
+
aria-hidden="true"
|
|
8
|
+
class="dropdown icon"
|
|
9
|
+
/>
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
<div
|
|
13
|
+
class="ui segment"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
class="ui action left icon input"
|
|
17
|
+
>
|
|
18
|
+
<i
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
class="search link icon"
|
|
21
|
+
/>
|
|
22
|
+
<input
|
|
23
|
+
placeholder="placeholder"
|
|
24
|
+
type="text"
|
|
25
|
+
value=""
|
|
26
|
+
/>
|
|
27
|
+
<button
|
|
28
|
+
class="ui icon button"
|
|
29
|
+
>
|
|
30
|
+
<i
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
class="calendar alternate outline icon"
|
|
33
|
+
/>
|
|
34
|
+
</button>
|
|
35
|
+
<div
|
|
36
|
+
aria-expanded="false"
|
|
37
|
+
class="ui button floating labeled scrolling dropdown icon"
|
|
38
|
+
role="listbox"
|
|
39
|
+
tabindex="0"
|
|
40
|
+
>
|
|
41
|
+
<div
|
|
42
|
+
aria-atomic="true"
|
|
43
|
+
aria-live="polite"
|
|
44
|
+
class="divider text"
|
|
45
|
+
role="alert"
|
|
46
|
+
>
|
|
47
|
+
Filters
|
|
48
|
+
</div>
|
|
49
|
+
<i
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
class="filter icon"
|
|
52
|
+
/>
|
|
53
|
+
<div
|
|
54
|
+
class="menu transition"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
class="item"
|
|
58
|
+
role="option"
|
|
59
|
+
>
|
|
60
|
+
<em>
|
|
61
|
+
(reset filters)
|
|
62
|
+
</em>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div
|
|
68
|
+
class="selectedFilters"
|
|
69
|
+
/>
|
|
70
|
+
<div
|
|
71
|
+
class="dimmable structure-table-overflow"
|
|
72
|
+
>
|
|
73
|
+
<div
|
|
74
|
+
class="ui inverted dimmer"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
class="content"
|
|
78
|
+
>
|
|
79
|
+
<div
|
|
80
|
+
class="ui large loader"
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
class="ui icon info message"
|
|
86
|
+
>
|
|
87
|
+
<i
|
|
88
|
+
aria-hidden="true"
|
|
89
|
+
class="search icon"
|
|
90
|
+
/>
|
|
91
|
+
<div
|
|
92
|
+
class="content"
|
|
93
|
+
>
|
|
94
|
+
<div
|
|
95
|
+
class="header"
|
|
96
|
+
>
|
|
97
|
+
header
|
|
98
|
+
</div>
|
|
99
|
+
body
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<DataViewSelector /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
aria-expanded="false"
|
|
7
|
+
class="ui fluid search selection dropdown"
|
|
8
|
+
role="combobox"
|
|
9
|
+
>
|
|
10
|
+
<input
|
|
11
|
+
aria-autocomplete="list"
|
|
12
|
+
autocomplete="off"
|
|
13
|
+
class="search"
|
|
14
|
+
tabindex="0"
|
|
15
|
+
type="text"
|
|
16
|
+
value=""
|
|
17
|
+
/>
|
|
18
|
+
<div
|
|
19
|
+
aria-atomic="true"
|
|
20
|
+
aria-live="polite"
|
|
21
|
+
class="divider default text"
|
|
22
|
+
role="alert"
|
|
23
|
+
>
|
|
24
|
+
data_view
|
|
25
|
+
</div>
|
|
26
|
+
<i
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
class="dropdown icon"
|
|
29
|
+
/>
|
|
30
|
+
<div
|
|
31
|
+
class="menu transition"
|
|
32
|
+
role="listbox"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
aria-checked="false"
|
|
36
|
+
aria-selected="true"
|
|
37
|
+
class="selected item"
|
|
38
|
+
role="option"
|
|
39
|
+
style="pointer-events: all;"
|
|
40
|
+
>
|
|
41
|
+
<span
|
|
42
|
+
class="text"
|
|
43
|
+
>
|
|
44
|
+
UserDataView
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<ReferenceDatasetSelector /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
aria-expanded="false"
|
|
7
|
+
class="ui fluid search selection dropdown"
|
|
8
|
+
role="combobox"
|
|
9
|
+
>
|
|
10
|
+
<input
|
|
11
|
+
aria-autocomplete="list"
|
|
12
|
+
autocomplete="off"
|
|
13
|
+
class="search"
|
|
14
|
+
tabindex="0"
|
|
15
|
+
type="text"
|
|
16
|
+
value=""
|
|
17
|
+
/>
|
|
18
|
+
<div
|
|
19
|
+
aria-atomic="true"
|
|
20
|
+
aria-live="polite"
|
|
21
|
+
class="divider default text"
|
|
22
|
+
role="alert"
|
|
23
|
+
>
|
|
24
|
+
reference_dataset
|
|
25
|
+
</div>
|
|
26
|
+
<i
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
class="dropdown icon"
|
|
29
|
+
/>
|
|
30
|
+
<div
|
|
31
|
+
class="menu transition"
|
|
32
|
+
role="listbox"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
aria-checked="false"
|
|
36
|
+
aria-selected="true"
|
|
37
|
+
class="selected item"
|
|
38
|
+
role="option"
|
|
39
|
+
style="pointer-events: all;"
|
|
40
|
+
>
|
|
41
|
+
<span
|
|
42
|
+
class="text"
|
|
43
|
+
>
|
|
44
|
+
UserReferenceDataset
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|