| 1 | import fs from 'fs' |
| 2 | import path from 'path' |
| 3 | import { describe, expect, it } from 'vitest' |
| 4 | |
| 5 | const exportHandlersSource = (): string => |
| 6 | fs.readFileSync(path.resolve('src/main/io/export-handlers.ts'), 'utf8') |
| 7 | |
| 8 | const handlerSource = (source: string, channel: string, nextChannel: string): string => |
| 9 | source.slice( |
| 10 | source.indexOf(`ipcMain.handle('${channel}'`), |
| 11 | source.indexOf(`ipcMain.handle('${nextChannel}'`) |
| 12 | ) |
| 13 | |
| 14 | describe('export slide-size routing', () => { |
| 15 | it('routes a supported 16:9 or 4:3 slide size through PPTX export', () => { |
| 16 | const source = exportHandlersSource() |
| 17 | const pptxHandler = handlerSource(source, 'export:pptx', 'export:video') |
| 18 | |
| 19 | expect(pptxHandler).toContain('const slideSize = requireSessionSlideSize(session)') |
| 20 | expect(pptxHandler).toContain('assertPptxExportSupported(slideSize)') |
| 21 | expect(pptxHandler).toContain('const pptxLayout = resolvePptxExportLayout(slideSize)') |
| 22 | expect(pptxHandler).toContain('widthIn: pptxLayout.slideWidthIn') |
| 23 | expect(pptxHandler).toContain('heightIn: pptxLayout.slideHeightIn') |
| 24 | }) |
| 25 | |
| 26 | it('uses a standard video frame while passing slide size for centered page fitting', () => { |
| 27 | const source = exportHandlersSource() |
| 28 | const videoHandler = handlerSource(source, 'export:video', 'export:outlinesMarkdown') |
| 29 | |
| 30 | expect(videoHandler).toContain('const slideSize = requireSessionSlideSize(session)') |
| 31 | expect(videoHandler).toContain('slideSize,') |
| 32 | expect(videoHandler).not.toContain('width: slideSize.width') |
| 33 | expect(videoHandler).not.toContain('height: slideSize.height') |
| 34 | expect(videoHandler).toContain('exportHtmlPagesToVideo({') |
| 35 | }) |
| 36 | }) |
| 37 |