新增迁移50与每5分钟/手动持久同步,API只读本地;同步失败保留、权限阻断、租约与质量失效原子激活。 保留全量稳定分页/固定列,已存质量批量读取,元数据不反复解压长答案;详情安全Markdown与原文。 已运行整仓 make verify、源与副本隔离PG -race、真实只读源及隔离浏览器。 实际同步2525条;固定窗口640条本地中位1.46秒,对照直接源33.10秒。 停worker、缺源凭据、重启API后仍可查询;未更新8088,未修改生产原问答。
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { QAAnswerMarkdown } from './QAAnswerMarkdown'
|
||||
describe('AI answer Markdown preview', () => {
|
||||
it('renders headings, tables, code, links and keeps original source', () => {
|
||||
const answer =
|
||||
'# 安装步骤\n\n- **先断电**\n- 检查接线\n\n| 参数 | 值 |\n| --- | --- |\n| 速度 | 50 |\n\n```python\nprint("ready")\n```\n\n[说明](https://example.invalid/guide)'
|
||||
const html = renderToStaticMarkup(<QAAnswerMarkdown answer={answer} />)
|
||||
expect(html).toContain('<h1>安装步骤</h1>')
|
||||
expect(html).toContain('<strong>先断电</strong>')
|
||||
expect(html).toContain('<table>')
|
||||
expect(html).toContain('language-python')
|
||||
expect(html).toContain('href="https://example.invalid/guide"')
|
||||
expect(html).toContain('noopener noreferrer')
|
||||
expect(html).toContain('查看 Markdown 原文')
|
||||
})
|
||||
it('never executes raw HTML, unsafe URL schemes or automatically loads external images', () => {
|
||||
const answer =
|
||||
'<script>globalThis.PWNED=true</script>\n\n<img src="x" onerror="alert(1)">\n\n[unsafe](javascript:alert%281%29)\n\n'
|
||||
const html = renderToStaticMarkup(<QAAnswerMarkdown answer={answer} />)
|
||||
expect(html).not.toContain('<script>')
|
||||
expect(html).not.toContain('<img ')
|
||||
expect(html).not.toContain('href="javascript:')
|
||||
expect(html.split('<details')[0]).not.toContain('onerror=')
|
||||
expect(html).toContain('查看图片')
|
||||
})
|
||||
it('does not confuse an empty answer with a positive assessment', () => {
|
||||
expect(renderToStaticMarkup(<QAAnswerMarkdown answer="" />)).toContain('尚无答案;不默认判覆盖或正确')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user