@stream-io/feeds-client 0.2.0 → 0.2.2

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 (83) hide show
  1. package/@react-bindings/hooks/feed-state-hooks/index.ts +4 -0
  2. package/CHANGELOG.md +16 -0
  3. package/dist/@react-bindings/hooks/feed-state-hooks/index.d.ts +4 -0
  4. package/dist/@react-bindings/hooks/feed-state-hooks/useAggregatedActivities.d.ts +11 -0
  5. package/dist/@react-bindings/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts +6 -0
  6. package/dist/@react-bindings/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts +6 -0
  7. package/dist/@react-bindings/hooks/feed-state-hooks/useNotificationStatus.d.ts +13 -0
  8. package/dist/@react-bindings/wrappers/StreamFeed.d.ts +1 -1
  9. package/dist/index-react-bindings.browser.cjs +505 -222
  10. package/dist/index-react-bindings.browser.cjs.map +1 -1
  11. package/dist/index-react-bindings.browser.js +502 -223
  12. package/dist/index-react-bindings.browser.js.map +1 -1
  13. package/dist/index-react-bindings.node.cjs +505 -222
  14. package/dist/index-react-bindings.node.cjs.map +1 -1
  15. package/dist/index-react-bindings.node.js +502 -223
  16. package/dist/index-react-bindings.node.js.map +1 -1
  17. package/dist/index.browser.cjs +440 -205
  18. package/dist/index.browser.cjs.map +1 -1
  19. package/dist/index.browser.js +440 -206
  20. package/dist/index.browser.js.map +1 -1
  21. package/dist/index.node.cjs +440 -205
  22. package/dist/index.node.cjs.map +1 -1
  23. package/dist/index.node.js +440 -206
  24. package/dist/index.node.js.map +1 -1
  25. package/dist/src/feed/event-handlers/activity/handle-activity-deleted.d.ts +12 -3
  26. package/dist/src/feed/event-handlers/activity/handle-activity-marked.d.ts +11 -0
  27. package/dist/src/feed/event-handlers/activity/handle-activity-pinned.d.ts +3 -0
  28. package/dist/src/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +10 -6
  29. package/dist/src/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +10 -6
  30. package/dist/src/feed/event-handlers/activity/handle-activity-unpinned.d.ts +3 -0
  31. package/dist/src/feed/event-handlers/activity/handle-activity-updated.d.ts +7 -3
  32. package/dist/src/feed/event-handlers/activity/index.d.ts +1 -0
  33. package/dist/src/feed/event-handlers/bookmark/handle-bookmark-added.d.ts +10 -6
  34. package/dist/src/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts +10 -6
  35. package/dist/src/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts +10 -6
  36. package/dist/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts +8 -1
  37. package/dist/src/feed/feed.d.ts +2 -2
  38. package/dist/src/gen/models/index.d.ts +36 -1
  39. package/dist/src/test-utils/response-generators.d.ts +66 -1
  40. package/dist/src/utils/index.d.ts +1 -0
  41. package/dist/src/utils/update-entity-in-array.d.ts +27 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +1 -1
  44. package/src/feed/event-handlers/activity/activity-marked-utils.test.ts +208 -0
  45. package/src/feed/event-handlers/activity/activity-reaction-utils.test.ts +108 -96
  46. package/src/feed/event-handlers/activity/activity-utils.test.ts +84 -122
  47. package/src/feed/event-handlers/activity/handle-activity-deleted.ts +43 -10
  48. package/src/feed/event-handlers/activity/handle-activity-marked.ts +68 -0
  49. package/src/feed/event-handlers/activity/handle-activity-pinned.test.ts +60 -0
  50. package/src/feed/event-handlers/activity/handle-activity-pinned.ts +30 -0
  51. package/src/feed/event-handlers/activity/handle-activity-reaction-added.test.ts +157 -0
  52. package/src/feed/event-handlers/activity/handle-activity-reaction-added.ts +82 -40
  53. package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.test.ts +200 -0
  54. package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.ts +89 -51
  55. package/src/feed/event-handlers/activity/handle-activity-unpinned.test.ts +95 -0
  56. package/src/feed/event-handlers/activity/handle-activity-unpinned.ts +30 -0
  57. package/src/feed/event-handlers/activity/handle-activity-updated.test.ts +115 -0
  58. package/src/feed/event-handlers/activity/handle-activity-updated.ts +73 -35
  59. package/src/feed/event-handlers/activity/index.ts +2 -1
  60. package/src/feed/event-handlers/bookmark/bookmark-utils.test.ts +121 -109
  61. package/src/feed/event-handlers/bookmark/handle-bookmark-added.test.ts +178 -0
  62. package/src/feed/event-handlers/bookmark/handle-bookmark-added.ts +82 -39
  63. package/src/feed/event-handlers/bookmark/handle-bookmark-deleted.test.ts +188 -0
  64. package/src/feed/event-handlers/bookmark/handle-bookmark-deleted.ts +86 -48
  65. package/src/feed/event-handlers/bookmark/handle-bookmark-updated.test.ts +196 -0
  66. package/src/feed/event-handlers/bookmark/handle-bookmark-updated.ts +83 -44
  67. package/src/feed/event-handlers/comment/handle-comment-added.test.ts +147 -0
  68. package/src/feed/event-handlers/comment/handle-comment-deleted.test.ts +133 -0
  69. package/src/feed/event-handlers/comment/handle-comment-deleted.ts +24 -10
  70. package/src/feed/event-handlers/comment/handle-comment-reaction.test.ts +315 -0
  71. package/src/feed/event-handlers/comment/handle-comment-updated.test.ts +131 -0
  72. package/src/feed/event-handlers/follow/handle-follow-created.test.ts +7 -7
  73. package/src/feed/event-handlers/follow/handle-follow-deleted.test.ts +2 -2
  74. package/src/feed/event-handlers/follow/handle-follow-updated.test.ts +1 -1
  75. package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.test.ts +120 -0
  76. package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.ts +47 -3
  77. package/src/feed/feed.ts +4 -2
  78. package/src/gen/model-decoders/decoders.ts +14 -1
  79. package/src/gen/models/index.ts +73 -2
  80. package/src/gen/moderation/ModerationApi.ts +1 -0
  81. package/src/test-utils/response-generators.ts +383 -0
  82. package/src/utils/index.ts +1 -0
  83. package/src/utils/update-entity-in-array.ts +51 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/feeds-client",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "./dist/index.node.js",
