e0a5f57793
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.
67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { getMarkdown, parseMarkdownToStructure } from '../src'
|
|
import { fixTableTokens } from '../src/plugins/fixTableTokens'
|
|
|
|
describe('table loading mid-states', () => {
|
|
it('recognizes spaced separator rows as loading tables', () => {
|
|
const md = getMarkdown('table-loading-spaced-separator')
|
|
const markdown = `# 表格
|
|
|列1|列2|列3|列4|列5|
|
|
| - | - | - | - | `
|
|
|
|
const nodes = parseMarkdownToStructure(markdown, md, { final: false }) as any[]
|
|
const table = nodes.find(node => node.type === 'table') as any
|
|
|
|
expect(table).toBeTruthy()
|
|
expect(table.loading).toBe(true)
|
|
expect(table.header.cells.map((cell: any) => cell.raw)).toEqual(['列1', '列2', '列3', '列4', '列5'])
|
|
})
|
|
|
|
it('keeps header cells when the separator row is only partially typed', () => {
|
|
const md = getMarkdown('table-loading-partial-separator')
|
|
const markdown = `# 表格
|
|
|列1|列2|列3|列4|列5|
|
|
|:-`
|
|
|
|
const nodes = parseMarkdownToStructure(markdown, md, { final: false }) as any[]
|
|
const table = nodes.find(node => node.type === 'table') as any
|
|
|
|
expect(table).toBeTruthy()
|
|
expect(table.loading).toBe(true)
|
|
expect(table.header.cells.map((cell: any) => cell.raw)).toEqual(['列1', '列2', '列3', '列4', '列5'])
|
|
})
|
|
|
|
it('fixes inline fallback tables with spaced alignment markers', () => {
|
|
const tokens = [
|
|
{ type: 'paragraph_open', tag: 'p' },
|
|
{ type: 'inline', tag: '', content: '|列1|列2|列3|\n| :- | :-: | -: |', children: null },
|
|
{ type: 'paragraph_close', tag: 'p' },
|
|
] as any[]
|
|
|
|
const fixed = fixTableTokens(tokens)
|
|
|
|
expect(fixed[0]?.type).toBe('table_open')
|
|
expect(fixed[0]?.loading).toBe(true)
|
|
expect(fixed.filter(token => token.type === 'th_open')).toHaveLength(3)
|
|
expect(fixed.filter(token => token.type === 'inline').map(token => token.content)).toEqual(['列1', '列2', '列3'])
|
|
})
|
|
|
|
it('does not hang on long malformed separator rows', { timeout: 500 }, () => {
|
|
const tokens = [
|
|
{ type: 'paragraph_open', tag: 'p' },
|
|
{
|
|
type: 'inline',
|
|
tag: '',
|
|
content: `|${'列|'.repeat(4000)}\n|${' :-'.repeat(4000)}`,
|
|
children: [{}, {}, {}],
|
|
},
|
|
{ type: 'paragraph_close', tag: 'p' },
|
|
] as any[]
|
|
|
|
const fixed = fixTableTokens(tokens)
|
|
|
|
expect(fixed).toHaveLength(3)
|
|
expect(fixed[1]?.type).toBe('inline')
|
|
})
|
|
})
|