import assert from 'node:assert/strict' import { buildOnlyOfficePreviewConfig } from '../src/views/scripts/onlyOfficePreviewConfig.js' function testUsesExplicitPixelHeightFromViewport() { const config = buildOnlyOfficePreviewConfig({ width: '50%', height: '100%' }, { viewportHeight: 900 }) assert.equal(config.width, '100%') assert.equal(config.height, '680px') } function testFallsBackToSafeDefaultHeight() { const config = buildOnlyOfficePreviewConfig({}, {}) assert.equal(config.height, '720px') } function testClampsSmallViewportHeight() { const config = buildOnlyOfficePreviewConfig({}, { viewportHeight: 600 }) assert.equal(config.height, '520px') } function testUsesEmbeddedPreviewModeWithMinimalToolbar() { const config = buildOnlyOfficePreviewConfig( { editorConfig: { customization: { compactHeader: true } } }, {} ) assert.equal(config.type, 'embedded') assert.deepEqual(config.editorConfig.embedded, { embedUrl: '', fullscreenUrl: '', saveUrl: '', shareUrl: '', toolbarDocked: 'top' }) } function run() { testUsesExplicitPixelHeightFromViewport() testFallsBackToSafeDefaultHeight() testClampsSmallViewportHeight() testUsesEmbeddedPreviewModeWithMinimalToolbar() console.log('onlyoffice preview config tests passed') } run()