6
6
  "exports": {
@@ -0,0 +1,208 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ ActivityMarkEvent,
4
+ NotificationStatusResponse,
5
+ } from '../../../gen/models';
6
+ import { updateNotificationStatusFromActivityMarked } from './handle-activity-marked';
7
+
8
+ const createMockActivityMarkEvent = (
9
+ overrides: Partial<ActivityMarkEvent> = {},
10
+ ): ActivityMarkEvent => ({
11
+ created_at: new Date(),
12
+ fid: 'user:notification',
13
+ custom: {},
14
+ type: 'feeds.activity.marked',
15
+ ...overrides,
16
+ });
17
+
18
+ const createMockNotificationStatus = (
19
+ overrides: Partial<NotificationStatusResponse> = {},
20
+ ): NotificationStatusResponse => ({
21
+ unread: 0,
22
+ unseen: 0,
23
+ ...overrides,
24
+ });
25
+
26
+ const createMockAggregatedActivity = (group: string) => ({ group });
27
+
28
+ describe('activity-marked-utils', () => {
29
+ describe('updateNotificationStatusFromActivityMarked', () => {
30
+ it('should return unchanged if notification_status is undefined', () => {
31
+ const event = createMockActivityMarkEvent({ mark_all_read: true });
32
+ const currentStatus = undefined;
33
+
34
+ const result = updateNotificationStatusFromActivityMarked(
35
+ event,
36
+ currentStatus,
37
+ );
38
+
39
+ expect(result.changed).toBe(false);
40
+ });
41
+
42
+ it('should handle mark_all_read by adding all aggregated activity groups', () => {
43
+ const event = createMockActivityMarkEvent({ mark_all_read: true });
44
+ const currentStatus = createMockNotificationStatus({
45
+ read_activities: ['existing1'],
46
+ });
47
+ const aggregatedActivities = [
48
+ createMockAggregatedActivity('group1'),
49
+ createMockAggregatedActivity('group2'),
50
+ createMockAggregatedActivity('group3'),
51
+ ];
52
+
53
+ const result = updateNotificationStatusFromActivityMarked(
54
+ event,
55
+ currentStatus,
56
+ aggregatedActivities,
57
+ );
58
+
59
+ expect(result.changed).toBe(true);
60
+ expect(result.data?.notification_status.read_activities).toEqual([
61
+ 'existing1',
62
+ 'group1',
63
+ 'group2',
64
+ 'group3',
65
+ ]);
66
+ });
67
+
68
+ it('should handle mark_read by adding specific activity IDs', () => {
69
+ const event = createMockActivityMarkEvent({
70
+ mark_read: ['activity1', 'activity2'],
71
+ });
72
+ const currentStatus = createMockNotificationStatus({
73
+ read_activities: ['existing1'],
74
+ });
75
+
76
+ const result = updateNotificationStatusFromActivityMarked(
77
+ event,
78
+ currentStatus,
79
+ );
80
+
81
+ expect(result.changed).toBe(true);
82
+ expect(result.data?.notification_status.read_activities).toEqual([
83
+ 'existing1',
84
+ 'activity1',
85
+ 'activity2',
86
+ ]);
87
+ });
88
+
89
+ it('should handle mark_all_seen by setting last_seen_at to current date', () => {
90
+ const event = createMockActivityMarkEvent({ mark_all_seen: true });
91
+ const currentStatus = createMockNotificationStatus({
92
+ last_seen_at: new Date('2023-01-01'),
93
+ });
94
+
95
+ const result = updateNotificationStatusFromActivityMarked(
96
+ event,
97
+ currentStatus,
98
+ );
99
+
100
+ expect(result.changed).toBe(true);
101
+ expect(result.data?.notification_status.last_seen_at).toBeInstanceOf(
102
+ Date,
103
+ );
104
+ expect(
105
+ result.data?.notification_status.last_seen_at!.getTime(),
106
+ ).toBeGreaterThan(new Date('2023-01-01').getTime());
107
+ });
108
+
109
+ it('should handle multiple mark flags simultaneously', () => {
110
+ const event = createMockActivityMarkEvent({
111
+ mark_all_read: true,
112
+ mark_all_seen: true,
113
+ });
114
+ const currentStatus = createMockNotificationStatus({
115
+ read_activities: ['existing1'],
116
+ last_seen_at: new Date('2023-01-01'),
117
+ });
118
+ const aggregatedActivities = [
119
+ createMockAggregatedActivity('group1'),
120
+ createMockAggregatedActivity('group2'),
121
+ ];
122
+
123
+ const result = updateNotificationStatusFromActivityMarked(
124
+ event,
125
+ currentStatus,
126
+ aggregatedActivities,
127
+ );
128
+
129
+ expect(result.changed).toBe(true);
130
+ expect(result.data?.notification_status.read_activities).toEqual([
131
+ 'existing1',
132
+ 'group1',
133
+ 'group2',
134
+ ]);
135
+ expect(result.data?.notification_status.last_seen_at).toBeInstanceOf(
136
+ Date,
137
+ );
138
+ });
139
+
140
+ it('should deduplicate read activities when adding new ones', () => {
141
+ const event = createMockActivityMarkEvent({
142
+ mark_read: ['activity1', 'activity1', 'activity2'],
143
+ });
144
+ const currentStatus = createMockNotificationStatus({
145
+ read_activities: ['existing1', 'activity1'],
146
+ });
147
+
148
+ const result = updateNotificationStatusFromActivityMarked(
149
+ event,
150
+ currentStatus,
151
+ );
152
+
153
+ expect(result.changed).toBe(true);
154
+ expect(result.data?.notification_status.read_activities).toEqual([
155
+ 'existing1',
156
+ 'activity1',
157
+ 'activity2',
158
+ ]);
159
+ });
160
+
161
+ it('should preserve existing notification status fields', () => {
162
+ const event = createMockActivityMarkEvent({ mark_all_seen: true });
163
+ const currentStatus = createMockNotificationStatus({
164
+ unread: 5,
165
+ unseen: 3,
166
+ read_activities: ['existing1'],
167
+ });
168
+
169
+ const result = updateNotificationStatusFromActivityMarked(
170
+ event,
171
+ currentStatus,
172
+ );
173
+
174
+ expect(result.changed).toBe(true);
175
+ expect(result.data?.notification_status.unread).toBe(5);
176
+ expect(result.data?.notification_status.unseen).toBe(3);
177
+ expect(result.data?.notification_status.read_activities).toEqual([
178
+ 'existing1',
179
+ ]);
180
+ expect(result.data?.notification_status.last_seen_at).toBeInstanceOf(
181
+ Date,
182
+ );
183
+ });
184
+
185
+ it('should handle mark_all_read with no existing read_activities', () => {
186
+ const event = createMockActivityMarkEvent({ mark_all_read: true });
187
+ const currentStatus = createMockNotificationStatus({
188
+ read_activities: undefined,
189
+ });
190
+ const aggregatedActivities = [
191
+ createMockAggregatedActivity('group1'),
192
+ createMockAggregatedActivity('group2'),
193
+ ];
194
+
195
+ const result = updateNotificationStatusFromActivityMarked(
196
+ event,
197
+ currentStatus,
198
+ aggregatedActivities,
199
+ );
200
+
201
+ expect(result.changed).toBe(true);
202
+ expect(result.data?.notification_status.read_activities).toEqual([
203
+ 'group1',
204
+ 'group2',
205
+ ]);
206
+ });
207
+ });
208
+ });
@@ -5,73 +5,45 @@ import {
5
5
  ActivityResponse,
6
6
  FeedsReactionResponse,
7
7
  } from '../../../gen/models';
