mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
c4ab4a9153
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.
35 lines
1.4 KiB
TypeScript
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('')
|
|
})
|
|
})
|