@truedat/audit 4.51.2 → 4.51.4

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/CHANGELOG.md CHANGED
@@ -1,10 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.51.3] 2022-09-16
4
+
5
+ ### Changed
6
+
7
+ - [TD-4794] Use `DomainSelector` in `SubscriptionForm`
8
+
3
9
  ## [4.49.8] 2022-08-11
4
10
 
5
11
  ### Added
6
12
 
7
- - [TD-5035] Get external notification body from envent payload
13
+ - [TD-5035] Get external notification body from event payload
8
14
 
9
15
  ## [4.48.11] 2022-21-07
10
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/audit",
3
- "version": "4.51.2",
3
+ "version": "4.51.4",
4
4
  "description": "Truedat Web Audit Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.47.9",
37
+ "@truedat/test": "4.51.4",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -85,8 +85,8 @@
85
85
  ]
86
86
  },
87
87
  "dependencies": {
88
- "@truedat/auth": "4.51.2",
89
- "@truedat/core": "4.51.2",
88
+ "@truedat/auth": "4.51.4",
89
+ "@truedat/core": "4.51.4",
90
90
  "path-to-regexp": "^1.7.0",
91
91
  "prop-types": "^15.8.1",
92
92
  "react-color": "^2.17.3",
@@ -106,5 +106,5 @@
106
106
  "react-dom": ">= 16.8.6 < 17",
107
107
  "semantic-ui-react": ">= 0.88.2 < 2.1"
108
108
  },
109
- "gitHead": "9bdc76f3ee59a6e28fb2312e26d0cba2807f069b"
109
+ "gitHead": "d3e3af905c2330f5e4aaeeefc3549acaa19575f7"
110
110
  }
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
4
4
  import { useIntl, FormattedMessage } from "react-intl";
5
5
  import { useForm, useWatch, Controller } from "react-hook-form";
6
6
  import { Button, Form, Radio, Icon } from "semantic-ui-react";