8
+ import { addReactionToActivities, removeReactionFromActivities } from './';
8
9
  import {
9
- addReactionToActivity,
10
- removeReactionFromActivity,
11
- addReactionToActivities,
12
- removeReactionFromActivities,
13
- } from './';
14
-
15
- const createMockActivity = (id: string): ActivityResponse => ({
16
- id,
17
- type: 'test',
18
- created_at: new Date(),
19
- updated_at: new Date(),
20
- visibility: 'public',
21
- bookmark_count: 0,
22
- comment_count: 0,
23
- share_count: 0,
24
- attachments: [],
25
- comments: [],
26
- feeds: [],
27
- filter_tags: [],
28
- interest_tags: [],
29
- latest_reactions: [],
30
- mentioned_users: [],
31
- own_bookmarks: [],
32
- own_reactions: [],
33
- custom: {},
34
- reaction_groups: {},
35
- search_data: {},
36
- popularity: 0,
37
- score: 0,
38
- reaction_count: 0,
39
- user: {
40
- id: 'user1',
41
- created_at: new Date(),
42
- updated_at: new Date(),
43
- banned: false,
44
- language: 'en',
45
- online: false,
46
- role: 'user',
47
- blocked_user_ids: [],
48
- teams: [],
49
- custom: {},
50
- },
51
- });
10
+ generateActivityResponse,
11
+ generateFeedReactionResponse,
12
+ } from '../../../test-utils';
52
13
 
