Files
bookorbit/client/src/features/whats-new/lib/markdown.test.ts
T
neon c4ab4a9153 feat: add in-app release notes viewer
Introduces a new feature to fetch, parse, and display app release notes
and update highlights directly within the UI.

- Backend: Adds the `release-notes` module to fetch GitHub releases
  and parse markdown highlight sections.
- Frontend: Adds the `WhatsNew` dialog and view, including custom
  markdown rendering and an image lightbox for update media.
- Tools: Adds validation scripts (`whats-new-lint`, `whats-new-preview`)
  to ensure release content parses correctly before publication.
2026-06-18 03:37:53 +00:00

35 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { renderChangelogMarkdown } from './markdown'
describe('renderChangelogMarkdown', () => {
it('renders headings, lists, bold, code and links', () => {
const md = ['### Features', '- add **two-way** sync', '- speed up `jumpRail`', '', '[issue](https://example.com/1)'].join('\n')
const html = renderChangelogMarkdown(md)
expect(html).toContain('<h3>Features</h3>')
expect(html).toContain('<ul>')
expect(html).toContain('<strong>two-way</strong>')
expect(html).toContain('<code>jumpRail</code>')
expect(html).toMatch(/<a [^>]*href="https:\/\/example\.com\/1"[^>]*>issue<\/a>/)
expect(html).toContain('target="_blank"')
expect(html).toContain('rel="noopener noreferrer"')
})
it('renders fenced code blocks and horizontal rules', () => {
const html = renderChangelogMarkdown(['---', '```bash', 'docker pull x', '```'].join('\n'))
expect(html).toContain('<hr>')
expect(html).toContain('<pre><code>docker pull x</code></pre>')
})
it('strips dangerous markup', () => {
const html = renderChangelogMarkdown('<script>alert(1)</script>\n[x](javascript:alert(1))')
expect(html).not.toContain('<script>')
expect(html).not.toContain('javascript:')
})
it('returns empty string for empty input', () => {
expect(renderChangelogMarkdown(null)).toBe('')
expect(renderChangelogMarkdown('')).toBe('')
})
})