Files
BoosAPI/desktop/libs/markstream-vue/test/custom-html-inline-after-close.test.ts
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

41 lines
2.1 KiB
TypeScript

import { getMarkdown, parseMarkdownToStructure } from 'stream-markdown-parser'
import { describe, expect, it } from 'vitest'
describe('custom html block followed by inline text (same line)', () => {
const md = getMarkdown('custom-html-inline-after-close', { customHtmlTags: ['thinking'] })
const prefix = `<thinking>inside\n\nmore</thinking>我是`
it('wraps trailing inline tokens into a paragraph (no stray root-level inline nodes)', () => {
const markdown = `${prefix}**潮位站潮位预报智能体**,专门负责为您提供镇海潮位站的潮位预报服务。`
const nodes = parseMarkdownToStructure(markdown, md, { customHtmlTags: ['thinking'] }) as any[]
expect(nodes[0].type).toBe('thinking')
expect(nodes[1].type).toBe('paragraph')
expect(nodes[1].children?.map((n: any) => n.type)).toEqual(['text', 'strong', 'text'])
expect(nodes[1].children?.[0]?.content).toBe('我是')
expect(nodes[1].children?.[1]?.children?.[0]?.content).toBe('潮位站潮位预报智能体')
})
it('does not reintroduce the newline for other inline forms', () => {
const cases: Array<{ label: string, suffix: string, mustContainType: string }> = [
{ label: 'plain text', suffix: '普通文本。', mustContainType: 'text' },
{ label: 'emphasis', suffix: '*x*。', mustContainType: 'emphasis' },
{ label: 'strong+em', suffix: '***xx***。', mustContainType: 'strong' },
{ label: 'inline code', suffix: '`code`。', mustContainType: 'inline_code' },
{ label: 'link', suffix: '[a](https://example.com)。', mustContainType: 'link' },
{ label: 'strikethrough', suffix: '~~del~~。', mustContainType: 'strikethrough' },
]
for (const c of cases) {
const nodes = parseMarkdownToStructure(`${prefix}${c.suffix}`, md, { customHtmlTags: ['thinking'] }) as any[]
expect(nodes[0].type, c.label).toBe('thinking')
expect(nodes[1].type, c.label).toBe('paragraph')
expect(nodes.length, c.label).toBe(2)
const childTypes = (nodes[1].children ?? []).map((n: any) => n?.type).filter(Boolean)
expect(childTypes, c.label).toContain(c.mustContainType)
}
})
})