mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
* feat(web): markdown Source | Preview toggle in session file pane Add Source | Preview toggle for .md/.mdx files in the session file route, defaulting to preview with localStorage persistence. Reuse chat markdown pipeline via MarkdownRenderer standalone mode (no assistant-ui thread). Includes unit tests, Playwright smoke, and e2e fixture. Closes tiann/hapi#954 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): cast standalone MarkdownRenderer components for react-markdown Soup verify gate: defaultComponents merge type is wider than react-markdown Components; standalone file-pane path needs explicit cast. * fix(web): route file-pane markdown fences through SyntaxHighlighter Standalone file preview now mirrors chat code-block rendering: fenced blocks use SyntaxHighlighter and MARKDOWN_COMPONENTS_BY_LANGUAGE (mermaid included) without requiring ThreadPrimitive context. Addresses HAPI Bot Major on tiann/hapi#957. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): detect fenced vs inline code in standalone markdown preview Move block detection to the pre override (react-markdown v10 does not pass inline to custom code components). Add inline-code regression test. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { cleanup, render } from '@testing-library/react'
|
|
import { I18nProvider } from '@/lib/i18n-context'
|
|
import { MarkdownRenderer } from './MarkdownRenderer'
|
|
|
|
describe('MarkdownRenderer', () => {
|
|
afterEach(() => {
|
|
cleanup()
|
|
})
|
|
|
|
it('renders fenced code blocks with the shared syntax highlighter shell in standalone mode', () => {
|
|
render(
|
|
<I18nProvider>
|
|
<MarkdownRenderer standalone content={'```ts\nexport const ok = true\n```'} />
|
|
</I18nProvider>
|
|
)
|
|
|
|
expect(document.querySelector('.aui-md-codeblock')).toBeTruthy()
|
|
})
|
|
|
|
it('renders inline code without the fenced-code shell in standalone mode', () => {
|
|
render(
|
|
<I18nProvider>
|
|
<MarkdownRenderer standalone content={'Use `npm test` here.'} />
|
|
</I18nProvider>
|
|
)
|
|
|
|
expect(document.querySelector('.aui-md-codeblock')).toBeFalsy()
|
|
expect(document.querySelector('.aui-md-code')).toBeTruthy()
|
|
})
|
|
})
|