@truedat/audit 7.5.7 → 7.5.10

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.
Files changed (65) hide show
  1. package/package.json +45 -71
  2. package/src/components/ContentFilters.js +3 -1
  3. package/src/components/NotificationEvent.js +2 -2
  4. package/src/components/NotificationsMenu.js +2 -10
  5. package/src/components/ShareLinkForm.js +33 -32
  6. package/src/components/ShareLinkPopup.js +1 -1
  7. package/src/components/Subscription.js +0 -1
  8. package/src/components/SubscriptionActions.js +1 -2
  9. package/src/components/SubscriptionCrumbs.js +2 -3
  10. package/src/components/SubscriptionEdit.js +0 -1
  11. package/src/components/SubscriptionForm.js +305 -310
  12. package/src/components/SubscriptionLoader.js +2 -2
  13. package/src/components/SubscriptionNew.js +0 -1
  14. package/src/components/SubscriptionRoutes.js +58 -56
  15. package/src/components/SubscriptionWatchForm.js +0 -1
  16. package/src/components/Subscriptions.js +4 -7
  17. package/src/components/SubscriptionsLoader.js +1 -1
  18. package/src/components/__tests__/NotificationEvent.spec.js +1 -4
  19. package/src/components/__tests__/NotificationsMenu.spec.js +0 -1
  20. package/src/components/__tests__/ShareLinkForm.spec.js +23 -17
  21. package/src/components/__tests__/ShareLinkPopup.spec.js +0 -1
  22. package/src/components/__tests__/Subscription.spec.js +0 -1
  23. package/src/components/__tests__/SubscriptionActions.spec.js +0 -1
  24. package/src/components/__tests__/SubscriptionCrumbs.spec.js +5 -5
  25. package/src/components/__tests__/SubscriptionEdit.spec.js +9 -8
  26. package/src/components/__tests__/SubscriptionForm.spec.js +141 -125
  27. package/src/components/__tests__/SubscriptionLoader.spec.js +0 -1
  28. package/src/components/__tests__/SubscriptionNew.spec.js +5 -5
  29. package/src/components/__tests__/SubscriptionRoutes.spec.js +44 -6
  30. package/src/components/__tests__/SubscriptionWatchForm.spec.js +37 -34
  31. package/src/components/__tests__/Subscriptions.spec.js +0 -1
  32. package/src/components/__tests__/SubscriptionsLoader.spec.js +0 -1
  33. package/src/components/__tests__/__snapshots__/NotificationEvent.spec.js.snap +6 -6
  34. package/src/components/__tests__/__snapshots__/NotificationsMenu.spec.js.snap +7 -7
  35. package/src/components/__tests__/__snapshots__/ShareLinkForm.spec.js.snap +6 -6
  36. package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +4 -5
  37. package/src/components/__tests__/__snapshots__/SubscriptionActions.spec.js.snap +0 -1
  38. package/src/components/__tests__/__snapshots__/SubscriptionCrumbs.spec.js.snap +20 -30
  39. package/src/components/__tests__/__snapshots__/SubscriptionEdit.spec.js.snap +75 -25
  40. package/src/components/__tests__/__snapshots__/SubscriptionForm.spec.js.snap +23 -23
  41. package/src/components/__tests__/__snapshots__/SubscriptionNew.spec.js.snap +64 -25
  42. package/src/components/__tests__/__snapshots__/SubscriptionRoutes.spec.js.snap +710 -23
  43. package/src/components/__tests__/__snapshots__/SubscriptionWatchForm.spec.js.snap +83 -80
  44. package/src/components/__tests__/__snapshots__/Subscriptions.spec.js.snap +28 -37
  45. package/src/index.js +1 -2
  46. package/src/reducers/__tests__/auditMessage.spec.js +3 -3
  47. package/src/reducers/__tests__/auditRedirect.spec.js +2 -2
  48. package/src/reducers/__tests__/events.spec.js +1 -1
  49. package/src/reducers/__tests__/searchSubscription.spec.js +5 -5
  50. package/src/reducers/__tests__/subscription.spec.js +1 -1
  51. package/src/reducers/__tests__/subscriptionUpdating.spec.js +6 -6
  52. package/src/reducers/__tests__/subscriptions.spec.js +1 -1
  53. package/src/reducers/auditMessage.js +1 -1
  54. package/src/reducers/events.js +1 -1
  55. package/src/sagas/__tests__/deleteSubscription.spec.js +7 -7
  56. package/src/sagas/__tests__/fetchSubscription.spec.js +2 -2
  57. package/src/sagas/__tests__/readNotification.spec.js +2 -2
  58. package/src/sagas/__tests__/updateSubscription.spec.js +8 -8
  59. package/src/sagas/createSubscription.js +3 -3
  60. package/src/sagas/deleteSubscription.js +1 -1
  61. package/src/sagas/readNotification.js +1 -1
  62. package/src/sagas/updateSubscription.js +4 -4
  63. package/src/selectors/__tests__/getRecipients.spec.js +0 -32
  64. package/src/selectors/getRecipients.js +0 -34
  65. package/src/selectors/index.js +0 -1