7
- import { HistoryBackButton } from "@truedat/core/components";
7
+ import { DomainSelector, HistoryBackButton } from "@truedat/core/components";
8
8
  import {
9
9
  CONCEPT_EVENTS,
10
10
  DEFAULT_ICON,
@@ -20,10 +20,6 @@ const ConceptSelector = React.lazy(() =>
20
20
  import("@truedat/bg/concepts/relations/components/ConceptSelector")
21
21
  );
22
22
 
23
- const DomainDropdownSelector = React.lazy(() =>
24
- import("@truedat/bg/taxonomy/components/DomainDropdownSelector")
25
- );
26
-
27
23
  const UserSelector = React.lazy(() =>
28
24
  import("@truedat/auth/users/components/UserSelector")
29
25
  );
@@ -338,11 +334,14 @@ export const SubscriptionForm = ({
338
334
  name="scope.resource_id"
339
335
  rules={{ required: true }}
340
336
  render={({ field: { onChange, value } }) => (
341
- <DomainDropdownSelector
337
+ <DomainSelector
338
+ action="manageSubscriptions"
342
339
  disabled={isEditForm}
340
+ label={formatMessage({ id: "domain.selector.label" })}
341
+ required
342
+ labels
343
343
  value={value}
344
344
  onChange={(_e, { value }) => onChange(value)}
345
- hideLabel
346
345
  />
347
346
  )}
348
347
  />
@@ -4,7 +4,7 @@ import {
4
4
  SUBSCRIPTION,
5
5
  SUBSCRIPTIONS,
6
6
  SUBSCRIPTION_NEW,
7
- SUBSCRIPTION_EDIT
7
+ SUBSCRIPTION_EDIT,
8
8
  } from "@truedat/core/routes";
9
9
  import Subscription from "./Subscription";
10
10
  import Subscriptions from "./Subscriptions";
@@ -21,10 +21,6 @@ const RolesLoader = React.lazy(() =>
21
21
  import("@truedat/auth/roles/components/RolesLoader")
22
22
  );
23
23
 
24
- const DomainsLoader = React.lazy(() =>
25
- import("@truedat/bg/taxonomy/components/DomainsLoader")
26
- );
27
-
28
24
  const TemplatesLoader = React.lazy(() =>
29
25
  import("@truedat/df/templates/components/TemplatesLoader")
30
26
  );
@@ -50,7 +46,6 @@ export const SubscriptionRoutes = () => (
50
46
  <TemplatesLoader scope="bg" />
51
47
  <UsersLoader />
52
48
  <RolesLoader />
53
- <DomainsLoader />
54
49
  <SubscriptionNew />
55
50
  </>
56
51
  )}
@@ -61,7 +56,6 @@ export const SubscriptionRoutes = () => (
61
56
  render={() => (
62
57
  <>
63
58
  <TemplatesLoader scope="bg" />
64
- <DomainsLoader />
65
59
  <UsersLoader />
66
60
  <SubscriptionLoader />
67
61
  <SubscriptionEdit />
@@ -2,14 +2,11 @@ import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
4
  import userEvent from "@testing-library/user-event";
5
+ import { domainsMock } from "@truedat/test/mocks";
5
6
  import SubscriptionForm from "../SubscriptionForm";
6
7
 
7
8
  const conceptActiveFilters = {};
8
9
  const structureActiveFilters = {};
9
- const domains = [
10
- { name: "domain1", id: 11 },
11
- { name: "domain2", id: 22 },
12
- ];
13
10
  const roles = [{ name: "role1" }, { name: "role2" }];
14
11
  const templates = [
15
12
  {
@@ -39,11 +36,13 @@ const state = {
39
36
  roles,
40
37
  templates,
41
38
  users,
42
- domains,
43
39
  conceptActiveFilters,
44
40
  structureActiveFilters,
45
41
  };
46
- const renderOpts = { state };
42
+
43
+ const variables = { action: "manageSubscriptions" };
44
+ const mocks = [domainsMock(variables), domainsMock(variables)];
45
+ const renderOpts = { state, mocks };
47
46
 
48
47
  describe("<SubscriptionForm />", () => {
49
48
  it("matches the latest snapshot", async () => {
@@ -66,26 +65,26 @@ describe("<SubscriptionForm />", () => {
66
65
  // Select role
67
66
  userEvent.click(await findByText("Role"));
68
67
  await waitFor(() => {
69
- expect(queryByText(/Search Roles/)).toBeTruthy();
68
+ expect(queryByText(/Search Roles/)).toBeInTheDocument();
70
69
  });
71
70
  userEvent.click(await findByText("role2"));
72
71
 
73
72
  // Select email
74
73
  userEvent.click(await findByText("Email"));
75
74
  await waitFor(() => {
76
- expect(queryByTestId("email-input")).toBeTruthy();
75
+ expect(queryByTestId("email-input")).toBeInTheDocument();
77
76
  });
78
77
  userEvent.type(queryByTestId("email-input"), "foo");
79
78
 
80
79
  // Select concept and taxonomy_role
81
80
  userEvent.click(await findByText("Concept"));
82
81
  await waitFor(() => {
83
- expect(queryByText("No concepts found")).toBeTruthy();
82
+ expect(queryByText("No concepts found")).toBeInTheDocument();
84
83
  });
85
84
 
86
85
  userEvent.click(await findByText("Role in taxonomy"));
87
86
  await waitFor(() => {
88
- expect(queryByText(/Search Roles/)).toBeTruthy();
87
+ expect(queryByText(/Search Roles/)).toBeInTheDocument();
89
88
  });
90
89
  await waitFor(() => {
91
90
  expect(queryByText("No concepts found")).toBeFalsy();
@@ -95,14 +94,14 @@ describe("<SubscriptionForm />", () => {
95
94
  // Select user
96
95
  userEvent.click(await findByText("User"));
97
96
  await waitFor(() => {
98
- expect(queryByText(/Search users/)).toBeTruthy();
97
+ expect(queryByText(/Search users/)).toBeInTheDocument();
99
98
  });
100
99
  userEvent.click(await findByText("user2"));
101
100
 
102
101
  // Test concepts
103
102
  userEvent.click(await findByText("Concept"));
104
103
  await waitFor(() => {
105
- expect(queryByText("No concepts found")).toBeTruthy();
104
+ expect(queryByText("No concepts found")).toBeInTheDocument();
106
105
  });
107
106
 
108
107
  // Test structures
@@ -110,16 +109,16 @@ describe("<SubscriptionForm />", () => {
110
109
  await waitFor(() => {
111
110
  expect(
112
111
  queryByText("No structures have been found matching these filters.")
113
- ).toBeTruthy();
112
+ ).toBeInTheDocument();
114
113
  });
115
114
 
116
115
  // Select domains
117
116
  userEvent.click(await findByText("Domain and children"));
118
117
  await waitFor(() => {
119
- expect(queryByText(/Select a domain/)).toBeTruthy();
118
+ expect(queryByText(/Select a domain/)).toBeInTheDocument();
120
119
  });
121
120
 
122
- userEvent.click(await findByText("domain1"));
121
+ userEvent.click(await findByText("fooDomain"));
123
122
  userEvent.click(await findByText("Daily"));
124
123
  userEvent.click(await findByText("Rule result created"));
125
124
  userEvent.click(await findByText("Goal"));
@@ -139,7 +138,7 @@ describe("<SubscriptionForm />", () => {
139
138
  scope: {
140
139
  resource_type: "domains",
141
140
  events: ["rule_result_created"],
142
- resource_id: 11,
141
+ resource_id: "1",
143
142
  status: ["success"],
144
143
  filters: null,
145
144
  },
@@ -152,7 +151,7 @@ describe("<SubscriptionForm />", () => {
152
151
  const onSubmit = jest.fn();
153
152
  const props = { onSubmit };
154
153
 
155
- const { getByRole, findByText, queryByTestId, queryByText } = render(
154
+ const { getByRole, findByText, queryByText } = render(
156
155
  <SubscriptionForm {...props} />,
157
156
  renderOpts
158
157
  );
@@ -161,41 +160,20 @@ describe("<SubscriptionForm />", () => {
161
160
  expect(getByRole("button", { name: "Save" })).toBeDisabled();
162
161
  });
163
162
 
164
- // Select role
165
- userEvent.click(await findByText("Role"));
166
- await waitFor(() => {
167
- expect(queryByText(/Search Roles/)).toBeTruthy();
168
- });
169
- userEvent.click(await findByText("role2"));
170
-
171
- // Select email
172
- userEvent.click(await findByText("Email"));
173
- await waitFor(() => {
174
- expect(queryByTestId("email-input")).toBeTruthy();
175
- });
176
- userEvent.type(queryByTestId("email-input"), "foo");
177
-
178
163
  // Select user
179
164
  userEvent.click(await findByText("User"));
180
165
  await waitFor(() => {
181
- expect(queryByText(/Search users/)).toBeTruthy();
166
+ expect(queryByText(/Search users/)).toBeInTheDocument();
182
167
  });
183
168
  userEvent.click(await findByText("user2"));
184
169
 
185
- // Test concepts
186
- userEvent.click(await findByText("Concept"));
187
- await waitFor(() => {
188
- expect(queryByText("No concepts found")).toBeTruthy();
189
- });
190
-
191
170
  // Select domains
192
171
  userEvent.click(await findByText("Domain and children"));
193
172
  await waitFor(() => {
194
- expect(queryByText(/Select a domain/)).toBeTruthy();
173
+ expect(queryByText(/Select a domain/)).toBeInTheDocument();
195
174
  });
196
175
 
197
- userEvent.click(await findByText("domain1"));
198
-
176
+ userEvent.click(await findByText("fooDomain"));
199
177
  userEvent.click(await findByText("Daily"));
200
178
  userEvent.click(await findByText("Comment created"));
201
179
  userEvent.click(await queryByText("Filters to subscription"));
@@ -218,7 +196,7 @@ describe("<SubscriptionForm />", () => {
218
196
  scope: {
219
197
  resource_type: "domains",
220
198
  events: ["comment_created"],
221
- resource_id: 11,
199
+ resource_id: "1",
222
200
  status: [],
223
201
  filters: {
224
202
  template: { id: 1 },