Files
genoffice/apps/docs/tests/float-spill.test.ts
T
merrick-2002andGenOffice 6d9b6812dd Sync snapshot (2026-08-23) (#130)
- Convert scanned PDFs to editable text with local OCR, running through the operating system's own engine on macOS and Windows
- Add a much richer AI workflow to Docs, PDF, and Markdown: selection-scoped questions, batched edits, character-level edits, comment and tracked-change awareness, citations back to the source block, and in-document image generation
- Let Slides open the same presentation in a second window and edit it from both
- Improve PDF to Excel table recovery: tables spanning pages merge into one worksheet, and label/value grids and rule-less statement bands become real rows
- Fix a large wave of Word layout fidelity in Docs, Excel parity in Sheets, and PowerPoint import fidelity in Slides

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-08-23 23:10:02 +08:00

44 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
appendFloatSpillBlock,
computeSectionedSlicesF2,
type BlockBox,
type FloatBox,
} from '../src/renderer/pagination'
const el = null as unknown as HTMLElement
const base = { anchorTop: 0, pinned: false, pageRelV: false }
describe('appendFloatSpillBlock', () => {
it('appends a virtual block spanning to the lowest float bottom', () => {
const blocks: BlockBox[] = [{ top: 0, height: 100 }]
const floats: FloatBox[] = [{ el, ...base, top: 950, height: 400 }]
const total = appendFloatSpillBlock(blocks, 100, floats)
expect(total).toBe(1350)
const spill = blocks[1]
expect(spill.isFloatSpill).toBe(true)
expect(spill.top).toBe(100)
expect(spill.height).toBe(1250)
expect(spill.lineBoxes!.length).toBeGreaterThan(1)
})
it('returns null when floats stay within the flow', () => {
const blocks: BlockBox[] = [{ top: 0, height: 500 }]
expect(appendFloatSpillBlock(blocks, 500, [{ el, ...base, top: 100, height: 200 }])).toBeNull()
expect(blocks).toHaveLength(1)
})
it('materializes trailing pages for overflowing floats', () => {
const blocks: BlockBox[] = [{ top: 0, height: 100 }]
const floats: FloatBox[] = [{ el, ...base, top: 1500, height: 400 }]
const total = appendFloatSpillBlock(blocks, 100, floats)!
const slices = computeSectionedSlicesF2(
blocks,
[{ contentHeight: 900, forceBreak: false }],
total,
)
expect(slices.length).toBeGreaterThanOrEqual(2)
expect(slices[slices.length - 1].end).toBeGreaterThanOrEqual(1900)
})
})