53
- const createMockReaction = (
54
- type: string,
55
- userId: string,
56
- activityId: string,
57
- ): FeedsReactionResponse => ({
58
- type,
59
- user: {
60
- id: userId,
61
- created_at: new Date(),
62
- updated_at: new Date(),
63
- banned: false,
64
- language: 'en',
65
- online: false,
66
- role: 'user',
67
- blocked_user_ids: [],
68
- teams: [],
69
- custom: {},
70
- },
71
- activity_id: activityId,
72
- created_at: new Date(),
73
- updated_at: new Date(),
74
- });
14
+ const addReactionToActivity = (
15
+ event: ActivityReactionAddedEvent,
16
+ activity: ActivityResponse,
17
+ eventBelongsToCurrentUser: boolean,
18
+ ) => {
19
+ const result = addReactionToActivities(
20
+ event,
21
+ [activity],
22
+ eventBelongsToCurrentUser,
23
+ );
24
+
25
+ return {
26
+ changed: result.changed,
27
+ ...result.entities![0],
28
+ };
29
+ };
30
+
31
+ const removeReactionFromActivity = (
32
+ event: ActivityReactionAddedEvent,
33
+ activity: ActivityResponse,
34
+ eventBelongsToCurrentUser: boolean,
35
+ ) => {
36
+ const result = removeReactionFromActivities(
37
+ event,
38
+ [activity],
39
+ eventBelongsToCurrentUser,
40
+ );
41
+
42
+ return {
43
+ changed: result.changed,
44
+ ...result.entities![0],
45
+ };
46
+ };
75
47
 
