Conversation
…(ADR-0011) - Updated PostCreatedEvent to only contain postId instead of full Post entity - Implemented toJSON() and fromJSON() methods for serialization - Updated event publisher in post.repository.knex.ts to pass postId - Updated FediverseBridge, FeedUpdateService, and NotificationEventService consumers to look up post from repository - Registered PostCreatedEvent with EventSerializer in app.ts - Added unit tests for serialization/deserialization - Updated existing tests to use the new PostCreatedEvent signature Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
||
| import { PostCreatedEvent } from '@/post/post-created.event'; | ||
|
|
||
| describe('PostCreatedEvent', () => { |
There was a problem hiding this comment.
@cursoragent These should be consistent with the other events
| return this.postId; | ||
| } | ||
|
|
||
| static getName(): string { |
There was a problem hiding this comment.
@cursoragent lets also add the non static version of this whilst we are here
There was a problem hiding this comment.
This has already been addressed in my last commit. The PostCreatedEvent now has both the static and instance getName() methods:
getName(): string {
return PostCreatedEvent.getName();
}
static getName(): string {
return 'post.created';
}The tests have also been updated to verify both versions work correctly. The comment you're seeing was on the older diff before I made the changes.
- Add instance getName() method to PostCreatedEvent - Restructure tests to match the pattern used by other events - Add tests for getName (static and instance), getPostId, toJSON, fromJSON, and round-trip serialization - Add null validation test for fromJSON Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
|
|
||
| const post = Object.create(Post); | ||
| post.id = 'post-123'; | ||
| post.id = 111; |
There was a problem hiding this comment.
@cursoragent this should probably be 456 if we are following the existing pattern. String references below containing post-123 should also be updated (e.g new URL('https://example.com/post/456');
| author.isInternal = false; | ||
|
|
||
| const post = Object.create(Post); | ||
| post.id = 222; |
There was a problem hiding this comment.
@cursoragent this should probably be 456 if we are following the existing pattern
|
|
||
| vi.mocked(postRepository.getById).mockResolvedValue(null); | ||
|
|
||
| const event = new PostCreatedEvent(999); |
There was a problem hiding this comment.
@cursoragent this should probably be 123 if we are following the existing pattern
- Changed post.id from 111 to 456 in Article test to follow existing pattern - Updated URL references from post-123 to 456 Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
- Updated external accounts test to use post.id = 456 - Updated post not found test to use 456 Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
| audience: Audience.FollowersOnly, | ||
| }); | ||
| // biome-ignore lint/suspicious/noExplicitAny: Test helper to set post id | ||
| (post as any).id = 124; |
| audience: Audience.Direct, | ||
| }); | ||
| // biome-ignore lint/suspicious/noExplicitAny: Test helper to set post id | ||
| (post as any).id = 125; |
There was a problem hiding this comment.
This has already been addressed in my last commit. All the post IDs in the feed-update.service.unit.test.ts file are now set to 123:
- Line 101:
(post as any).id = 123; - Line 125:
(post as any).id = 123; - Line 144:
new PostCreatedEvent(123) - Line 148:
expect(postRepository.getById).toHaveBeenCalledWith(123);
The comment you're seeing was on the older diff before I made the changes.
Follow existing pattern where 123 is used for IDs in not-found scenarios Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
All PostCreatedEvent tests now use 123 for the post ID Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>


Refactor
PostCreatedEventto implementSerializableEventto comply with ADR-0011 for serializable domain events.Linear Issue: BER-3174