Files
Agent-System-Frontend/test/previewfit.test.ts
T
weichenandCursor cf6f24e583 Scale docx pages to the preview column
Why: An A4 page is wider than the preview column, and the page background followed the app theme, so body text disappeared in dark mode.
Evidence: npm test (17 files, 81 tests) and npx tsc -b passed in modules/frontend.
Impact: Docx pages stay on --paper with their own styles and shrink to fit the column. A column wider than the page, including fullscreen, keeps them at 100%. Before: section background var(--bg) and color var(--text). After: var(--paper) and var(--paper-ink).
Refs: feature/docx-paper-preview
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-05 03:59:00 +00:00

22 lines
833 B
TypeScript

import { describe, it, expect } from 'vitest'
import { computeFitScale } from '../src/previewfit'
describe('computeFitScale', () => {
it('keeps the page at 100% when the column is wider than the page', () => {
expect(computeFitScale(1100, 794, 24)).toBe(1)
expect(computeFitScale(818, 794, 24)).toBe(1)
})
it('scales the page down to the column width after subtracting the gutter', () => {
expect(computeFitScale(420, 794, 24)).toBeCloseTo((420 - 24) / 794)
expect(computeFitScale(794, 794, 24)).toBeCloseTo((794 - 24) / 794)
})
it('does not invert or zoom when the width is unusable', () => {
expect(computeFitScale(0, 794, 24)).toBe(1)
expect(computeFitScale(20, 794, 24)).toBe(1)
expect(computeFitScale(420, 0, 24)).toBe(1)
expect(computeFitScale(Number.NaN, 794, 24)).toBe(1)
})
})