76
48
  const createMockAddedEvent = (
77
49
  reaction: FeedsReactionResponse,
@@ -100,8 +72,12 @@ const createMockDeletedEvent = (
100
72
  describe('activity-reaction-utils', () => {
101
73
  describe('addReactionToActivity', () => {
102
74
  it('should add reaction to own_reactions when from current user', () => {
103
- const activity = createMockActivity('activity1');
104
- const reaction = createMockReaction('like', 'user1', 'activity1');
75
+ const activity = generateActivityResponse({ id: 'activity1' });
76
+ const reaction = generateFeedReactionResponse({
77
+ type: 'like',
78
+ user: { id: 'user1' },
79
+ activity_id: 'activity1',
80
+ });
105
81
  const eventActivity = { ...activity };
106
82
  eventActivity.latest_reactions = [reaction];
107
83
  eventActivity.reaction_groups = {
@@ -129,8 +105,12 @@ describe('activity-reaction-utils', () => {
129
105
  });
130
106
 
131
107
  it('should not add reaction to own_reactions when not from current user', () => {
132
- const activity = createMockActivity('activity1');
133
- const reaction = createMockReaction('like', 'user2', 'activity1');
108
+ const activity = generateActivityResponse({ id: 'activity1' });
109
+ const reaction = generateFeedReactionResponse({
110
+ type: 'like',
111
+ user: { id: 'user2' },
112
+ activity_id: 'activity1',
113
+ });
134
114
  const eventActivity = { ...activity };
135
115
  eventActivity.latest_reactions = [reaction];
136
116
  eventActivity.reaction_groups = {
@@ -160,8 +140,12 @@ describe('activity-reaction-utils', () => {
160
140
 
161
141
  describe('removeReactionFromActivity', () => {
162
142
  it('should remove reaction from own_reactions when from current user', () => {
163
- const activity = createMockActivity('activity1');
164
- const reaction = createMockReaction('like', 'user1', 'activity1');
143
+ const activity = generateActivityResponse({ id: 'activity1' });
144
+ const reaction = generateFeedReactionResponse({
145
+ type: 'like',
146
+ user: { id: 'user1' },
147
+ activity_id: 'activity1',
148
+ });
165
149
  const eventActivity = { ...activity };
166
150
  eventActivity.latest_reactions = [reaction];
167
151
  eventActivity.reaction_groups = {
@@ -192,8 +176,12 @@ describe('activity-reaction-utils', () => {
192
176
  });
193
177
 
194
178
  it('should not remove reaction from own_reactions when not from current user', () => {
195
- const activity = createMockActivity('activity1');
196
- const reaction = createMockReaction('like', 'user1', 'activity1');
179
+ const activity = generateActivityResponse({ id: 'activity1' });
180
+ const reaction = generateFeedReactionResponse({
181
+ type: 'like',
182
+ user: { id: 'user1' },
183
+ activity_id: 'activity1',
184
+ });
197
185
  const eventActivity = { ...activity };
198
186
  eventActivity.latest_reactions = [reaction];
199
187
  eventActivity.reaction_groups = {
@@ -226,9 +214,13 @@ describe('activity-reaction-utils', () => {
226
214
 
227
215
  describe('addReactionToActivities', () => {
228
216
  it('should add reaction to activity in activities array', () => {
229
- const activity = createMockActivity('activity1');
217
+ const activity = generateActivityResponse({ id: 'activity1' });
230
218
  const activities = [activity];
231
- const reaction = createMockReaction('like', 'user1', 'activity1');
219
+ const reaction = generateFeedReactionResponse({
220
+ type: 'like',
221
+ user: { id: 'user1' },
222
+ activity_id: 'activity1',
223
+ });
232
224
  const eventActivity = { ...activity };
233
225
  eventActivity.latest_reactions = [reaction];
234
226
  eventActivity.reaction_groups = {
@@ -244,16 +236,20 @@ describe('activity-reaction-utils', () => {
244
236
  const result = addReactionToActivities(event, activities, true);
245
237
 
246
238
  expect(result.changed).toBe(true);
247
- expect(result.activities).toHaveLength(1);
248
- expect(result.activities[0].own_reactions).toHaveLength(1);
249
- expect(result.activities[0].own_reactions[0]).toEqual(reaction);
239
+ expect(result.entities!).toHaveLength(1);
240
+ expect(result.entities![0].own_reactions).toHaveLength(1);
241
+ expect(result.entities![0].own_reactions[0]).toEqual(reaction);
250
242
  });
251
243
 
252
244
  it('should return unchanged state if activity not found', () => {
253
- const activity = createMockActivity('activity1');
245
+ const activity = generateActivityResponse({ id: 'activity1' });
254
246
  const activities = [activity];
255
- const reaction = createMockReaction('like', 'user1', 'activity2');
256
- const eventActivity = createMockActivity('activity2');
247
+ const reaction = generateFeedReactionResponse({
248
+ type: 'like',
249
+ user: { id: 'user1' },
250
+ activity_id: 'activity2',
251
+ });
252
+ const eventActivity = generateActivityResponse({ id: 'activity2' });
257
253
  eventActivity.latest_reactions = [reaction];
258
254
  eventActivity.reaction_groups = {
259
255
  [reaction.type]: {
@@ -268,12 +264,16 @@ describe('activity-reaction-utils', () => {
268
264
  const result = addReactionToActivities(event, activities, true);
269
265
 
270
266
  expect(result.changed).toBe(false);
271
- expect(result.activities).toBe(activities);
267
+ expect(result.entities).toBe(activities);
272
268
  });
273
269
 
274
270
  it('should handle undefined activities', () => {
275
- const activity = createMockActivity('activity1');
276
- const reaction = createMockReaction('like', 'user1', 'activity1');
271
+ const activity = generateActivityResponse({ id: 'activity1' });
272
+ const reaction = generateFeedReactionResponse({
273
+ type: 'like',
274
+ user: { id: 'user1' },
275
+ activity_id: 'activity1',
276
+ });
277
277
  const eventActivity = { ...activity };
278
278
  eventActivity.own_reactions = [reaction];
279
279
  eventActivity.latest_reactions = [reaction];
@@ -290,14 +290,18 @@ describe('activity-reaction-utils', () => {
290
290
  const result = addReactionToActivities(event, undefined, true);
291
291
 
292
292
  expect(result.changed).toBe(false);
293
- expect(result.activities).toEqual([]);
293
+ expect(result.entities).toBeUndefined();
294
294
  });
295
295
  });
296
296
 
297
297
  describe('removeReactionFromActivities', () => {
298
298
  it('should remove reaction from activity in activities array', () => {
299
- const activity = createMockActivity('activity1');
300
- const reaction = createMockReaction('like', 'user1', 'activity1');
299
+ const activity = generateActivityResponse({ id: 'activity1' });
300
+ const reaction = generateFeedReactionResponse({
301
+ type: 'like',
302
+ user: { id: 'user1' },
303
+ activity_id: 'activity1',
304
+ });
301
305
  const eventActivity = { ...activity };
302
306
  eventActivity.latest_reactions = [reaction];
303
307
  eventActivity.reaction_groups = {
@@ -323,15 +327,19 @@ describe('activity-reaction-utils', () => {
323
327
  );
324
328
 
325
329
  expect(result.changed).toBe(true);
326
- expect(result.activities).toHaveLength(1);
327
- expect(result.activities[0].own_reactions).toHaveLength(0);
330
+ expect(result.entities).toHaveLength(1);
331
+ expect(result.entities![0].own_reactions).toHaveLength(0);
328
332
  });
329
333
 
330
334
  it('should return unchanged state if activity not found', () => {
331
- const activity = createMockActivity('activity1');
335
+ const activity = generateActivityResponse({ id: 'activity1' });
332
336
  const activities = [activity];
333
- const reaction = createMockReaction('like', 'user1', 'activity2');
334
- const eventActivity = createMockActivity('activity2');
337
+ const reaction = generateFeedReactionResponse({
338
+ type: 'like',
339
+ user: { id: 'user1' },
340
+ activity_id: 'activity2',
341
+ });
342
+ const eventActivity = generateActivityResponse({ id: 'activity2' });
335
343
  eventActivity.latest_reactions = [];
336
344
  eventActivity.reaction_groups = {};
337
345
  const event = createMockDeletedEvent(reaction, eventActivity);
@@ -339,12 +347,16 @@ describe('activity-reaction-utils', () => {
339
347
  const result = removeReactionFromActivities(event, activities, true);
340
348
 
341
349
  expect(result.changed).toBe(false);
342
- expect(result.activities).toBe(activities);
350
+ expect(result.entities).toBe(activities);
343
351
  });
344
352
 
345
353
  it('should handle undefined activities', () => {
346
- const activity = createMockActivity('activity1');
347
- const reaction = createMockReaction('like', 'user1', 'activity1');
354
+ const activity = generateActivityResponse({ id: 'activity1' });
355
+ const reaction = generateFeedReactionResponse({
356
+ type: 'like',
357
+ user: { id: 'user1' },
358
+ activity_id: 'activity1',
359
+ });
348
360
  const eventActivity = { ...activity };
349
361
  eventActivity.latest_reactions = [];
350
362
  eventActivity.reaction_groups = {};
@@ -353,7 +365,7 @@ describe('activity-reaction-utils', () => {
353
365
  const result = removeReactionFromActivities(event, undefined, true);
354
366
 
355
367
  expect(result.changed).toBe(false);
356
- expect(result.activities).toEqual([]);
368
+ expect(result.entities).toBeUndefined();
357
369
  });
358
370
  });
359
371
  });