@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.
- package/package.json +45 -71
- package/src/components/ContentFilters.js +3 -1
- package/src/components/NotificationEvent.js +2 -2
- package/src/components/NotificationsMenu.js +2 -10
- package/src/components/ShareLinkForm.js +33 -32
- package/src/components/ShareLinkPopup.js +1 -1
- package/src/components/Subscription.js +0 -1
- package/src/components/SubscriptionActions.js +1 -2
- package/src/components/SubscriptionCrumbs.js +2 -3
- package/src/components/SubscriptionEdit.js +0 -1
- package/src/components/SubscriptionForm.js +305 -310
- package/src/components/SubscriptionLoader.js +2 -2
- package/src/components/SubscriptionNew.js +0 -1
- package/src/components/SubscriptionRoutes.js +58 -56
- package/src/components/SubscriptionWatchForm.js +0 -1
- package/src/components/Subscriptions.js +4 -7
- package/src/components/SubscriptionsLoader.js +1 -1
- package/src/components/__tests__/NotificationEvent.spec.js +1 -4
- package/src/components/__tests__/NotificationsMenu.spec.js +0 -1
- package/src/components/__tests__/ShareLinkForm.spec.js +23 -17
- package/src/components/__tests__/ShareLinkPopup.spec.js +0 -1
- package/src/components/__tests__/Subscription.spec.js +0 -1
- package/src/components/__tests__/SubscriptionActions.spec.js +0 -1
- package/src/components/__tests__/SubscriptionCrumbs.spec.js +5 -5
- package/src/components/__tests__/SubscriptionEdit.spec.js +9 -8
- package/src/components/__tests__/SubscriptionForm.spec.js +141 -125
- package/src/components/__tests__/SubscriptionLoader.spec.js +0 -1
- package/src/components/__tests__/SubscriptionNew.spec.js +5 -5
- package/src/components/__tests__/SubscriptionRoutes.spec.js +44 -6
- package/src/components/__tests__/SubscriptionWatchForm.spec.js +37 -34
- package/src/components/__tests__/Subscriptions.spec.js +0 -1
- package/src/components/__tests__/SubscriptionsLoader.spec.js +0 -1
- package/src/components/__tests__/__snapshots__/NotificationEvent.spec.js.snap +6 -6
- package/src/components/__tests__/__snapshots__/NotificationsMenu.spec.js.snap +7 -7
- package/src/components/__tests__/__snapshots__/ShareLinkForm.spec.js.snap +6 -6
- package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +4 -5
- package/src/components/__tests__/__snapshots__/SubscriptionActions.spec.js.snap +0 -1
- package/src/components/__tests__/__snapshots__/SubscriptionCrumbs.spec.js.snap +20 -30
- package/src/components/__tests__/__snapshots__/SubscriptionEdit.spec.js.snap +75 -25
- package/src/components/__tests__/__snapshots__/SubscriptionForm.spec.js.snap +23 -23
- package/src/components/__tests__/__snapshots__/SubscriptionNew.spec.js.snap +64 -25
- package/src/components/__tests__/__snapshots__/SubscriptionRoutes.spec.js.snap +710 -23
- package/src/components/__tests__/__snapshots__/SubscriptionWatchForm.spec.js.snap +83 -80
- package/src/components/__tests__/__snapshots__/Subscriptions.spec.js.snap +28 -37
- package/src/index.js +1 -2
- package/src/reducers/__tests__/auditMessage.spec.js +3 -3
- package/src/reducers/__tests__/auditRedirect.spec.js +2 -2
- package/src/reducers/__tests__/events.spec.js +1 -1
- package/src/reducers/__tests__/searchSubscription.spec.js +5 -5
- package/src/reducers/__tests__/subscription.spec.js +1 -1
- package/src/reducers/__tests__/subscriptionUpdating.spec.js +6 -6
- package/src/reducers/__tests__/subscriptions.spec.js +1 -1
- package/src/reducers/auditMessage.js +1 -1
- package/src/reducers/events.js +1 -1
- package/src/sagas/__tests__/deleteSubscription.spec.js +7 -7
- package/src/sagas/__tests__/fetchSubscription.spec.js +2 -2
- package/src/sagas/__tests__/readNotification.spec.js +2 -2
- package/src/sagas/__tests__/updateSubscription.spec.js +8 -8
- package/src/sagas/createSubscription.js +3 -3
- package/src/sagas/deleteSubscription.js +1 -1
- package/src/sagas/readNotification.js +1 -1
- package/src/sagas/updateSubscription.js +4 -4
- package/src/selectors/__tests__/getRecipients.spec.js +0 -32
- package/src/selectors/getRecipients.js +0 -34
- package/src/selectors/index.js +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { waitFor } from "@testing-library/react";
|
|
3
|
-
import { render } from "@truedat/test/render";
|
|
4
1
|
import userEvent from "@testing-library/user-event";
|
|
2
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
5
4
|
import {
|
|
6
5
|
domainsMock,
|
|
7
6
|
mockUseStructures,
|
|
@@ -9,10 +8,10 @@ import {
|
|
|
9
8
|
} from "@truedat/test/mocks";
|
|
10
9
|
import SearchContextWrapper from "@truedat/core/components/common/SearchContextWrapper";
|
|
11
10
|
import SubscriptionForm from "../SubscriptionForm";
|
|
12
|
-
import en from "../../messages/en";
|
|
13
11
|
|
|
14
12
|
mockUseStructures();
|
|
15
13
|
mockUseConcepts();
|
|
14
|
+
jest.mock("@truedat/core/hooks/useUserFilters");
|
|
16
15
|
|
|
17
16
|
const structureActiveFilters = {};
|
|
18
17
|
const roles = [{ name: "role1" }, { name: "role2" }];
|
|
@@ -47,28 +46,9 @@ const state = {
|
|
|
47
46
|
structureActiveFilters,
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
const messages = {
|
|
51
|
-
en: {
|
|
52
|
-
...en,
|
|
53
|
-
"actions.save": "Save",
|
|
54
|
-
"actions.cancel": "Cancel",
|
|
55
|
-
"role.search.placeholder": "Search Roles...",
|
|
56
|
-
"concepts.search.results.empty": "No concepts found",
|
|
57
|
-
"user.search.placeholder": "Search users...",
|
|
58
|
-
"domain.selector.placeholder": "Select a domain...",
|
|
59
|
-
"domain.selector.label": "Domain",
|
|
60
|
-
"structures.not_found.body":
|
|
61
|
-
"No structures have been found matching these filters.",
|
|
62
|
-
"structures.not_found.header": "Nothing found...",
|
|
63
|
-
"structures.search.placeholder": "Search structures...",
|
|
64
|
-
"search.placeholder": "Search...",
|
|
65
|
-
"structures.loading.header": "Loading structures...",
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
49
|
const variables = { action: "manageSubscriptions" };
|
|
70
50
|
const mocks = [domainsMock(variables), domainsMock(variables)];
|
|
71
|
-
const renderOpts = { state, mocks
|
|
51
|
+
const renderOpts = { state, mocks };
|
|
72
52
|
const searchProps = {
|
|
73
53
|
loading: false,
|
|
74
54
|
searchParams: {},
|
|
@@ -77,99 +57,124 @@ const searchProps = {
|
|
|
77
57
|
|
|
78
58
|
describe("<SubscriptionForm />", () => {
|
|
79
59
|
it("matches the latest snapshot", async () => {
|
|
80
|
-
const
|
|
81
|
-
await
|
|
82
|
-
expect(container).toMatchSnapshot();
|
|
60
|
+
const rendered = render(<SubscriptionForm />, renderOpts);
|
|
61
|
+
await waitForLoad(rendered);
|
|
62
|
+
expect(rendered.container).toMatchSnapshot();
|
|
83
63
|
});
|
|
84
64
|
|
|
85
65
|
it("test SubscriptionForm functionality", async () => {
|
|
86
66
|
const onSubmit = jest.fn();
|
|
87
67
|
const props = { onSubmit };
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
const rendered = render(
|
|
69
|
+
<SearchContextWrapper props={searchProps}>
|
|
70
|
+
<SubscriptionForm {...props} />
|
|
71
|
+
</SearchContextWrapper>,
|
|
72
|
+
renderOpts
|
|
73
|
+
);
|
|
74
|
+
await waitForLoad(rendered);
|
|
75
|
+
|
|
76
|
+
const user = userEvent.setup({ delay: null });
|
|
77
|
+
|
|
78
|
+
expect(
|
|
79
|
+
rendered.getByRole("button", { name: "actions.save" })
|
|
80
|
+
).toBeDisabled();
|
|
98
81
|
|
|
99
82
|
// Select role
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
await user.click(rendered.getByText("role"));
|
|
84
|
+
|
|
85
|
+
await waitFor(() =>
|
|
86
|
+
expect(rendered.getByText(/role.search.placeholder/i)).toBeInTheDocument()
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
await user.click(await rendered.findByText(/role2/i));
|
|
105
90
|
|
|
106
91
|
// Select email
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
await user.click(rendered.getByText(/email/i));
|
|
93
|
+
|
|
94
|
+
await waitFor(() =>
|
|
95
|
+
expect(rendered.getByTestId("email-input")).toBeInTheDocument()
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
await user.type(rendered.getByTestId("email-input"), "foo");
|
|
112
99
|
|
|
113
100
|
// Select concept and taxonomy_role
|
|
114
|
-
|
|
115
|
-
await waitFor(() => {
|
|
116
|
-
expect(queryByText("No concepts found")).toBeInTheDocument();
|
|
117
|
-
});
|
|
101
|
+
await user.click(rendered.getByText("concept"));
|
|
118
102
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
103
|
+
await waitFor(() =>
|
|
104
|
+
expect(
|
|
105
|
+
rendered.getByText(/concepts.search.results.empty/i)
|
|
106
|
+
).toBeInTheDocument()
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
await user.click(rendered.getByText("taxonomy_role"));
|
|
110
|
+
|
|
111
|
+
await waitFor(() =>
|
|
112
|
+
expect(rendered.getByText(/role.search.placeholder/i)).toBeInTheDocument()
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Wait for concepts.search.results.empty to disappear
|
|
116
|
+
await rendered.findByText(/role2/i);
|
|
117
|
+
expect(rendered.queryByText(/concepts.search.results.empty/i)).toBeFalsy();
|
|
118
|
+
|
|
119
|
+
await user.click(await rendered.findByText(/role2/i));
|
|
127
120
|
|
|
128
121
|
// Select user
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
await user.click(rendered.getByText(/user/i));
|
|
123
|
+
|
|
124
|
+
await waitFor(() =>
|
|
125
|
+
expect(rendered.getByText(/user.search.placeholder/i)).toBeInTheDocument()
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
await user.click(await rendered.findByText(/user2/i));
|
|
134
129
|
|
|
135
130
|
// Test concepts
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
await user.click(rendered.getByText("concept"));
|
|
132
|
+
|
|
133
|
+
await waitFor(() =>
|
|
134
|
+
expect(
|
|
135
|
+
rendered.getByText(/concepts.search.results.empty/i)
|
|
136
|
+
).toBeInTheDocument()
|
|
137
|
+
);
|
|
140
138
|
|
|
141
139
|
// Test structures
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
await waitFor(() => {
|
|
140
|
+
await user.click(rendered.getByText(/structure/i));
|
|
141
|
+
|
|
142
|
+
// Wait for loading to disappear
|
|
143
|
+
await waitFor(() =>
|
|
147
144
|
expect(
|
|
148
|
-
|
|
149
|
-
).toBeInTheDocument()
|
|
150
|
-
|
|
145
|
+
rendered.getByText(/structures.not_found.body/i)
|
|
146
|
+
).toBeInTheDocument()
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
expect(rendered.container.querySelector(".loading")).toBeNull();
|
|
151
150
|
|
|
152
151
|
// Select domains
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
await user.click(rendered.getByText(/domains/i));
|
|
153
|
+
|
|
154
|
+
await waitFor(() =>
|
|
155
|
+
expect(
|
|
156
|
+
rendered.getByText(/domain.selector.placeholder/i)
|
|
157
|
+
).toBeInTheDocument()
|
|
158
|
+
);
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
userEvent.click(await findByText("Daily"));
|
|
160
|
-
userEvent.click(await findByText("Rule result created"));
|
|
161
|
-
userEvent.click(await findByText("Goal"));
|
|
160
|
+
await user.click(await rendered.findByText(/foodomain/i));
|
|
162
161
|
|
|
163
|
-
await
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
await user.click(rendered.getByText(/daily/i));
|
|
163
|
+
|
|
164
|
+
await user.click(rendered.getByText(/rule_result_created/i));
|
|
165
|
+
|
|
166
|
+
await user.click(rendered.getByText(/success/i));
|
|
167
|
+
|
|
168
|
+
// Wait for save button to be enabled
|
|
169
|
+
const saveButton = rendered.getByRole("button", { name: "actions.save" });
|
|
170
|
+
|
|
171
|
+
await waitFor(() => expect(saveButton).toBeEnabled());
|
|
166
172
|
|
|
167
173
|
// Submit
|
|
168
|
-
await
|
|
169
|
-
userEvent.click(getByRole("button", { name: "Save" }));
|
|
170
|
-
});
|
|
174
|
+
await user.click(saveButton);
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
// Check that onSubmit was called with the right arguments
|
|
177
|
+
await waitFor(() => {
|
|
173
178
|
expect(onSubmit).toHaveBeenCalledWith({
|
|
174
179
|
subscriber: { type: "user", identifier: "2" },
|
|
175
180
|
scope: {
|
|
@@ -180,54 +185,65 @@ describe("<SubscriptionForm />", () => {
|
|
|
180
185
|
filters: null,
|
|
181
186
|
},
|
|
182
187
|
periodicity: "daily",
|
|
183
|
-
})
|
|
184
|
-
);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
185
190
|
});
|
|
186
191
|
|
|
187
192
|
it("test SubscriptionForm filters functionality", async () => {
|
|
188
193
|
const onSubmit = jest.fn();
|
|
189
194
|
const props = { onSubmit };
|
|
190
195
|
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
renderOpts
|
|
194
|
-
);
|
|
196
|
+
const rendered = render(<SubscriptionForm {...props} />, renderOpts);
|
|
197
|
+
await waitForLoad(rendered);
|
|
195
198
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
const user = userEvent.setup({ delay: null });
|
|
200
|
+
|
|
201
|
+
expect(
|
|
202
|
+
rendered.getByRole("button", { name: "actions.save" })
|
|
203
|
+
).toBeDisabled();
|
|
199
204
|
|
|
200
205
|
// Select user
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
await user.click(rendered.getByText(/user/i));
|
|
207
|
+
|
|
208
|
+
await waitFor(() =>
|
|
209
|
+
expect(rendered.getByText(/user.search.placeholder/i)).toBeInTheDocument()
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
await user.click(await rendered.findByText(/user2/i));
|
|
206
213
|
|
|
207
214
|
// Select domains
|
|
208
|
-
|
|
209
|
-
await waitFor(() => {
|
|
210
|
-
expect(queryByText(/Select a domain/)).toBeInTheDocument();
|
|
211
|
-
});
|
|
215
|
+
await user.click(rendered.getByText(/domains/i));
|
|
212
216
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
userEvent.click(await findByText("Xyz"));
|
|
219
|
-
userEvent.click(await findByText("baz"));
|
|
217
|
+
await waitFor(() =>
|
|
218
|
+
expect(
|
|
219
|
+
rendered.getByText(/domain.selector.placeholder/i)
|
|
220
|
+
).toBeInTheDocument()
|
|
221
|
+
);
|
|
220
222
|
|
|
221
|
-
await
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
await user.click(await rendered.findByText(/foodomain/i));
|
|
224
|
+
|
|
225
|
+
await user.click(rendered.getByText(/daily/i));
|
|
226
|
+
|
|
227
|
+
await user.click(rendered.getByText(/comment_created/i));
|
|
228
|
+
|
|
229
|
+
await user.click(rendered.getByText(/subscriptions.selectFilters/i));
|
|
230
|
+
|
|
231
|
+
await user.click(await rendered.findByText("Foo"));
|
|
232
|
+
|
|
233
|
+
await user.click(rendered.getByText(/xyz/i));
|
|
234
|
+
|
|
235
|
+
await user.click(rendered.getByText("baz"));
|
|
236
|
+
|
|
237
|
+
// Wait for save button to be enabled
|
|
238
|
+
const saveButton = rendered.getByRole("button", { name: "actions.save" });
|
|
239
|
+
|
|
240
|
+
await waitFor(() => expect(saveButton).toBeEnabled());
|
|
224
241
|
|
|
225
242
|
// Submit
|
|
226
|
-
await
|
|
227
|
-
userEvent.click(getByRole("button", { name: "Save" }));
|
|
228
|
-
});
|
|
243
|
+
await user.click(saveButton);
|
|
229
244
|
|
|
230
|
-
|
|
245
|
+
// Check that onSubmit was called with the right arguments
|
|
246
|
+
await waitFor(() => {
|
|
231
247
|
expect(onSubmit).toHaveBeenCalledWith({
|
|
232
248
|
subscriber: { type: "user", identifier: "2" },
|
|
233
249
|
scope: {
|
|
@@ -241,7 +257,7 @@ describe("<SubscriptionForm />", () => {
|
|
|
241
257
|
},
|
|
242
258
|
},
|
|
243
259
|
periodicity: "daily",
|
|
244
|
-
})
|
|
245
|
-
);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
246
262
|
});
|
|
247
263
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import SubscriptionNew from "../SubscriptionNew";
|
|
4
3
|
|
|
5
4
|
const renderOpts = {
|
|
@@ -7,8 +6,9 @@ const renderOpts = {
|
|
|
7
6
|
};
|
|
8
7
|
|
|
9
8
|
describe("<SubscriptionNew />", () => {
|
|
10
|
-
it("matches the latest snapshot", () => {
|
|
11
|
-
const
|
|
12
|
-
|
|
9
|
+
it("matches the latest snapshot", async () => {
|
|
10
|
+
const rendered = render(<SubscriptionNew />, renderOpts);
|
|
11
|
+
await waitForLoad(rendered);
|
|
12
|
+
expect(rendered.container).toMatchSnapshot();
|
|
13
13
|
});
|
|
14
14
|
});
|
|
@@ -1,10 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import {
|
|
3
|
+
SUBSCRIPTION,
|
|
4
|
+
SUBSCRIPTIONS,
|
|
5
|
+
SUBSCRIPTION_NEW,
|
|
6
|
+
SUBSCRIPTION_EDIT,
|
|
7
|
+
} from "@truedat/core/routes";
|
|
8
|
+
import { SubscriptionRoutes } from "../SubscriptionRoutes";
|
|
4
9
|
|
|
5
10
|
describe("<SubscriptionRoutes />", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
11
|
+
it("matches the latest snapshot for route SUBSCRIPTIONS", async () => {
|
|
12
|
+
const rendered = render(<SubscriptionRoutes />, {
|
|
13
|
+
routes: [SUBSCRIPTIONS],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await waitForLoad(rendered);
|
|
17
|
+
expect(rendered.container).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("matches the latest snapshot for route SUBSCRIPTION_NEW", async () => {
|
|
21
|
+
const rendered = render(<SubscriptionRoutes />, {
|
|
22
|
+
routes: [SUBSCRIPTION_NEW],
|
|
23
|
+
state: { templates: [] },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await waitForLoad(rendered);
|
|
27
|
+
expect(rendered.container).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("matches the latest snapshot for route SUBSCRIPTION_EDIT", async () => {
|
|
31
|
+
const rendered = render(<SubscriptionRoutes />, {
|
|
32
|
+
routes: [SUBSCRIPTION_EDIT],
|
|
33
|
+
state: { templates: [] },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await waitForLoad(rendered);
|
|
37
|
+
expect(rendered.container).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("matches the latest snapshot for route SUBSCRIPTION", async () => {
|
|
41
|
+
const rendered = render(<SubscriptionRoutes />, {
|
|
42
|
+
routes: [SUBSCRIPTION],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
await waitForLoad(rendered);
|
|
46
|
+
expect(rendered.container).toMatchSnapshot();
|
|
9
47
|
});
|
|
10
48
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import userEvent from "@testing-library/user-event";
|
|
2
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
3
|
import { SubscriptionWatchForm } from "../SubscriptionWatchForm";
|
|
4
4
|
|
|
5
5
|
describe("<SubscriptionWatchForm />", () => {
|
|
@@ -10,13 +10,13 @@ describe("<SubscriptionWatchForm />", () => {
|
|
|
10
10
|
status: ["warn"],
|
|
11
11
|
events: ["rule_result_created"],
|
|
12
12
|
resource_id: 2,
|
|
13
|
-
resource_type: "rule"
|
|
13
|
+
resource_type: "rule",
|
|
14
14
|
},
|
|
15
15
|
subscriber: {
|
|
16
16
|
id: 3,
|
|
17
17
|
identifier: "2",
|
|
18
|
-
type: "user"
|
|
19
|
-
}
|
|
18
|
+
type: "user",
|
|
19
|
+
},
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const handleChange = jest.fn();
|
|
@@ -30,43 +30,46 @@ describe("<SubscriptionWatchForm />", () => {
|
|
|
30
30
|
handleChange,
|
|
31
31
|
handleSubmit,
|
|
32
32
|
handleDelete,
|
|
33
|
-
subscriptionUpdating
|
|
33
|
+
subscriptionUpdating,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
it("matches the latest snapshot", () => {
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
it("matches the latest snapshot", async () => {
|
|
37
|
+
const rendered = render(<SubscriptionWatchForm {...props} />);
|
|
38
|
+
await waitForLoad(rendered);
|
|
39
|
+
expect(rendered.container).toMatchSnapshot();
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
it("calls handleChange when periodicity field changes", () => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
it("calls handleChange when periodicity field changes", async () => {
|
|
43
|
+
const rendered = render(<SubscriptionWatchForm {...props} />);
|
|
44
|
+
await waitForLoad(rendered);
|
|
45
|
+
|
|
46
|
+
const user = userEvent.setup({ delay: null });
|
|
47
|
+
const comboBoxes = await rendered.getAllByRole("radio");
|
|
48
|
+
const periodicityField = comboBoxes.find((el) => el.name === "periodicity");
|
|
49
|
+
await user.click(periodicityField);
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
.find({ name })
|
|
48
|
-
.at(1)
|
|
49
|
-
.simulate("change", e, { name });
|
|
50
|
-
expect(handleChange.mock.calls.length).toBe(1);
|
|
51
|
+
expect(handleChange).toHaveBeenCalledTimes(1);
|
|
51
52
|
});
|
|
52
53
|
|
|
53
|
-
it("calls handleSubmit on click", () => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
it("calls handleSubmit on click", async () => {
|
|
55
|
+
const rendered = render(<SubscriptionWatchForm {...props} />);
|
|
56
|
+
await waitForLoad(rendered);
|
|
57
|
+
|
|
58
|
+
const user = userEvent.setup({ delay: null });
|
|
59
|
+
const submitButton = await rendered.getByRole("button", { name: /save/i });
|
|
60
|
+
await user.click(submitButton);
|
|
61
|
+
|
|
62
|
+
expect(handleSubmit).toHaveBeenCalledTimes(1);
|
|
61
63
|
});
|
|
62
64
|
|
|
63
|
-
it("calls handleDelete", () => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
it("calls handleDelete", async () => {
|
|
66
|
+
const rendered = render(<SubscriptionWatchForm {...props} />);
|
|
67
|
+
await waitForLoad(rendered);
|
|
68
|
+
|
|
69
|
+
const user = userEvent.setup({ delay: null });
|
|
70
|
+
const deleteButton = rendered.getByRole("button", { name: /remove/i });
|
|
71
|
+
await user.click(deleteButton);
|
|
72
|
+
|
|
73
|
+
expect(handleDelete).toHaveBeenCalledTimes(1);
|
|
71
74
|
});
|
|
72
75
|
});
|
|
@@ -9,9 +9,9 @@ exports[`<NotificationEvent /> matches the latest snapshot 1`] = `
|
|
|
9
9
|
<div
|
|
10
10
|
class="ui orange mini basic label"
|
|
11
11
|
>
|
|
12
|
-
|
|
12
|
+
notifications.new
|
|
13
13
|
</div>
|
|
14
|
-
|
|
14
|
+
notifications.events.comments
|
|
15
15
|
</h4>
|
|
16
16
|
<p>
|
|
17
17
|
event name
|
|
@@ -19,12 +19,12 @@ exports[`<NotificationEvent /> matches the latest snapshot 1`] = `
|
|
|
19
19
|
<div
|
|
20
20
|
class="ui label"
|
|
21
21
|
>
|
|
22
|
-
|
|
22
|
+
comment_created
|
|
23
23
|
</div>
|
|
24
24
|
<time
|
|
25
25
|
datetime="1577836800000"
|
|
26
26
|
>
|
|
27
|
-
|
|
27
|
+
5 years ago
|
|
28
28
|
</time>
|
|
29
29
|
</div>
|
|
30
30
|
</div>
|
|
@@ -39,7 +39,7 @@ exports[`<NotificationEvent /> matches the latest snapshot for external notifica
|
|
|
39
39
|
<div
|
|
40
40
|
class="ui orange mini basic label"
|
|
41
41
|
>
|
|
42
|
-
|
|
42
|
+
notifications.new
|
|
43
43
|
</div>
|
|
44
44
|
↗ Test external notification
|
|
45
45
|
</h4>
|
|
@@ -54,7 +54,7 @@ exports[`<NotificationEvent /> matches the latest snapshot for external notifica
|
|
|
54
54
|
<time
|
|
55
55
|
datetime="1577836800000"
|
|
56
56
|
>
|
|
57
|
-
|
|
57
|
+
5 years ago
|
|
58
58
|
</time>
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
@@ -18,7 +18,7 @@ exports[`<NotificationsMenu /> matches the latest snapshot 1`] = `
|
|
|
18
18
|
<div
|
|
19
19
|
class="header"
|
|
20
20
|
>
|
|
21
|
-
|
|
21
|
+
navigation.notifications
|
|
22
22
|
</div>
|
|
23
23
|
<div
|
|
24
24
|
class="divider"
|
|
@@ -35,9 +35,9 @@ exports[`<NotificationsMenu /> matches the latest snapshot 1`] = `
|
|
|
35
35
|
<div
|
|
36
36
|
class="ui orange mini basic label"
|
|
37
37
|
>
|
|
38
|
-
|
|
38
|
+
notifications.new
|
|
39
39
|
</div>
|
|
40
|
-
|
|
40
|
+
notifications.events.default
|
|
41
41
|
</h4>
|
|
42
42
|
<p>
|
|
43
43
|
bar
|
|
@@ -48,7 +48,7 @@ exports[`<NotificationsMenu /> matches the latest snapshot 1`] = `
|
|
|
48
48
|
foo
|
|
49
49
|
</div>
|
|
50
50
|
<time
|
|
51
|
-
datetime="
|
|
51
|
+
datetime="1735689600000"
|
|
52
52
|
>
|
|
53
53
|
a few seconds ago
|
|
54
54
|
</time>
|
|
@@ -77,7 +77,7 @@ exports[`<NotificationsMenu /> matches the latest snapshot with external notific
|
|
|
77
77
|
<div
|
|
78
78
|
class="header"
|
|
79
79
|
>
|
|
80
|
-
|
|
80
|
+
navigation.notifications
|
|
81
81
|
</div>
|
|
82
82
|
<div
|
|
83
83
|
class="divider"
|
|
@@ -95,7 +95,7 @@ exports[`<NotificationsMenu /> matches the latest snapshot with external notific
|
|
|
95
95
|
<div
|
|
96
96
|
class="ui orange mini basic label"
|
|
97
97
|
>
|
|
98
|
-
|
|
98
|
+
notifications.new
|
|
99
99
|
</div>
|
|
100
100
|
↗ undefined
|
|
101
101
|
</h4>
|
|
@@ -108,7 +108,7 @@ exports[`<NotificationsMenu /> matches the latest snapshot with external notific
|
|
|
108
108
|
external_notification
|
|
109
109
|
</div>
|
|
110
110
|
<time
|
|
111
|
-
datetime="
|
|
111
|
+
datetime="1735689600000"
|
|
112
112
|
>
|
|
113
113
|
a few seconds ago
|
|
114
114
|
</time>
|