@truedat/audit 4.44.2 → 4.44.3
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 +5 -5
- package/src/components/EventsLoader.js +15 -11
- package/src/components/NotificationEvent.js +12 -1
- package/src/components/ShareLinkForm.js +1 -1
- package/src/components/Subscription.js +43 -22
- package/src/components/SubscriptionEdit.js +33 -18
- package/src/components/SubscriptionForm.js +6 -2
- package/src/components/SubscriptionLoader.js +26 -14
- package/src/components/SubscriptionNew.js +20 -8
- package/src/components/Subscriptions.js +22 -7
- package/src/components/SubscriptionsLoader.js +26 -13
- package/src/components/__tests__/NotificationEvent.spec.js +8 -9
- package/src/components/__tests__/ShareLinkForm.spec.js +14 -34
- package/src/components/__tests__/Subscription.spec.js +18 -27
- package/src/components/__tests__/SubscriptionEdit.spec.js +12 -20
- package/src/components/__tests__/SubscriptionForm.spec.js +51 -156
- package/src/components/__tests__/SubscriptionLoader.spec.js +4 -12
- package/src/components/__tests__/SubscriptionNew.spec.js +6 -13
- package/src/components/__tests__/Subscriptions.spec.js +26 -38
- package/src/components/__tests__/SubscriptionsLoader.spec.js +10 -9
- package/src/components/__tests__/__snapshots__/NotificationEvent.spec.js.snap +25 -44
- package/src/components/__tests__/__snapshots__/ShareLinkForm.spec.js.snap +6 -6
- package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +144 -75
- package/src/components/__tests__/__snapshots__/SubscriptionEdit.spec.js.snap +372 -22
- package/src/components/__tests__/__snapshots__/SubscriptionForm.spec.js.snap +22 -22
- package/src/components/__tests__/__snapshots__/SubscriptionLoader.spec.js.snap +16 -1
- package/src/components/__tests__/__snapshots__/SubscriptionNew.spec.js.snap +373 -16
- package/src/components/__tests__/__snapshots__/Subscriptions.spec.js.snap +339 -407
- package/src/components/__tests__/__snapshots__/SubscriptionsLoader.spec.js.snap +18 -1
- package/src/messages/en.js +0 -2
- package/src/messages/es.js +0 -2
|
@@ -1,39 +1,30 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Subscription, SubscriptionHeader } from "../Subscription";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import Subscription, { SubscriptionHeader } from "../Subscription";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
// workaround for enzyme issue with React.useContext
|
|
24
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
25
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
state: {
|
|
7
|
+
subscriptionLoading: false,
|
|
8
|
+
subscription: {
|
|
9
|
+
subscriber: { type: "user" },
|
|
10
|
+
scope: {
|
|
11
|
+
events: ["event1"],
|
|
12
|
+
status: ["status1"],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
26
17
|
|
|
27
18
|
describe("<Subscription />", () => {
|
|
28
19
|
it("matches the latest snapshot", () => {
|
|
29
|
-
const
|
|
30
|
-
expect(
|
|
20
|
+
const { container } = render(<Subscription />, renderOpts);
|
|
21
|
+
expect(container).toMatchSnapshot();
|
|
31
22
|
});
|
|
32
23
|
});
|
|
33
24
|
|
|
34
25
|
describe("<SubscriptionHeader />", () => {
|
|
35
26
|
it("matches the latest snapshot", () => {
|
|
36
|
-
const
|
|
37
|
-
expect(
|
|
27
|
+
const { container } = render(<SubscriptionHeader />, renderOpts);
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
38
29
|
});
|
|
39
30
|
});
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallow } from "enzyme";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
4
3
|
import SubscriptionEdit from "../SubscriptionEdit";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
)
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
// workaround for enzyme issue with React.useContext
|
|
20
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
21
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
state: {
|
|
7
|
+
creatingSubscription: false,
|
|
8
|
+
subscription: {
|
|
9
|
+
subscriber: { type: "user" },
|
|
10
|
+
},
|
|
11
|
+
templates: [],
|
|
12
|
+
},
|
|
13
|
+
};
|
|
22
14
|
|
|
23
15
|
describe("<SubscriptionEdit />", () => {
|
|
24
16
|
it("matches the latest snapshot", () => {
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
17
|
+
const { container } = render(<SubscriptionEdit />, renderOpts);
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
27
19
|
});
|
|
28
20
|
});
|
|
@@ -6,107 +6,6 @@ import SubscriptionForm from "../SubscriptionForm";
|
|
|
6
6
|
|
|
7
7
|
jest.setTimeout(20000);
|
|
8
8
|
|
|
9
|
-
const messages = {
|
|
10
|
-
en: {
|
|
11
|
-
"actions.cancel": "actions.cancel",
|
|
12
|
-
"actions.submit": "actions.submit",
|
|
13
|
-
"concepts.search.placeholder": "concepts.search.placeholder",
|
|
14
|
-
"concepts.search.results.empty": "concepts.search.results.empty",
|
|
15
|
-
"domain.selector.placeholder": "domain.selector.placeholder",
|
|
16
|
-
"role.search.placeholder": "role.search.placeholder",
|
|
17
|
-
"structures.not_found.body": "structures.not_found.body",
|
|
18
|
-
"structures.not_found.header": "structures.not_found.header",
|
|
19
|
-
"structures.search.placeholder": "structures.search.placeholder",
|
|
20
|
-
"subscription.subscriber_type.email": "subscription.subscriber_type.email",
|
|
21
|
-
"subscription.subscriber_type.role": "subscription.subscriber_type.role",
|
|
22
|
-
"subscription.subscriber_type.user": "subscription.subscriber_type.user",
|
|
23
|
-
"subscription.subscriber_type.taxonomy_role":
|
|
24
|
-
"subscription.subscriber_type.taxonomy_role",
|
|
25
|
-
"subscriptions.events": "subscriptions.events",
|
|
26
|
-
"subscriptions.events.comment_created":
|
|
27
|
-
"subscriptions.events.comment_created",
|
|
28
|
-
"subscriptions.events.concept_deprecated":
|
|
29
|
-
"subscriptions.events.concept_deprecated",
|
|
30
|
-
"subscriptions.events.concept_published":
|
|
31
|
-
"subscriptions.events.concept_published",
|
|
32
|
-
"subscriptions.events.concept_rejected":
|
|
33
|
-
"subscriptions.events.concept_rejected",
|
|
34
|
-
"subscriptions.events.concept_rejection_canceled":
|
|
35
|
-
"subscriptions.events.concept_rejection_canceled",
|
|
36
|
-
"subscriptions.events.concept_submitted":
|
|
37
|
-
"subscriptions.events.concept_submitted",
|
|
38
|
-
"subscriptions.events.delete_concept_draft":
|
|
39
|
-
"subscriptions.events.delete_concept_draft",
|
|
40
|
-
"subscriptions.events.implementation_created": "Implementation created",
|
|
41
|
-
"subscriptions.events.ingest_sent_for_approval":
|
|
42
|
-
"subscriptions.events.ingest_sent_for_approval",
|
|
43
|
-
"subscriptions.events.new_concept_draft":
|
|
44
|
-
"subscriptions.events.new_concept_draft",
|
|
45
|
-
"subscriptions.events.grant_created": "subscriptions.events.grant_created",
|
|
46
|
-
"subscriptions.events.grant_deleted": "subscriptions.events.grant_deleted",
|
|
47
|
-
"subscriptions.events.relation_created":
|
|
48
|
-
"subscriptions.events.relation_created",
|
|
49
|
-
"subscriptions.events.relation_deleted":
|
|
50
|
-
"subscriptions.events.relation_deleted",
|
|
51
|
-
"subscriptions.events.relation_deprecated":
|
|
52
|
-
"subscriptions.events.relation_deprecated",
|
|
53
|
-
"subscriptions.events.rule_created": "Rule created",
|
|
54
|
-
"subscriptions.events.structure_note_deleted":
|
|
55
|
-
"subscriptions.events.structure_note_deleted",
|
|
56
|
-
"subscriptions.events.structure_note_deprecated":
|
|
57
|
-
"subscriptions.events.structure_note_deprecated",
|
|
58
|
-
"subscriptions.events.structure_note_draft":
|
|
59
|
-
"subscriptions.events.structure_note_draft",
|
|
60
|
-
"subscriptions.events.structure_note_pending_approval":
|
|
61
|
-
"subscriptions.events.structure_note_pending_approval",
|
|
62
|
-
"subscriptions.events.structure_note_published":
|
|
63
|
-
"subscriptions.events.structure_note_published",
|
|
64
|
-
"subscriptions.events.structure_note_rejected":
|
|
65
|
-
"subscriptions.events.structure_note_rejected",
|
|
66
|
-
"subscriptions.events.structure_note_versioned":
|
|
67
|
-
"subscriptions.events.structure_note_versioned",
|
|
68
|
-
"subscriptions.events.rule_result_created":
|
|
69
|
-
"subscriptions.events.rule_result_created",
|
|
70
|
-
"subscriptions.events.structure_tag_link_deleted":
|
|
71
|
-
"subscriptions.events.structure_tag_link_deleted",
|
|
72
|
-
"subscriptions.events.structure_tag_link_updated":
|
|
73
|
-
"subscriptions.events.structure_tag_link_updated",
|
|
74
|
-
"subscriptions.events.structure_tag_linked":
|
|
75
|
-
"subscriptions.events.structure_tag_linked",
|
|
76
|
-
"subscriptions.events.update_concept_draft":
|
|
77
|
-
"subscriptions.events.update_concept_draft",
|
|
78
|
-
"subscriptions.periodicity": "subscriptions.periodicity",
|
|
79
|
-
"subscriptions.periodicity.daily": "subscriptions.periodicity.daily",
|
|
80
|
-
"subscriptions.periodicity.hourly": "subscriptions.periodicity.hourly",
|
|
81
|
-
"subscriptions.periodicity.minutely": "subscriptions.periodicity.minutely",
|
|
82
|
-
"subscriptions.resource": "subscriptions.resource",
|
|
83
|
-
"subscriptions.resource.type.concept":
|
|
84
|
-
"subscriptions.resource.type.concept",
|
|
85
|
-
"subscriptions.resource.type.data_structure":
|
|
86
|
-
"subscriptions.resource.type.data_structure",
|
|
87
|
-
"subscriptions.resource.type.domain": "subscriptions.resource.type.domain",
|
|
88
|
-
"subscriptions.resource.type.domains":
|
|
89
|
-
"subscriptions.resource.type.domains",
|
|
90
|
-
"subscriptions.resource.type.rule": "subscriptions.resource.type.rule",
|
|
91
|
-
"subscriptions.resource.type.source": "subscriptions.resource.type.source",
|
|
92
|
-
"subscriptions.selectFilters": "subscriptions.selectFilters",
|
|
93
|
-
"subscriptions.status": "subscriptions.status",
|
|
94
|
-
"subscriptions.status.fail": "subscriptions.status.fail",
|
|
95
|
-
"subscriptions.status.success": "subscriptions.status.success",
|
|
96
|
-
"subscriptions.status.warn": "subscriptions.status.warn",
|
|
97
|
-
"subscriptions.subscriber": "subscriptions.subscriber",
|
|
98
|
-
"subscriptions.template.field": "subscriptions.template.field",
|
|
99
|
-
"subscriptions.template.field.placeholder":
|
|
100
|
-
"subscriptions.template.field.placeholder",
|
|
101
|
-
"subscriptions.template.field.value": "subscriptions.template.field.value",
|
|
102
|
-
"subscriptions.template.field.value.placeholder":
|
|
103
|
-
"subscriptions.template.field.value.placeholder",
|
|
104
|
-
"subscriptions.template.label": "subscriptions.template.label",
|
|
105
|
-
"subscriptions.template.placeholder": "subscriptions.template.placeholder",
|
|
106
|
-
"user.search.placeholder": "user.search.placeholder",
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
9
|
const conceptActiveFilters = {};
|
|
111
10
|
const structureActiveFilters = {};
|
|
112
11
|
const domains = [
|
|
@@ -146,15 +45,12 @@ const state = {
|
|
|
146
45
|
conceptActiveFilters,
|
|
147
46
|
structureActiveFilters,
|
|
148
47
|
};
|
|
149
|
-
const renderOpts = {
|
|
150
|
-
messages,
|
|
151
|
-
state,
|
|
152
|
-
};
|
|
48
|
+
const renderOpts = { state };
|
|
153
49
|
|
|
154
50
|
describe("<SubscriptionForm />", () => {
|
|
155
51
|
it("matches the latest snapshot", async () => {
|
|
156
52
|
const { container, findByRole } = render(<SubscriptionForm />, renderOpts);
|
|
157
|
-
await findByRole("button", { name:
|
|
53
|
+
await findByRole("button", { name: "Save" });
|
|
158
54
|
expect(container).toMatchSnapshot();
|
|
159
55
|
});
|
|
160
56
|
|
|
@@ -166,78 +62,77 @@ describe("<SubscriptionForm />", () => {
|
|
|
166
62
|
renderOpts
|
|
167
63
|
);
|
|
168
64
|
await waitFor(() => {
|
|
169
|
-
expect(getByRole("button", { name:
|
|
65
|
+
expect(getByRole("button", { name: "Save" })).toBeDisabled();
|
|
170
66
|
});
|
|
171
67
|
|
|
172
68
|
// Select role
|
|
173
|
-
userEvent.click(await findByText(
|
|
69
|
+
userEvent.click(await findByText("Role"));
|
|
174
70
|
await waitFor(() => {
|
|
175
|
-
expect(queryByText(
|
|
71
|
+
expect(queryByText(/Search Roles/)).toBeTruthy();
|
|
176
72
|
});
|
|
177
|
-
userEvent.click(await findByText(
|
|
73
|
+
userEvent.click(await findByText("role2"));
|
|
178
74
|
|
|
179
75
|
// Select email
|
|
180
|
-
userEvent.click(await findByText(
|
|
76
|
+
userEvent.click(await findByText("Email"));
|
|
181
77
|
await waitFor(() => {
|
|
182
78
|
expect(queryByTestId("email-input")).toBeTruthy();
|
|
183
79
|
});
|
|
184
80
|
userEvent.type(queryByTestId("email-input"), "foo");
|
|
185
81
|
|
|
186
82
|
// Select concept and taxonomy_role
|
|
187
|
-
userEvent.click(await findByText(
|
|
83
|
+
userEvent.click(await findByText("Concept"));
|
|
188
84
|
await waitFor(() => {
|
|
189
|
-
expect(queryByText("concepts
|
|
85
|
+
expect(queryByText("No concepts found")).toBeTruthy();
|
|
190
86
|
});
|
|
191
87
|
|
|
192
|
-
userEvent.click(await findByText(
|
|
88
|
+
userEvent.click(await findByText("Role in taxonomy"));
|
|
193
89
|
await waitFor(() => {
|
|
194
|
-
expect(queryByText(
|
|
90
|
+
expect(queryByText(/Search Roles/)).toBeTruthy();
|
|
195
91
|
});
|
|
196
92
|
await waitFor(() => {
|
|
197
|
-
expect(queryByText("concepts
|
|
93
|
+
expect(queryByText("No concepts found")).toBeFalsy();
|
|
198
94
|
});
|
|
199
|
-
userEvent.click(await findByText(
|
|
95
|
+
userEvent.click(await findByText("role2"));
|
|
200
96
|
|
|
201
97
|
// Select user
|
|
202
|
-
userEvent.click(await findByText(
|
|
98
|
+
userEvent.click(await findByText("User"));
|
|
203
99
|
await waitFor(() => {
|
|
204
|
-
expect(queryByText(
|
|
100
|
+
expect(queryByText(/Search users/)).toBeTruthy();
|
|
205
101
|
});
|
|
206
|
-
userEvent.click(await findByText(
|
|
102
|
+
userEvent.click(await findByText("user2"));
|
|
207
103
|
|
|
208
104
|
// Test concepts
|
|
209
|
-
userEvent.click(await findByText(
|
|
105
|
+
userEvent.click(await findByText("Concept"));
|
|
210
106
|
await waitFor(() => {
|
|
211
|
-
expect(queryByText("concepts
|
|
107
|
+
expect(queryByText("No concepts found")).toBeTruthy();
|
|
212
108
|
});
|
|
213
109
|
|
|
214
110
|
// Test structures
|
|
215
|
-
userEvent.click(await findByText(
|
|
111
|
+
userEvent.click(await findByText("Structure"));
|
|
216
112
|
await waitFor(() => {
|
|
217
|
-
expect(
|
|
113
|
+
expect(
|
|
114
|
+
queryByText("No structures have been found matching these filters.")
|
|
115
|
+
).toBeTruthy();
|
|
218
116
|
});
|
|
219
117
|
|
|
220
118
|
// Select domains
|
|
221
|
-
userEvent.click(await findByText(
|
|
119
|
+
userEvent.click(await findByText("Domain and children"));
|
|
222
120
|
await waitFor(() => {
|
|
223
|
-
expect(queryByText(
|
|
121
|
+
expect(queryByText(/Select a domain/)).toBeTruthy();
|
|
224
122
|
});
|
|
225
123
|
|
|
226
|
-
userEvent.click(await findByText(
|
|
227
|
-
|
|
228
|
-
userEvent.click(await findByText(
|
|
229
|
-
userEvent.click(
|
|
230
|
-
await findByText(/subscriptions.events.rule_result_created/)
|
|
231
|
-
);
|
|
232
|
-
userEvent.click(await findByText(/subscriptions.status.success/));
|
|
124
|
+
userEvent.click(await findByText("domain1"));
|
|
125
|
+
userEvent.click(await findByText("Daily"));
|
|
126
|
+
userEvent.click(await findByText("Rule result created"));
|
|
127
|
+
userEvent.click(await findByText("Goal"));
|
|
233
128
|
|
|
234
129
|
await waitFor(() => {
|
|
235
|
-
expect(getByRole("button", { name:
|
|
130
|
+
expect(getByRole("button", { name: "Save" })).toBeEnabled();
|
|
236
131
|
});
|
|
237
132
|
|
|
238
133
|
// Submit
|
|
239
134
|
await waitFor(() => {
|
|
240
|
-
userEvent.click(getByRole("button", { name:
|
|
135
|
+
userEvent.click(getByRole("button", { name: "Save" }));
|
|
241
136
|
});
|
|
242
137
|
|
|
243
138
|
await waitFor(() =>
|
|
@@ -265,58 +160,58 @@ describe("<SubscriptionForm />", () => {
|
|
|
265
160
|
);
|
|
266
161
|
|
|
267
162
|
await waitFor(() => {
|
|
268
|
-
expect(getByRole("button", { name:
|
|
163
|
+
expect(getByRole("button", { name: "Save" })).toBeDisabled();
|
|
269
164
|
});
|
|
270
165
|
|
|
271
166
|
// Select role
|
|
272
|
-
userEvent.click(await findByText(
|
|
167
|
+
userEvent.click(await findByText("Role"));
|
|
273
168
|
await waitFor(() => {
|
|
274
|
-
expect(queryByText(
|
|
169
|
+
expect(queryByText(/Search Roles/)).toBeTruthy();
|
|
275
170
|
});
|
|
276
|
-
userEvent.click(await findByText(
|
|
171
|
+
userEvent.click(await findByText("role2"));
|
|
277
172
|
|
|
278
173
|
// Select email
|
|
279
|
-
userEvent.click(await findByText(
|
|
174
|
+
userEvent.click(await findByText("Email"));
|
|
280
175
|
await waitFor(() => {
|
|
281
176
|
expect(queryByTestId("email-input")).toBeTruthy();
|
|
282
177
|
});
|
|
283
178
|
userEvent.type(queryByTestId("email-input"), "foo");
|
|
284
179
|
|
|
285
180
|
// Select user
|
|
286
|
-
userEvent.click(await findByText(
|
|
181
|
+
userEvent.click(await findByText("User"));
|
|
287
182
|
await waitFor(() => {
|
|
288
|
-
expect(queryByText(
|
|
183
|
+
expect(queryByText(/Search users/)).toBeTruthy();
|
|
289
184
|
});
|
|
290
|
-
userEvent.click(await findByText(
|
|
185
|
+
userEvent.click(await findByText("user2"));
|
|
291
186
|
|
|
292
187
|
// Test concepts
|
|
293
|
-
userEvent.click(await findByText(
|
|
188
|
+
userEvent.click(await findByText("Concept"));
|
|
294
189
|
await waitFor(() => {
|
|
295
|
-
expect(queryByText("concepts
|
|
190
|
+
expect(queryByText("No concepts found")).toBeTruthy();
|
|
296
191
|
});
|
|
297
192
|
|
|
298
193
|
// Select domains
|
|
299
|
-
userEvent.click(await findByText(
|
|
194
|
+
userEvent.click(await findByText("Domain and children"));
|
|
300
195
|
await waitFor(() => {
|
|
301
|
-
expect(queryByText(
|
|
196
|
+
expect(queryByText(/Select a domain/)).toBeTruthy();
|
|
302
197
|
});
|
|
303
198
|
|
|
304
|
-
userEvent.click(await findByText(
|
|
199
|
+
userEvent.click(await findByText("domain1"));
|
|
305
200
|
|
|
306
|
-
userEvent.click(await findByText(
|
|
307
|
-
userEvent.click(await findByText(
|
|
308
|
-
userEvent.click(await queryByText(
|
|
309
|
-
userEvent.click(await findByText(
|
|
310
|
-
userEvent.click(await findByText(
|
|
311
|
-
userEvent.click(await findByText(
|
|
201
|
+
userEvent.click(await findByText("Daily"));
|
|
202
|
+
userEvent.click(await findByText("Comment created"));
|
|
203
|
+
userEvent.click(await queryByText("Filters to subscription"));
|
|
204
|
+
userEvent.click(await findByText("Foo"));
|
|
205
|
+
userEvent.click(await findByText("Xyz"));
|
|
206
|
+
userEvent.click(await findByText("baz"));
|
|
312
207
|
|
|
313
208
|
await waitFor(() => {
|
|
314
|
-
expect(getByRole("button", { name:
|
|
209
|
+
expect(getByRole("button", { name: "Save" })).toBeEnabled();
|
|
315
210
|
});
|
|
316
211
|
|
|
317
212
|
// Submit
|
|
318
213
|
await waitFor(() => {
|
|
319
|
-
userEvent.click(getByRole("button", { name:
|
|
214
|
+
userEvent.click(getByRole("button", { name: "Save" }));
|
|
320
215
|
});
|
|
321
216
|
|
|
322
217
|
await waitFor(() =>
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import SubscriptionLoader from "../SubscriptionLoader";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
...jest.requireActual("react-redux"),
|
|
7
|
-
useDispatch: jest.fn(),
|
|
8
|
-
useSelector: jest.fn(selector => selector({ subscriptionsLoading: false }))
|
|
9
|
-
}));
|
|
10
|
-
jest.mock("react-router-dom", () => ({
|
|
11
|
-
...jest.requireActual("react-router-dom"),
|
|
12
|
-
useParams: () => ({ id: 1 })
|
|
13
|
-
}));
|
|
5
|
+
const renderOpts = { state: { subscriptionLoading: true } };
|
|
14
6
|
|
|
15
7
|
describe("<SubscriptionLoader />", () => {
|
|
16
8
|
it("matches the latest snapshot", () => {
|
|
17
|
-
const
|
|
18
|
-
expect(
|
|
9
|
+
const { container } = render(<SubscriptionLoader />, renderOpts);
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
19
11
|
});
|
|
20
12
|
});
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallow } from "enzyme";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
4
3
|
import SubscriptionNew from "../SubscriptionNew";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
useSelector: jest.fn(selector => selector({ creatingSubscription: false }))
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
// workaround for enzyme issue with React.useContext
|
|
13
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
14
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
state: { templates: [] },
|
|
7
|
+
};
|
|
15
8
|
|
|
16
9
|
describe("<SubscriptionNew />", () => {
|
|
17
10
|
it("matches the latest snapshot", () => {
|
|
18
|
-
const
|
|
19
|
-
expect(
|
|
11
|
+
const { container } = render(<SubscriptionNew />, renderOpts);
|
|
12
|
+
expect(container).toMatchSnapshot();
|
|
20
13
|
});
|
|
21
14
|
});
|
|
@@ -1,51 +1,39 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import Subscriptions, { SubscriptionsHeader } from "../Subscriptions";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
],
|
|
26
|
-
})
|
|
27
|
-
),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
const mockHistory = {
|
|
31
|
-
goBack: jest.fn(),
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
state: {
|
|
7
|
+
subscriptions: [
|
|
8
|
+
{
|
|
9
|
+
id: 1,
|
|
10
|
+
scope: { resource_type: "domain" },
|
|
11
|
+
periodicity: "hourly",
|
|
12
|
+
subscriber: { id: 3, type: "user" },
|
|
13
|
+
resource: { id: 2, name: "resource" },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 2,
|
|
17
|
+
scope: { resource_type: "data_structure" },
|
|
18
|
+
periodicity: "minutely",
|
|
19
|
+
subscriber: { id: 4, type: "user" },
|
|
20
|
+
resource: { id: 3, name: "bar" },
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
users: [{ full_name: "test1", id: 1 }],
|
|
24
|
+
},
|
|
32
25
|
};
|
|
33
26
|
|
|
34
|
-
jest.mock("react-router-dom", () => ({
|
|
35
|
-
...jest.requireActual("react-router-dom"),
|
|
36
|
-
useHistory: () => mockHistory,
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
27
|
describe("<Subscriptions />", () => {
|
|
40
28
|
it("matches the latest snapshot", () => {
|
|
41
|
-
const
|
|
42
|
-
expect(
|
|
29
|
+
const { container } = render(<Subscriptions />, renderOpts);
|
|
30
|
+
expect(container).toMatchSnapshot();
|
|
43
31
|
});
|
|
44
32
|
});
|
|
45
33
|
|
|
46
34
|
describe("<SubscriptionsHeader />", () => {
|
|
47
35
|
it("matches the latest snapshot", () => {
|
|
48
|
-
const
|
|
49
|
-
expect(
|
|
36
|
+
const { container } = render(<SubscriptionsHeader />, renderOpts);
|
|
37
|
+
expect(container).toMatchSnapshot();
|
|
50
38
|
});
|
|
51
39
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import SubscriptionsLoader from "../SubscriptionsLoader";
|
|
4
4
|
|
|
5
|
-
jest.mock("react-redux", () => ({
|
|
6
|
-
...jest.requireActual("react-redux"),
|
|
7
|
-
useDispatch: jest.fn(),
|
|
8
|
-
useSelector: jest.fn(selector => selector({ subscriptionsLoading: false }))
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
5
|
describe("<SubscriptionsLoader />", () => {
|
|
12
6
|
it("matches the latest snapshot", () => {
|
|
13
|
-
const
|
|
14
|
-
expect(
|
|
7
|
+
const { container } = render(<SubscriptionsLoader />, {});
|
|
8
|
+
expect(container).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("matches the latest snapshot (loading)", () => {
|
|
12
|
+
const { container } = render(<SubscriptionsLoader loading />, {
|
|
13
|
+
state: { subscriptionsLoading: true },
|
|
14
|
+
});
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
15
16
|
});
|
|
16
17
|
});
|
|
@@ -1,50 +1,31 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<NotificationEvent /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<h4>
|
|
8
|
-
<Label
|
|
9
|
-
basic={true}
|
|
10
|
-
color="orange"
|
|
11
|
-
size="mini"
|
|
12
|
-
>
|
|
13
|
-
<MemoizedFormattedMessage
|
|
14
|
-
id="notifications.new"
|
|
15
|
-
/>
|
|
16
|
-
</Label>
|
|
17
|
-
<MemoizedFormattedMessage
|
|
18
|
-
id="notifications.events.comments"
|
|
19
|
-
/>
|
|
20
|
-
</h4>
|
|
21
|
-
<p>
|
|
22
|
-
event name
|
|
23
|
-
</p>
|
|
24
|
-
<Label>
|
|
25
|
-
<MemoizedFormattedMessage
|
|
26
|
-
id="subscriptions.events.comment_created"
|
|
27
|
-
/>
|
|
28
|
-
</Label>
|
|
29
|
-
<t
|
|
30
|
-
ago={false}
|
|
31
|
-
calendar={false}
|
|
32
|
-
decimal={false}
|
|
33
|
-
element={null}
|
|
34
|
-
filter={[Function]}
|
|
35
|
-
fromNow={true}
|
|
36
|
-
interval={60000}
|
|
37
|
-
local={false}
|
|
38
|
-
locale="en"
|
|
39
|
-
onChange={[Function]}
|
|
40
|
-
titleFormat=""
|
|
41
|
-
toNow={false}
|
|
42
|
-
unit={null}
|
|
43
|
-
unix={false}
|
|
44
|
-
utc={false}
|
|
45
|
-
withTitle={false}
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="notification-item unread"
|
|
46
7
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
8
|
+
<h4>
|
|
9
|
+
<div
|
|
10
|
+
class="ui orange mini basic label"
|
|
11
|
+
>
|
|
12
|
+
New
|
|
13
|
+
</div>
|
|
14
|
+
🖋 Alert: New comments added
|
|
15
|
+
</h4>
|
|
16
|
+
<p>
|
|
17
|
+
event name
|
|
18
|
+
</p>
|
|
19
|
+
<div
|
|
20
|
+
class="ui label"
|
|
21
|
+
>
|
|
22
|
+
Comment created
|
|
23
|
+
</div>
|
|
24
|
+
<time
|
|
25
|
+
datetime="1577836800000"
|
|
26
|
+
>
|
|
27
|
+
2 years ago
|
|
28
|
+
</time>
|
|
29
|
+
</div>
|
|
49
30
|
</div>
|
|
50
31
|
`;
|