sort comments
Gitea Actions Demo / Deploy (push) Successful in 1m50s

This commit is contained in:
vadim committed 2026-10-02 21:43:37 +03:00
1 parent d0fcc93a8d
commit 5607e97533
7 files changed
+60 -9

No files matched your search

@@ -32,11 +32,30 @@ describe('ListCommentsUseCase', () => {
const result = await useCase.execute(new ListCommentsQuery(1, 'user-1', 1, 'comment-1'));
expect(commentRepository.findByIssue).toHaveBeenCalledWith({ issueId: 1, limit: 1, cursor: 'comment-1' });
expect(commentRepository.findByIssue).toHaveBeenCalledWith({
issueId: 1,
limit: 1,
cursor: 'comment-1',
direction: 'forward',
});
expect(result.list.map((comment) => comment.id)).toEqual(['comment-2']);
expect(result.nextCursor).toBe('comment-2');
});
it('forwards the backward direction for chat-style paging', async () => {
vi.mocked(issueRepository.findById).mockResolvedValue(buildIssue());
vi.mocked(commentRepository.findByIssue).mockResolvedValue({ list: [], nextCursor: null });
await useCase.execute(new ListCommentsQuery(1, 'user-1', 20, 'comment-5', 'backward'));
expect(commentRepository.findByIssue).toHaveBeenCalledWith({
issueId: 1,
limit: 20,
cursor: 'comment-5',
direction: 'backward',
});
});
it('throws IssueNotFoundException when the issue is not visible to the user', async () => {
vi.mocked(issueRepository.findById).mockResolvedValue(null);