@truedat/qx 8.3.5 → 8.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/qx",
3
- "version": "8.3.5",
3
+ "version": "8.4.0",
4
4
  "description": "Truedat Web Quality Experience package",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -56,7 +56,7 @@
56
56
  "@testing-library/jest-dom": "^6.6.3",
57
57
  "@testing-library/react": "^16.3.0",
58
58
  "@testing-library/user-event": "^14.6.1",
59
- "@truedat/test": "8.3.5",
59
+ "@truedat/test": "8.3.6",
60
60
  "identity-obj-proxy": "^3.0.0",
61
61
  "jest": "^29.7.0",
62
62
  "redux-saga-test-plan": "^4.0.6"
@@ -89,5 +89,5 @@
89
89
  "semantic-ui-react": "^3.0.0-beta.2",
90
90
  "swr": "^2.3.3"
91
91
  },
92
- "gitHead": "12d1969c3403861d360fbdc24fd270ab1fece070"
92
+ "gitHead": "d5bf6e90b3e11093255962cbd47534f2a67fe313"
93
93
  }
package/src/api.js CHANGED
@@ -5,6 +5,7 @@ const API_FUNCTIONS = "/api/quality_functions";
5
5
  const API_QUALITY_CONTROL_DRAFT = "/api/quality_controls/:id/draft";
6
6
  const API_QUALITY_CONTROL_FILTERS = "/api/quality_controls/filters";
7
7
  const API_QUALITY_CONTROL_MAIN = "/api/quality_controls/:id/main";
8
+ const API_QUALITY_CONTROL_DOMAIN = "/api/quality_controls/:id/domain";
8
9
  const API_QUALITY_CONTROL_PUBLISHED = "/api/quality_controls/:id/published";
9
10
  const API_QUALITY_CONTROL_QUERIES = "/api/quality_controls/:id/queries";
10
11
  const API_QUALITY_CONTROL_SEARCH = "/api/quality_controls/search";
