diff --git a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx index 0c632615285..e39f528552a 100644 --- a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx +++ b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx @@ -1,6 +1,6 @@ import { renderToStaticMarkup } from 'react-dom/server' import { describe, expect, it } from 'vitest' -import CommentMarkdown from './CommentMarkdown' +import CommentMarkdown, { remarkGitHubReferences } from './CommentMarkdown' describe('CommentMarkdown', () => { it('autolinks same-repo GitHub issue references when repo context is provided', () => { @@ -42,6 +42,33 @@ describe('CommentMarkdown', () => { expect(markup).not.toContain('href="https://github.com/stablyai/orca/issues/2317"') }) + it('autolinks very large generated GitHub reference comments', () => { + const referenceCount = 130_000 + const tree = { + type: 'root', + children: [ + { + type: 'paragraph', + children: [ + { + type: 'text', + value: Array.from({ length: referenceCount }, (_, index) => `#${index + 1}`).join(' ') + } + ] + } + ] + } + + const transform = remarkGitHubReferences({ owner: 'stablyai', repo: 'orca' })() + + expect(() => transform(tree)).not.toThrow() + expect(tree.children[0]?.children).toHaveLength(referenceCount * 2 - 1) + expect(tree.children[0]?.children[0]).toMatchObject({ + type: 'link', + url: 'https://github.com/stablyai/orca/issues/1' + }) + }) + it('contains long PR body markdown inside its available width', () => { const markup = renderToStaticMarkup(