@@ -1,7 +1,7 @@
1
- import React, { useEffect } from "react";
1
+ import { useEffect } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { connect } from "react-redux";
4
- import { useParams } from "react-router-dom";
4
+ import { useParams } from "react-router";
5
5
  import { Dimmer, Loader } from "semantic-ui-react";
6
6
  import { clearSubscription, fetchSubscription } from "../routines";
7
7
 
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
2
  import { useIntl } from "react-intl";
4
3
  import { connect } from "react-redux";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Route, Switch } from "react-router-dom";
2
+ import { Route, Routes } from "react-router";
3
3
  import {
4
4
  SUBSCRIPTION,
5
5
  SUBSCRIPTIONS,
@@ -13,68 +13,70 @@ import SubscriptionEdit from "./SubscriptionEdit";
13
13
  import SubscriptionLoader from "./SubscriptionLoader";
14
14
  import SubscriptionsLoader from "./SubscriptionsLoader";
15
15
 
16
- const UsersLoader = React.lazy(() =>
17
- import("@truedat/auth/users/components/UsersLoader")
16
+ const UsersLoader = React.lazy(
17
+ () => import("@truedat/auth/users/components/UsersLoader")
18
18
  );
19
19
 
20
- const RolesLoader = React.lazy(() =>
21
- import("@truedat/auth/roles/components/RolesLoader")
20
+ const RolesLoader = React.lazy(
21
+ () => import("@truedat/auth/roles/components/RolesLoader")
22
22
  );
23
23
 
24
- const TemplatesLoader = React.lazy(() =>
25
- import("@truedat/df/templates/components/TemplatesLoader")
24
+ const TemplatesLoader = React.lazy(
25
+ () => import("@truedat/core/components/TemplatesLoader")
26
26
  );
27
27
 
28
28
  export const SubscriptionRoutes = () => (
29
- <Switch>
30
- <Route
31
- exact
32
- path={SUBSCRIPTIONS}
33
- render={() => (
34
- <>
35
- <UsersLoader />
36
- <SubscriptionsLoader />
37
- <Subscriptions />
38
- </>
39
- )}
40
- />
41
- <Route
42
- exact
43
- path={SUBSCRIPTION_NEW}
44
- render={() => (
45
- <>
46
- <TemplatesLoader scope="bg" />
47
- <UsersLoader />
48
- <RolesLoader />
49
- <SubscriptionNew />
50
- </>
51
- )}
52
- />
53
- <Route
54
- exact
55
- path={SUBSCRIPTION_EDIT}
56
- render={() => (
57
- <>
58
- <TemplatesLoader scope="bg" />
59
- <UsersLoader />
60
- <SubscriptionLoader />
61
- <SubscriptionEdit />
62
- </>
63
- )}
64
- />
65
- <Route
66
- exact
67
- path={SUBSCRIPTION}
68
- render={() => (
69
- <>
70
- <TemplatesLoader scope="bg" />
71
- <UsersLoader />
72
- <SubscriptionLoader />
73
- <Subscription />
74
- </>
75
- )}
76
- />
77
- </Switch>
29
+ <Routes>
30
+ <Route path="subscriptions">
31
+ <Route
32
+ index
33
+ element={
34
+ <>
35
+ <UsersLoader />
36
+ <SubscriptionsLoader />
37
+ <Subscriptions />
38
+ </>
39
+ }
40
+ />
41
+ <Route
42
+ path="new"
43
+ element={
44
+ <>
45
+ <TemplatesLoader scope="bg" />
46
+ <UsersLoader />
47
+ <RolesLoader />
48
+ <SubscriptionNew />
49
+ </>
50
+ }
51
+ />
52
+ <Route path=":id">
53
+ <Route
54
+ index
55
+ element={
56
+ <>
57
+ <TemplatesLoader scope="bg" />
58
+ <UsersLoader />
59
+ <SubscriptionLoader />
60
+ <Subscription />
61
+ </>
62
+ }
63
+ />
64
+ <Route
65
+ path="edit"
66
+ element={
67
+ <>
68
+ <TemplatesLoader scope="bg" />
69
+ <UsersLoader />
70
+ <SubscriptionLoader />
71
+ <SubscriptionEdit />
72
+ </>
73
+ }
74
+ />
75
+ </Route>
76
+ </Route>
77
+
78
+ <Route path="*" element={null} />
79
+ </Routes>
78
80
  );
79
81
 
80
82
  export default SubscriptionRoutes;
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import { Form, Radio, Button, Icon } from "semantic-ui-react";
4
3
  import { FormattedMessage } from "react-intl";
5
4
  import PropTypes from "prop-types";
@@ -1,9 +1,9 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { connect } from "react-redux";
5
4
  import { useForm, Controller } from "react-hook-form";
6
- import { useHistory, Link } from "react-router-dom";
5
+ import { Link } from "react-router";
6
+ import { useNavigate } from "react-router";
7
7
  import { FormattedMessage, useIntl } from "react-intl";
8
8
  import { SUBSCRIPTION_NEW, linkTo } from "@truedat/core/routes";
9
9
  import {
@@ -65,7 +65,7 @@ export const Subscriptions = ({
65
65
  subscriptionsLoading: loading,
66
66
  users,
67
67
  }) => {
68
- const history = useHistory();
68
+ const navigate = useNavigate();
69
69
  const { control, watch } = useForm({
70
70
  mode: "all",
71
71
  defaultValues: {
@@ -99,7 +99,6 @@ export const Subscriptions = ({
99
99
  return (
100
100
  <Segment>
101
101
  <SubscriptionsHeader />
102
-
103
102
  <Form>
104
103
  <Header
105
104
  as="h5"
@@ -174,14 +173,12 @@ export const Subscriptions = ({
174
173
  )}
175
174
  />
176
175
  </Form>
177
-
178
176
  <Label className="rules-label-results">
179
177
  <FormattedMessage
180
178
  id="subscriptions.retrieved.results"
181
179
  values={{ count: orderedSubscriptions.length }}
182
180
  />
183
181
  </Label>
184
-
185
182
  <Table className="subscription-table" selectable>
186
183
  <Table.Header>
187
184
  <Table.Row>
@@ -201,7 +198,7 @@ export const Subscriptions = ({
201
198
  ({ periodicity, scope, subscriber, resource, id }, key) => (
202
199
  <Table.Row
203
200
  key={key}
204
- onClick={() => history.push(linkTo.SUBSCRIPTION({ id }))}
201
+ onClick={() => navigate(linkTo.SUBSCRIPTION({ id }))}
205
202
  >
206
203
  <Table.Cell>
207
204
  <Icon name={subscriberIcon(subscriber)} />
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import { useEffect } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { connect } from "react-redux";
4
4
  import { Dimmer, Loader } from "semantic-ui-react";
@@ -1,11 +1,8 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import NotificationEvent from "../NotificationEvent";
4
3
 
5
4
  jest.mock("@truedat/core/hooks", () => ({ useOnScreen: jest.fn() }));
6
- jest
7
- .spyOn(global.Date, "now")
8
- .mockImplementation(() => new Date("2022-01-01T11:01:58.135Z").valueOf());
5
+
9
6
  describe("<NotificationEvent />", () => {
10
7
  it("matches the latest snapshot", () => {
11
8
  const event = {
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import { NotificationsMenu } from "../NotificationsMenu";
4
3
 
@@ -1,7 +1,6 @@
1
- import React from "react";
2
- import { waitFor } from "@testing-library/react";
3
1
  import userEvent from "@testing-library/user-event";
4
- import { render } from "@truedat/test/render";
2
+ import { waitFor } from "@testing-library/react";
3
+ import { render, waitForLoad } from "@truedat/test/render";
5
4
  import { ShareLinkForm } from "../ShareLinkForm";
6
5
 
7
6
  describe("<ShareLinkForm />", () => {
@@ -33,32 +32,39 @@ describe("<ShareLinkForm />", () => {
33
32
  options,
34
33
  };
35
34
 
36
- it("matches the latest snapshot", () => {
37
- const { container } = render(<ShareLinkForm {...props} />);
38
- expect(container).toMatchSnapshot();
35
+ it("matches the latest snapshot", async () => {
36
+ const rendered = render(<ShareLinkForm {...props} />);
37
+ await waitForLoad(rendered);
38
+ expect(rendered.container).toMatchSnapshot();
39
39
  });
40
40
 
41
41
  it("enables send button when selecting recipient", async () => {
42
- const { findByText, queryByRole } = render(<ShareLinkForm {...props} />);
42
+ const rendered = render(<ShareLinkForm {...props} />);
43
+ await waitForLoad(rendered);
43
44
 
44
- expect(queryByRole("button", { name: /Share/ })).toBeDisabled();
45
- userEvent.click(await findByText(/john/));
45
+ const user = userEvent.setup({ delay: null });
46
+ expect(rendered.queryByRole("button", { name: /share/i })).toBeDisabled();
47
+ await user.click(await rendered.findByText(/john/i));
46
48
  await waitFor(() => {
47
- expect(queryByRole("button", { name: /Share/ })).not.toBeDisabled();
49
+ expect(
50
+ rendered.queryByRole("button", { name: /share/i })
51
+ ).not.toBeDisabled();
48
52
  });
49
53
  });
50
54
 
51
55
  it("invokes function when send button clicked", async () => {
52
- const { findByRole, findByText, queryByRole } = render(
53
- <ShareLinkForm {...props} />
54
- );
56
+ const rendered = render(<ShareLinkForm {...props} />);
57
+ await waitForLoad(rendered);
55
58
 
56
- expect(queryByRole("button", { name: /Share/ })).toBeDisabled();
57
- userEvent.click(await findByText(/john/));
59
+ const user = userEvent.setup({ delay: null });
60
+ expect(rendered.queryByRole("button", { name: /share/i })).toBeDisabled();
61
+ await user.click(await rendered.findByText(/john/i));
58
62
  await waitFor(() => {
59
- expect(queryByRole("button", { name: /Share/ })).not.toBeDisabled();
63
+ expect(
64
+ rendered.queryByRole("button", { name: /share/i })
65
+ ).not.toBeDisabled();
60
66
  });
61
- userEvent.click(await findByRole("button", { name: /Share/ }));
67
+ await user.click(await rendered.findByRole("button", { name: /share/i }));
62
68
  await waitFor(() => {
63
69
  expect(createNotification.mock.calls.length).toBe(1);
64
70
  });
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import { ShareLinkPopup } from "../ShareLinkPopup";
4
3
 
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import Subscription, { SubscriptionHeader } from "../Subscription";
4
3
 
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import { SubscriptionActions, ModalDelete } from "../SubscriptionActions";
4
3
 
@@ -1,10 +1,10 @@
1
- import React from "react";
2
- import { shallow } from "enzyme";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import SubscriptionCrumbs from "../SubscriptionCrumbs";
4
3
 
5
4
  describe("<SubscriptionCrumbs />", () => {
6
- it("matches the latest snapshot", () => {
7
- const wrapper = shallow(<SubscriptionCrumbs title="CrumbTitle" />);
8
- expect(wrapper).toMatchSnapshot();
5
+ it("matches the latest snapshot", async () => {
6
+ const rendered = render(<SubscriptionCrumbs title="CrumbTitle" />);
7
+ await waitForLoad(rendered);
8
+ expect(rendered.container).toMatchSnapshot();
9
9
  });
10
10
  });
@@ -1,20 +1,21 @@
1
- import React from "react";
2
- import { render } from "@truedat/test/render";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import SubscriptionEdit from "../SubscriptionEdit";
4
3
 
5
4
  const renderOpts = {
6
5
  state: {
7
- creatingSubscription: false,
6
+ subscriptionLoading: false,
8
7
  subscription: {
9
- subscriber: { type: "user" },
8
+ subscriber: { type: "user", identifier: "1" },
9
+ resource: { name: "foo" },
10
10
  },
11
- templates: [],
11
+ users: [{ id: 1, full_name: "John Doe" }],
12
12
  },
13
13
  };
14
14
 
15
15
  describe("<SubscriptionEdit />", () => {
16
- it("matches the latest snapshot", () => {
17
- const { container } = render(<SubscriptionEdit />, renderOpts);
18
- expect(container).toMatchSnapshot();
16
+ it("matches the latest snapshot", async () => {
17
+ const rendered = render(<SubscriptionEdit />, renderOpts);
18
+ await waitForLoad(rendered);
19
+ expect(rendered.container).toMatchSnapshot();
19
20
  });
20
21
  });