@@ -33,6 +34,7 @@ export {
33
34
  API_QUALITY_CONTROL_DRAFT,
34
35
  API_QUALITY_CONTROL_FILTERS,
35
36
  API_QUALITY_CONTROL_MAIN,
37
+ API_QUALITY_CONTROL_DOMAIN,
36
38
  API_QUALITY_CONTROL_PUBLISHED,
37
39
  API_QUALITY_CONTROL_QUERIES,
38
40
  API_QUALITY_CONTROL_SEARCH,
@@ -37,7 +37,7 @@ const DomainPopup = () => {
37
37
 
38
38
  export default function QualityControl() {
39
39
  const { qualityControl, actions, loading } = use(QxContext);
40
- const canUpdateDomain = _.includes("update_main")(actions);
40
+ const canUpdateDomain = _.includes("update_domain")(actions);
41
41
  return (
42
42
  <>
43
43
  {loading ? (
@@ -117,6 +117,7 @@ export default function QualityControlActions() {
117
117
  _.includes(action, [
118
118
  "delete_score",
119
119
  "update_main",
120
+ "update_domain",
120
121
  "execute",
121
122
  "link_to_business_concept",
122
123
  "link_to_data_structure",
@@ -5,14 +5,14 @@ import { useForm, Controller } from "react-hook-form";
5
5
  import { useIntl } from "react-intl";
6
6
  import { DomainSelector } from "@truedat/core/components";
7
7
  import QxContext from "../QxContext";
8
- import { useQualityControlUpdateMain } from "../../hooks/useQualityControls";
8
+ import { useQualityControlUpdateDomain } from "../../hooks/useQualityControls";
9
9
 
10
10
  export default function QualityControlManageDomain({ handleOpen }) {
11
11
  const { formatMessage } = useIntl();
12
12
  const { qualityControl, mutate } = use(QxContext);
13
13
 
14
- const { trigger: updateMainQualityControl, isMutating: isMutatingMain } =
15
- useQualityControlUpdateMain(qualityControl.id);
14
+ const { trigger: updateDomainQualityControl, isMutating: isMutatingMain } =
15
+ useQualityControlUpdateDomain(qualityControl.id);
16
16
 
17
17
  const domainIds = qualityControl.domain_ids;
18
18
  const [loading, setLoading] = useState(true);
@@ -24,7 +24,7 @@ export default function QualityControlManageDomain({ handleOpen }) {
24
24
  const { isDirty, isValid } = formState;
25
25
 
26
26
  const onSubmit = ({ domainIds }) => {
27
- updateMainQualityControl({
27
+ updateDomainQualityControl({
28
28
  quality_control: { domain_ids: domainIds },
29
29
  }).then(() => {
30
30
  handleOpen(false);
@@ -45,7 +45,7 @@ describe("<QualityControl />", () => {
45
45
  it("matches the latest snapshot", async () => {
46
46
  const context = {
47
47
  qualityControl: qualityControlData(),
48
- actions: ["update_main"],
48
+ actions: ["update_main", "update_domain"],
49
49
  };
50
50
  const rendered = render(
51
51
  <TestFormWrapper context={context}>
@@ -74,7 +74,7 @@ describe("<QualityControl />", () => {
74
74
  it("render popup when edit domain", async () => {
75
75
  const context = {
76
76
  qualityControl: qualityControlData(),
77
- actions: ["update_main"],
77
+ actions: ["update_main", "update_domain"],
78
78
  };
79
79
  const rendered = render(
80
80
  <TestFormWrapper context={context}>
@@ -1,10 +1,10 @@
1
1
  import { render } from "@truedat/test/render";
2
2
  import { waitFor } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
3
4
  import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
4
5
  import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
5
- import userEvent from "@testing-library/user-event";
6
6
  import { DOMAINS_QUERY } from "@truedat/core/api/queries";
7
- import { useQualityControlUpdateMain } from "@truedat/qx/hooks/useQualityControls";
7
+ import { useQualityControlUpdateDomain } from "@truedat/qx/hooks/useQualityControls";
8
8
  import QualityControlManageDomain from "../QualityControlManageDomain";
9
9
  import { qualityControlData } from "./__fixtures__/qualityControlHelper";
10
10
 
@@ -14,7 +14,7 @@ jest.mock("@truedat/qx/hooks/useQualityControls", () => {
14
14
  );
15
15
 
16
16
  return {
17
- useQualityControlUpdateMain: jest.fn(() => ({
17
+ useQualityControlUpdateDomain: jest.fn(() => ({
18
18
  trigger: jest.fn(() => Promise.resolve()),
19
19
  data: qualityControlData(),
20
20
  isMutating: false,
@@ -77,13 +77,14 @@ describe("<QualityControlManageDomain />", () => {
77
77
  expect(container).toMatchSnapshot();
78
78
  });
79
79
 
80
- it("calls updateMain when update button is clicked", async () => {
80
+ it("calls updateDomain when update button is clicked", async () => {
81
81
  const trigger = jest.fn(() =>
82
82
  Promise.resolve({ data: { data: { id: "9" } } })
83
83
  );
84
- useQualityControlUpdateMain.mockImplementation(() => ({
84
+ useQualityControlUpdateDomain.mockImplementation(() => ({
85
85
  trigger,
86
86
  }));
87
+ const user = userEvent.setup({ delay: null });
87
88
 
88
89
  const { container, queryByText, getByRole, getByText } = render(
89
90
  <TestFormWrapper context={context}>
@@ -98,14 +99,14 @@ describe("<QualityControlManageDomain />", () => {
98
99
 
99
100
  expect(getByRole("button", { name: "Update" })).toBeDisabled();
100
101
 
101
- userEvent.click(getByRole("listbox"));
102
- userEvent.click(getByRole("option", { name: "fooDomain" }));
102
+ await user.click(getByRole("listbox"));
103
+ await user.click(getByRole("option", { name: "fooDomain" }));
103
104
 
104
105
  await waitFor(() => {
105
106
  expect(getByRole("button", { name: "Update" })).toBeEnabled();
106
107
  });
107
108
 
108
- userEvent.click(getByText("Update"));
109
+ await user.click(getByText(/update/i));
109
110
 
110
111
  await waitFor(() => expect(trigger).toHaveBeenCalledTimes(1));
111
112
  await waitFor(() => expect(handleOpen).toHaveBeenCalledTimes(1));
@@ -30,10 +30,10 @@ const getDomainNames = (path) => (event) =>
30
30
  const getPayloadFromDomainChange = (event) => {
31
31
  if (_.has("payload.changes.domains")(event)) {
32
32
  const changedDomainNames = _.join(", ")(
33
- getDomainNames("payload.changes.domains")(event)
33
+ getDomainNames("payload.changes.domains")(event),
34
34
  );
35
35
  const currentDomainNames = _.join(", ")(
36
- getDomainNames("payload.current_domains")(event)
36
+ getDomainNames("payload.current_domains")(event),
37
37
  );
38
38
  return [
39
39
  [
@@ -88,7 +88,7 @@ const getPayloadFromScoreCriteriaChange = (event) => {
88
88
  b: bold,
89
89
  },
90
90
  ];
91
- })
91
+ }),
92
92
  )(event?.payload?.changes?.score_criteria);
93
93
  }
94
94
  return [];
@@ -120,7 +120,7 @@ const getPayloadFromDynamicContentChange = (event) => {
120
120
  _.map(([field, value]) => [
121
121
  { id: "quality_controls.events.action_dynamic_field_changed" },
122
122
  { field, value: normalizeValue(value?.value), b: bold },
123
- ])
123
+ ]),
124
124
  )(content);
125
125
  }
126
126
  return [];
@@ -150,7 +150,7 @@ const getPayloadFromRegularFields = (event) => {
150
150
  _.map(([field, value]) => [
151
151
  { id: "quality_controls.events.action_field_changed" },
152
152
  { field, value: normalizeValue(value), b: bold },
153
- ])
153
+ ]),
154
154
  )(event?.payload?.changes);
155
155
  }
156
156
  return [];
@@ -12,6 +12,7 @@ import {
12
12
  API_QUALITY_CONTROL_DRAFT,
13
13
  API_QUALITY_CONTROL_STATUS,
14
14
  API_QUALITY_CONTROL_MAIN,
15
+ API_QUALITY_CONTROL_DOMAIN,
15
16
  API_QUALITY_CONTROL_SEARCH,
16
17
  API_QUALITY_CONTROL_FILTERS,
17
18
  API_QUALITY_CONTROL_QUERIES,
@@ -53,6 +54,11 @@ export const useQualityControlUpdateMain = (id) => {
53
54
  return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
54
55
  };
55
56
 
57
+ export const useQualityControlUpdateDomain = (id) => {
58
+ const url = compile(API_QUALITY_CONTROL_DOMAIN)({ id: `${id}` });
59
+ return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
60
+ };
61
+
56
62
  export const useQualityControlDelete = (qualityControl) => {
57
63
  const id = qualityControl?.id || 0;
58
64
  const version = qualityControl?.version || 0;