Files
genoffice/apps/docs/tests/doc-style-css-borders.test.ts
T
merrick-2002andGenOffice 80d2a4651e Sync snapshot (2026-09-17) (#463)
- MCP over HTTP: `genoffice mcp --http` serves the tool set as a Streamable HTTP server for clients on other machines, with file upload, URL inputs and result files handed back; MCP agents can also read PDF text, edit the open document and drive the visible Sheets grid
- Docs: picture-heavy documents open lazily with media served from disk (gigabyte files in seconds), files over 512 MB are refused with a message instead of a crash, long documents open and type faster, and many Word-fidelity fixes for tables (autofit width, split rows, header-row keep, page-edge borders), anchored pictures and text boxes, header/footer spacing, chart labels and EMF+ clipping, Japanese font substitution, italic and bidi runs
- Markdown: saving keeps unchanged blocks byte-for-byte and re-serializes edited blocks in the document's own conventions (plus an opt-in unchanged-source round trip); ```wavedrom fences render as timing diagrams
- Sheets: smooth scrolling, duplicate and large-range copy on big streamed workbooks; context-menu submenus reopen reliably; AI bulk-job economy rules
- App: Help → Check for Updates and an About-dialog button; the in-editor Files pane and floating Files / Outline edge tabs are removed from all editors; AI panel can dock on either side
- AI providers: DeepSeek V4.1 Flash, gpt-6-astra and Opper added, retired ids dropped, clearer error when a tool call's arguments are too large
- PPTX: chart categories honor the 1904 date system, slide text extracts in presentation order, single-quoted attributes and case-insensitive preset colors parse; backports of public PRs #432–#461

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-09-17 21:30:17 +08:00

54 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { ParsedDocFull, StyleDisplay, StyleInfo } from '@genoffice/docx-engine'
import { docStyleCss } from '../src/renderer/doc-style-css'
;(globalThis as { CSS?: unknown }).CSS ??= { escape: (s: string) => s }
function parsedWith(styleId: string, display: StyleDisplay): ParsedDocFull {
const styles = new Map<string, StyleInfo>()
styles.set('Normal', {
styleId: 'Normal',
name: 'Normal',
type: 'paragraph',
isDefault: true,
} as StyleInfo)
styles.set(styleId, {
styleId,
name: styleId,
type: 'paragraph',
basedOn: 'Normal',
display,
} as StyleInfo)
return { styles, docDefaults: {}, blocks: [] } as unknown as ParsedDocFull
}
describe('docStyleCss paragraph borders', () => {
it('draws style-level w:pBdr sides with the direct-border look', () => {
const css = docStyleCss(
parsedWith('HDR', { borderSides: { b: { color: '1F4E79', szPt: 6 }, t: {} } }),
)
expect(css).toContain(
'[data-style="HDR"] { border-top:1px solid #444;border-bottom:8px solid #1F4E79;padding-top:0;padding-bottom:0 }',
)
})
it('pads only the drawn sides, by w:space, as longhands (a direct side on another edge layers per side)', () => {
const css = docStyleCss(
parsedWith('Title', { borderSides: { b: { color: '4F81BD', szPt: 1, spacePt: 4 } } }),
)
expect(css).toContain(
'[data-style="Title"] { border-bottom:1px solid #4F81BD;padding-bottom:4pt }',
)
const boxed = docStyleCss(
parsedWith('Box', { borderSides: { t: { spacePt: 1 }, l: { spacePt: 4 }, b: {}, r: {} } }),
)
expect(boxed).toContain('padding-top:1pt;padding-right:4px;padding-bottom:0;padding-left:4px }')
})
it('emits nothing for a side reset to none', () => {
const css = docStyleCss(parsedWith('Off', { borderSides: { b: null } }))
expect(css).not.toContain('border-')
expect(css).not.toContain('padding:')
})
})